All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Xishi Qiu <qiuxishi@huawei.com>
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: Fri, 11 Sep 2015 15:47:30 -0700	[thread overview]
Message-ID: <20150911154730.3a2151a0b111fed01acdaaa1@linux-foundation.org> (raw)
In-Reply-To: <55F23635.1010109@huawei.com>

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.

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

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


WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Xishi Qiu <qiuxishi@huawei.com>
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: Fri, 11 Sep 2015 15:47:30 -0700	[thread overview]
Message-ID: <20150911154730.3a2151a0b111fed01acdaaa1@linux-foundation.org> (raw)
In-Reply-To: <55F23635.1010109@huawei.com>

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.

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

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

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

  reply	other threads:[~2015-09-11 22:47 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 [this message]
2015-09-11 22:47   ` Andrew Morton
2015-09-14  1:17   ` Xishi Qiu
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=20150911154730.3a2151a0b111fed01acdaaa1@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=adech.fo@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=long.wanglong@huawei.com \
    --cc=mmarek@suse.cz \
    --cc=qiuxishi@huawei.com \
    --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.