From: Ben Luo <luoben@linux.alibaba.com>
To: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com,
iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
vbabka@suse.cz, roman.gushchin@linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/slub: return 0 when object pointer is NULL
Date: Mon, 12 Sep 2022 15:29:30 +0800 [thread overview]
Message-ID: <133458f0-23c9-9421-abb8-a50d5551b524@linux.alibaba.com> (raw)
In-Reply-To: <Yx7dKxwxlNmCr9Ai@hyeyoo>
Hello Hyeonggon,
Thanks for replying :)
在 2022/9/12 15:18, Hyeonggon Yoo 写道:
> On Mon, Sep 12, 2022 at 01:59:39PM +0800, Ben Luo wrote:
>> NULL is definitly not a valid address
>>
>> Signed-off-by: Ben Luo <luoben@linux.alibaba.com>
>> ---
>> mm/slub.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 862dbd9..50fad18 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -674,7 +674,7 @@ static inline int check_valid_pointer(struct kmem_cache *s,
>> void *base;
>>
>> if (!object)
>> - return 1;
>> + return 0;
>>
>> base = slab_address(slab);
>> object = kasan_reset_tag(object);
>> --
>> 1.8.3.1
>>
> Hello Ben.
>
> The return value is used to check if the @object has valid pointer
> in @slab. (used for debugging) the return value is 0 if valid, 1 if invalid.
>
> It does not return a pointer. So changing it to 0 because 1 is invalid
> address does not make sense.
I know the meaning of this return value, but I think this function was
expected by returning 0 if invalid ,1 if valid
Check this original code:
if (object < base || object >= base + slab->objects * s->size ||
(object - base) % s->size) {
return 0;
}
Object not in range of [base, base+length) is an invalid slab address,
and it will return 0
--
Thanks,
Ben
>
next prev parent reply other threads:[~2022-09-12 7:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-12 5:59 Ben Luo
2022-09-12 7:18 ` Hyeonggon Yoo
2022-09-12 7:29 ` Ben Luo [this message]
2022-09-12 7:47 ` Hyeonggon Yoo
2022-09-14 2:11 ` [mm/slub] fb670abe87: BUG_kmem_cache_node(Not_tainted):Freechain_corrupt kernel test robot
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=133458f0-23c9-9421-abb8-a50d5551b524@linux.alibaba.com \
--to=luoben@linux.alibaba.com \
--cc=42.hyeyoo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=vbabka@suse.cz \
/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