linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Walter Wu <walter-zh.wu@mediatek.com>,
	Dmitry Vyukov <dvyukov@google.com>
Cc: wsd_upstream <wsd_upstream@mediatek.com>,
	"Jason A . Donenfeld" <Jason@zx2c4.com>,
	Vasily Gorbik <gor@linux.ibm.com>, Arnd Bergmann <arnd@arndb.de>,
	Linux-MM <linux-mm@kvack.org>,
	Andrey Konovalov <andreyknvl@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	kasan-dev <kasan-dev@googlegroups.com>,
	Pekka Enberg <penberg@kernel.org>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Miles Chen <miles.chen@mediatek.com>,
	Alexander Potapenko <glider@google.com>,
	David Rientjes <rientjes@google.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	linux-mediatek@lists.infradead.org,
	Christoph Lameter <cl@linux.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v3] kasan: add memory corruption identification for software tag-based mode
Date: Wed, 10 Jul 2019 21:24:22 +0300	[thread overview]
Message-ID: <d9fd1d5b-9516-b9b9-0670-a1885e79f278@virtuozzo.com> (raw)
In-Reply-To: <1562640832.9077.32.camel@mtksdccf07>



On 7/9/19 5:53 AM, Walter Wu wrote:
> On Mon, 2019-07-08 at 19:33 +0300, Andrey Ryabinin wrote:
>>
>> On 7/5/19 4:34 PM, Dmitry Vyukov wrote:
>>> On Mon, Jul 1, 2019 at 11:56 AM Walter Wu <walter-zh.wu@mediatek.com> wrote:

>>>
>>> Sorry for delays. I am overwhelm by some urgent work. I afraid to
>>> promise any dates because the next week I am on a conference, then
>>> again a backlog and an intern starting...
>>>
>>> Andrey, do you still have concerns re this patch? This change allows
>>> to print the free stack.
>>
>> I 'm not sure that quarantine is a best way to do that. Quarantine is made to delay freeing, but we don't that here.
>> If we want to remember more free stacks wouldn't be easier simply to remember more stacks in object itself?
>> Same for previously used tags for better use-after-free identification.
>>
> 
> Hi Andrey,
> 
> We ever tried to use object itself to determine use-after-free
> identification, but tag-based KASAN immediately released the pointer
> after call kfree(), the original object will be used by another
> pointer, if we use object itself to determine use-after-free issue, then
> it has many false negative cases. so we create a lite quarantine(ring
> buffers) to record recent free stacks in order to avoid those false
> negative situations.

I'm telling that *more* than one free stack and also tags per object can be stored.
If object reused we would still have information about n-last usages of the object.
It seems like much easier and more efficient solution than patch you proposing.

As for other concern about this particular patch
 - It wasn't tested. There is deadlock (sleep in atomic) on the report path which would have been noticed it tested.
   Also GFP_NOWAIT allocation which fails very noisy and very often, especially in memory constraint enviromnent where tag-based KASAN supposed to be used.

 - Inefficient usage of memory:
	48 bytes (sizeof (qlist_object) + sizeof(kasan_alloc_meta)) per kfree() call seems like a lot. It could be less.

	The same 'struct kasan_track' stored twice in two different places (in object and in quarantine).
	Basically, at least some part of the quarantine always duplicates information that we already know about
	recently freed object. 

	Since now we call kmalloc() from kfree() path, every unique kfree() stacktrace now generates additional unique stacktrace that
	takes space in stackdepot.


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-07-10 18:25 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13  8:13 [PATCH v3] kasan: add memory corruption identification for software tag-based mode Walter Wu
2019-06-13 12:27 ` Andrey Ryabinin
2019-06-13 13:05   ` Dmitry Vyukov
2019-06-13 15:50     ` Andrey Ryabinin
2019-06-13 17:46   ` Walter Wu
2019-06-14  2:32     ` Walter Wu
2019-06-17  4:00       ` Walter Wu
2019-06-17 11:57         ` Dmitry Vyukov
2019-06-17 12:32           ` Walter Wu
2019-07-01  9:56             ` Walter Wu
2019-07-05 13:34               ` Dmitry Vyukov
2019-07-08 16:33                 ` Andrey Ryabinin
2019-07-09  2:53                   ` Walter Wu
2019-07-10 18:24                     ` Andrey Ryabinin [this message]
2019-07-11 10:06                       ` Walter Wu
2019-07-12 10:52                         ` Andrey Ryabinin
2019-07-15  3:06                           ` Walter Wu
2019-07-18 16:11                             ` Andrey Ryabinin
2019-07-22  9:52                               ` Walter Wu
2019-07-26 12:00                                 ` Andrey Ryabinin
2019-07-26 12:28                                   ` Walter Wu
2019-07-26 12:52                                     ` Andrey Ryabinin
2019-07-26 13:19                                       ` Walter Wu
2019-07-31 17:04                                         ` Andrey Ryabinin
2019-08-02  3:04                                           ` Walter Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d9fd1d5b-9516-b9b9-0670-a1885e79f278@virtuozzo.com \
    --to=aryabinin@virtuozzo.com \
    --cc=Jason@zx2c4.com \
    --cc=andreyknvl@google.com \
    --cc=arnd@arndb.de \
    --cc=cl@linux.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=gor@linux.ibm.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=matthias.bgg@gmail.com \
    --cc=miles.chen@mediatek.com \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=walter-zh.wu@mediatek.com \
    --cc=wsd_upstream@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).