All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Murzin <vladimir.murzin@arm.com>
To: Wang Long <long.wanglong@huawei.com>,
	"ryabinin.a.a@gmail.com" <ryabinin.a.a@gmail.com>,
	"adech.fo@gmail.com" <adech.fo@gmail.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"rusty@rustcorp.com.au" <rusty@rustcorp.com.au>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"wanglong@laoqinren.net" <wanglong@laoqinren.net>,
	"peifeiyue@huawei.com" <peifeiyue@huawei.com>,
	"morgan.wang@huawei.com" <morgan.wang@huawei.com>
Subject: Re: [PATCH 2/2] kasan: Fix a type conversion error
Date: Wed, 09 Sep 2015 10:01:57 +0100	[thread overview]
Message-ID: <55EFF585.80603@arm.com> (raw)
In-Reply-To: <1441771180-206648-3-git-send-email-long.wanglong@huawei.com>

On 09/09/15 04:59, Wang Long wrote:
> The current KASAN code can find the following out-of-bounds

Should it be "cannot"?

Vladimir

> bugs:
> 	char *ptr;
> 	ptr = kmalloc(8, GFP_KERNEL);
> 	memset(ptr+7, 0, 2);
> 
> the cause of the problem is the type conversion error in
> *memory_is_poisoned_n* function. So this patch fix that.
> 
> Signed-off-by: Wang Long <long.wanglong@huawei.com>
> ---
>  mm/kasan/kasan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
> index 7b28e9c..5d65d06 100644
> --- a/mm/kasan/kasan.c
> +++ b/mm/kasan/kasan.c
> @@ -204,7 +204,7 @@ static __always_inline bool memory_is_poisoned_n(unsigned long addr,
>  		s8 *last_shadow = (s8 *)kasan_mem_to_shadow((void *)last_byte);
>  
>  		if (unlikely(ret != (unsigned long)last_shadow ||
> -			((last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
> +			((long)(last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
>  			return true;
>  	}
>  	return false;
> 

--
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: Vladimir Murzin <vladimir.murzin@arm.com>
To: Wang Long <long.wanglong@huawei.com>,
	"ryabinin.a.a@gmail.com" <ryabinin.a.a@gmail.com>,
	"adech.fo@gmail.com" <adech.fo@gmail.com>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"rusty@rustcorp.com.au" <rusty@rustcorp.com.au>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"wanglong@laoqinren.net" <wanglong@laoqinren.net>,
	"peifeiyue@huawei.com" <peifeiyue@huawei.com>,
	"morgan.wang@huawei.com" <morgan.wang@huawei.com>
Subject: Re: [PATCH 2/2] kasan: Fix a type conversion error
Date: Wed, 09 Sep 2015 10:01:57 +0100	[thread overview]
Message-ID: <55EFF585.80603@arm.com> (raw)
In-Reply-To: <1441771180-206648-3-git-send-email-long.wanglong@huawei.com>

On 09/09/15 04:59, Wang Long wrote:
> The current KASAN code can find the following out-of-bounds

Should it be "cannot"?

Vladimir

> bugs:
> 	char *ptr;
> 	ptr = kmalloc(8, GFP_KERNEL);
> 	memset(ptr+7, 0, 2);
> 
> the cause of the problem is the type conversion error in
> *memory_is_poisoned_n* function. So this patch fix that.
> 
> Signed-off-by: Wang Long <long.wanglong@huawei.com>
> ---
>  mm/kasan/kasan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
> index 7b28e9c..5d65d06 100644
> --- a/mm/kasan/kasan.c
> +++ b/mm/kasan/kasan.c
> @@ -204,7 +204,7 @@ static __always_inline bool memory_is_poisoned_n(unsigned long addr,
>  		s8 *last_shadow = (s8 *)kasan_mem_to_shadow((void *)last_byte);
>  
>  		if (unlikely(ret != (unsigned long)last_shadow ||
> -			((last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
> +			((long)(last_byte & KASAN_SHADOW_MASK) >= *last_shadow)))
>  			return true;
>  	}
>  	return false;
> 


  reply	other threads:[~2015-09-09  9:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-09  3:59 [PATCH 0/2] KASAN: fix a type conversion error and add test Wang Long
2015-09-09  3:59 ` Wang Long
2015-09-09  3:59 ` [PATCH 1/2] lib: test_kasan: add some testcases Wang Long
2015-09-09  3:59   ` Wang Long
2015-09-09 10:10   ` Andrey Ryabinin
2015-09-09 10:10     ` Andrey Ryabinin
2015-09-09  3:59 ` [PATCH 2/2] kasan: Fix a type conversion error Wang Long
2015-09-09  3:59   ` Wang Long
2015-09-09  9:01   ` Vladimir Murzin [this message]
2015-09-09  9:01     ` Vladimir Murzin
2015-09-09  9:25     ` long.wanglong
2015-09-09  9:25       ` long.wanglong
2015-09-09  9:40   ` Andrey Ryabinin
2015-09-09  9:40     ` Andrey Ryabinin
2015-09-09 10:22     ` long.wanglong
2015-09-09 10:22       ` long.wanglong
2015-09-09 10:48       ` Andrey Ryabinin
2015-09-09 11:04         ` [PATCH v2] " Wang Long
2015-09-09 11:04           ` Wang Long

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=55EFF585.80603@arm.com \
    --to=vladimir.murzin@arm.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=morgan.wang@huawei.com \
    --cc=peifeiyue@huawei.com \
    --cc=rusty@rustcorp.com.au \
    --cc=ryabinin.a.a@gmail.com \
    --cc=wanglong@laoqinren.net \
    /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.