Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1408587
| Path | csiph.com!au2pb.net!weretis.net!feeder6.news.weretis.net!news.glorb.com!bofh.it!news.nic.it!robomod |
|---|---|
| From | "Luruo, Kuthonuzo" <kuthonuzo.luruo@hpe.com> |
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH v3 1/2] mm, kasan: improve double-free detection |
| Date | Sun, 29 May 2016 17:10:02 +0200 |
| Message-ID | <rEavM-7SI-19@gated-at.bofh.it> (permalink) |
| References | <rCpyV-6Uj-7@gated-at.bofh.it> <rE9T3-7qD-13@gated-at.bofh.it> <rEam5-7Af-3@gated-at.bofh.it> <rEam5-7Af-1@gated-at.bofh.it> |
| X-Original-To | Dmitry Vyukov <dvyukov@google.com> |
| Thread-Topic | [PATCH v3 1/2] mm, kasan: improve double-free detection |
| Thread-Index | AQHRtepZIUkedbFCFUKnJo90+W4fEJ/QAL2AgAAA1yCAAAcxAIAAAJ3A |
| Accept-Language | en-US |
| Content-Language | en-US |
| X-Originating-IP | [16.216.65.175] |
| Content-Type | text/plain; charset="utf-8" |
| Content-Transfer-Encoding | base64 |
| MIME-Version | 1.0 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 45 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Andrey Ryabinin <aryabinin@virtuozzo.com>, Alexander Potapenko <glider@google.com>, Christoph Lameter <cl@linux.com>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Andrew Morton <akpm@linux-foundation.org>, kasan-dev <kasan-dev@googlegroups.com>, LKML <linux-kernel@vger.kernel.org>, "linux-mm@kvack.org" <linux-mm@kvack.org>, Yury Norov <ynorov@caviumnetworks.com> |
| X-Original-Date | Sun, 29 May 2016 15:00:05 +0000 |
| X-Original-Message-ID | <20E775CA4D599049A25800DE5799F6DD1F635924@G9W0759.americas.hpqcorp.net> |
| X-Original-References | <20160524183018.GA4769@cherokee.in.rdlabs.hpecorp.net> <CACT4Y+ZBSEpqi+aUFdKZk9ncRzAxPpBRLV8DGrEuSWSBNbdpAQ@mail.gmail.com> <20E775CA4D599049A25800DE5799F6DD1F635901@G9W0759.americas.hpqcorp.net> <CACT4Y+Yd4kvqg90NsOWPpAc7ijGLfFn2Bn6CTVVDSm07k8eX9w@mail.gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1408587 |
Show key headers only | View raw
> >> > +/* flags shadow for object header if it has been overwritten. */
> >> > +void kasan_mark_bad_meta(struct kasan_alloc_meta *alloc_info,
> >> > + struct kasan_access_info *info)
> >> > +{
> >> > + u8 *datap = (u8 *)&alloc_info->data;
> >> > +
> >> > + if ((((u8 *)info->access_addr + info->access_size) > datap) &&
> >> > + ((u8 *)info->first_bad_addr <= datap) &&
> >> > + info->is_write)
> >> > + kasan_poison_shadow((void *)datap,
> KASAN_SHADOW_SCALE_SIZE,
> >> > + KASAN_KMALLOC_BAD_META);
> >>
> >>
> >> Is it only to prevent deadlocks in kasan_meta_lock?
> >>
> >> If so, it is still unrelable because an OOB write can happen in
> >> non-instrumented code. Or, kasan_meta_lock can successfully lock
> >> overwritten garbage before noticing KASAN_KMALLOC_BAD_META. Or, two
> >> threads can assume lock ownership after noticing
> >> KASAN_KMALLOC_BAD_META.
> >>
> >> After the first report we continue working in kind of best effort
> >> mode: we can try to mitigate some things, but generally all bets are
> >> off. Because of that there is no need to build something complex,
> >> global (and still unrelable). I would just wait for at most, say, 10
> >> seconds in kasan_meta_lock, if we can't get the lock -- print an error
> >> and return. That's simple, local and won't deadlock under any
> >> circumstances.
> >> The error message will be helpful, because there are chances we will
> >> report a double-free on free of the corrupted object.
> >> e
> >> Tests can be arranged so that they write 0 (unlocked) into the meta
> >> (if necessary).
> >
> > Dmitry,
> >
> > Thanks very much for review & comments. Yes, the locking scheme in v3
> > is flawed in the presence of OOB writes on header, safety valve
> > notwithstanding. The core issue is that when thread finds lock held, it is
> > difficult to tell whether a legit lock holder exists or lock bit got flipped
> > from OOB. Earlier, I did consider a lock timeout but felt it to be a bit ugly...
> >
> > However, I believe I've found a solution and was about to push out v4
> > when your comments came in. It takes concept from v3 - exploiting
> > shadow memory - to make lock much more reliable/resilient even in the
> > presence of OOB writes. I'll push out v4 within the hour...
>
>
> Locking shadow will probably work.
It does; v4 does this ;-)
> Need to think more.
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 1/2] mm, kasan: improve double-free detection Kuthonuzo Luruo <kuthonuzo.luruo@hpe.com> - 2016-05-24 20:50 +0200
Re: [PATCH v3 1/2] mm, kasan: improve double-free detection Dmitry Vyukov <dvyukov@google.com> - 2016-05-29 16:30 +0200
Re: [PATCH v3 1/2] mm, kasan: improve double-free detection Dmitry Vyukov <dvyukov@google.com> - 2016-05-29 17:00 +0200
RE: [PATCH v3 1/2] mm, kasan: improve double-free detection "Luruo, Kuthonuzo" <kuthonuzo.luruo@hpe.com> - 2016-05-29 17:10 +0200
RE: [PATCH v3 1/2] mm, kasan: improve double-free detection "Luruo, Kuthonuzo" <kuthonuzo.luruo@hpe.com> - 2016-05-29 17:00 +0200
csiph-web