From: Chen Gang <chengang@emindsoft.com.cn>
To: Alexander Potapenko <glider@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Dmitriy Vyukov <dvyukov@google.com>,
kasan-dev <kasan-dev@googlegroups.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux Memory Management List <linux-mm@kvack.org>,
Chen Gang <gang.chen.5i5j@gmail.com>
Subject: Re: [PATCH] include/linux/kasan.h: Notice about 0 for kasan_[dis/en]able_current()
Date: Mon, 02 May 2016 20:40:58 +0800 [thread overview]
Message-ID: <57274ADA.8060606@emindsoft.com.cn> (raw)
In-Reply-To: <CAG_fn=W7m0UN6-38Ut0c-a_m4BfuUPjrmHQThGCLLqV-brKTmA@mail.gmail.com>
On 5/2/16 19:23, Alexander Potapenko wrote:
> On Mon, May 2, 2016 at 1:20 PM, Chen Gang <chengang@emindsoft.com.cn> wrote:
>> On 5/2/16 18:49, Alexander Potapenko wrote:
>>> On Mon, May 2, 2016 at 7:35 AM, <chengang@emindsoft.com.cn> wrote:
>>>>
>>>> According to their comments and the kasan_depth's initialization, if
>>>> kasan_depth is zero, it means disable. So kasan_depth need consider
>>>> about the 0 overflow.
>>>>
>>>> Also remove useless comments for dummy kasan_slab_free().
>>>>
>>>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>>>
>>> Acked-by: Alexander Potapenko <glider@google.com>
> Nacked-by: Alexander Potapenko <glider@google.com>
>>>
>>
>> OK, thanks.
> Well, on a second thought I take that back, there still might be problems.
> I haven't noticed the other CL, and was too hasty reviewing this one.
>
> As kasan_disable_current() and kasan_enable_current() always go
> together, we need to prevent nested calls to them from breaking
> everything.
> If we ignore some calls to kasan_disable_current() to prevent
> overflows, the pairing calls to kasan_enable_current() will bring
> |current->kasan_depth| to an invalid state.
>
> E.g. if I'm understanding your idea correctly, after the following
> sequence of calls:
> kasan_disable_current(); // #1
> kasan_disable_current(); // #2
> kasan_enable_current(); // #3
> kasan_enable_current(); // #4
>
> the value of |current->kasan_depth| will be 2, so a single subsequent
> call to kasan_disable_current() won't disable KASAN.
>
> I think we'd better add BUG checks to bail out if the value of
> |current->kasan_depth| is too big or too small.
>
For me, BUG_ON is OK. e.g.
- BUG_ON(!kasan_depth) as soon as be in kasan_enable_current().
- BUG_ON(!(kasan_depth - 1)) as soon as be in kasan_disable_current().
Welcome another members ideas, if no any additional reply within 3 days,
I shall send patch v2 for it.
Thanks.
--
Chen Gang (e??a??)
Managing Natural Environments is the Duty of Human Beings.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2016-05-02 12:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-02 5:35 [PATCH] include/linux/kasan.h: Notice about 0 for kasan_[dis/en]able_current() chengang
2016-05-02 10:49 ` Alexander Potapenko
2016-05-02 11:20 ` Chen Gang
2016-05-02 11:23 ` Alexander Potapenko
2016-05-02 12:40 ` Chen Gang [this message]
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=57274ADA.8060606@emindsoft.com.cn \
--to=chengang@emindsoft.com.cn \
--cc=akpm@linux-foundation.org \
--cc=aryabinin@virtuozzo.com \
--cc=dvyukov@google.com \
--cc=gang.chen.5i5j@gmail.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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).