All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xishi Qiu <qiuxishi@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Konovalov <adech.fo@gmail.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Michal Marek <mmarek@suse.cz>,
	"long.wanglong" <long.wanglong@huawei.com>,
	Linux MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>
Subject: Re: [PATCH] kasan: use IS_ALIGNED in memory_is_poisoned_8()
Date: Mon, 14 Sep 2015 09:17:43 +0800	[thread overview]
Message-ID: <55F62037.30506@huawei.com> (raw)
In-Reply-To: <20150911154730.3a2151a0b111fed01acdaaa1@linux-foundation.org>

On 2015/9/12 6:47, Andrew Morton wrote:

> On Fri, 11 Sep 2015 10:02:29 +0800 Xishi Qiu <qiuxishi@huawei.com> wrote:
> 
>> Use IS_ALIGNED() to determine whether the shadow span two bytes.
>> It generates less code and more readable.
>>
> 
> Please cc Andrey Ryabinin on kasan patches.

Sorry, my mistake.

> 
>> --- a/mm/kasan/kasan.c
>> +++ b/mm/kasan/kasan.c
>> @@ -120,7 +120,7 @@ static __always_inline bool memory_is_poisoned_8(unsigned long addr)
>>  		if (memory_is_poisoned_1(addr + 7))
>>  			return true;
>>  
>> -		if (likely(((addr + 7) & KASAN_SHADOW_MASK) >= 7))
>> +		if (likely(IS_ALIGNED(addr, 8)))
>>  			return false;
> 
> Wouldn't IS_ALIGNED(addr, KASAN_SHADOW_SCALE_SIZE) be more appropriate?
> 

OK, I'll send V2.

> But I'm not really sure what the original code is trying to do.
> 
> 	if ((addr + 7) & 7) >= 7)
> 
> can only evaluate true if ((addr + 7) & 7) equals 7, so the ">=" could
> be "==".
> 

I think it should be "==", the value will not "> 7"

> I think.  The code looks a bit weird.  A code comment would help.
> 
> And how come memory_is_poisoned_16() does IS_ALIGNED(addr, 8)?  Should
> it be 16?

No, it is to determine whether the shadow span two bytes(8 bytes, not 16).

Thanks,
Xishi Qiu

> 
> 
> .
> 



--
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>

WARNING: multiple messages have this Message-ID (diff)
From: Xishi Qiu <qiuxishi@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Konovalov <adech.fo@gmail.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	Michal Marek <mmarek@suse.cz>,
	"long.wanglong" <long.wanglong@huawei.com>,
	Linux MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>
Subject: Re: [PATCH] kasan: use IS_ALIGNED in memory_is_poisoned_8()
Date: Mon, 14 Sep 2015 09:17:43 +0800	[thread overview]
Message-ID: <55F62037.30506@huawei.com> (raw)
In-Reply-To: <20150911154730.3a2151a0b111fed01acdaaa1@linux-foundation.org>

On 2015/9/12 6:47, Andrew Morton wrote:

> On Fri, 11 Sep 2015 10:02:29 +0800 Xishi Qiu <qiuxishi@huawei.com> wrote:
> 
>> Use IS_ALIGNED() to determine whether the shadow span two bytes.
>> It generates less code and more readable.
>>
> 
> Please cc Andrey Ryabinin on kasan patches.

Sorry, my mistake.

> 
>> --- a/mm/kasan/kasan.c
>> +++ b/mm/kasan/kasan.c
>> @@ -120,7 +120,7 @@ static __always_inline bool memory_is_poisoned_8(unsigned long addr)
>>  		if (memory_is_poisoned_1(addr + 7))
>>  			return true;
>>  
>> -		if (likely(((addr + 7) & KASAN_SHADOW_MASK) >= 7))
>> +		if (likely(IS_ALIGNED(addr, 8)))
>>  			return false;
> 
> Wouldn't IS_ALIGNED(addr, KASAN_SHADOW_SCALE_SIZE) be more appropriate?
> 

OK, I'll send V2.

> But I'm not really sure what the original code is trying to do.
> 
> 	if ((addr + 7) & 7) >= 7)
> 
> can only evaluate true if ((addr + 7) & 7) equals 7, so the ">=" could
> be "==".
> 

I think it should be "==", the value will not "> 7"

> I think.  The code looks a bit weird.  A code comment would help.
> 
> And how come memory_is_poisoned_16() does IS_ALIGNED(addr, 8)?  Should
> it be 16?

No, it is to determine whether the shadow span two bytes(8 bytes, not 16).

Thanks,
Xishi Qiu

> 
> 
> .
> 




  reply	other threads:[~2015-09-14  1:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11  2:02 [PATCH] kasan: use IS_ALIGNED in memory_is_poisoned_8() Xishi Qiu
2015-09-11  2:02 ` Xishi Qiu
2015-09-11 22:47 ` Andrew Morton
2015-09-11 22:47   ` Andrew Morton
2015-09-14  1:17   ` Xishi Qiu [this message]
2015-09-14  1:17     ` Xishi Qiu
2015-09-14 13:19   ` Andrey Ryabinin
2015-09-14 13:19     ` Andrey Ryabinin

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=55F62037.30506@huawei.com \
    --to=qiuxishi@huawei.com \
    --cc=adech.fo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=long.wanglong@huawei.com \
    --cc=mmarek@suse.cz \
    --cc=rusty@rustcorp.com.au \
    --cc=ryabinin.a.a@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.