From: Vlastimil Babka <vbabka@suse.cz>
To: Feng Tang <feng.tang@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Roman Gushchin <roman.gushchin@linux.dev>,
Hyeonggon Yoo <42.hyeyoo@gmail.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Marco Elver <elver@google.com>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Danilo Krummrich <dakr@kernel.org>,
Narasimhan.V@amd.com
Cc: linux-mm@kvack.org, kasan-dev@googlegroups.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 0/3] mm/slub: Improve data handling of krealloc() when orig_size is enabled
Date: Fri, 18 Oct 2024 11:51:49 +0200 [thread overview]
Message-ID: <c4a55668-dfdf-42f3-89b7-eb9c5ded4c81@suse.cz> (raw)
In-Reply-To: <20241016154152.1376492-1-feng.tang@intel.com>
On 10/16/24 17:41, Feng Tang wrote:
> Danilo Krummrich's patch [1] raised one problem about krealloc() that
> its caller doesn't pass the old request size, say the object is 64
> bytes kmalloc one, but caller originally only requested 48 bytes. Then
> when krealloc() shrinks or grows in the same object, or allocate a new
> bigger object, it lacks this 'original size' information to do accurate
> data preserving or zeroing (when __GFP_ZERO is set).
>
> Thus with slub debug redzone and object tracking enabled, parts of the
> object after krealloc() might contain redzone data instead of zeroes,
> which is violating the __GFP_ZERO guarantees. Good thing is in this
> case, kmalloc caches do have this 'orig_size' feature, which could be
> used to improve the situation here.
>
> To make the 'orig_size' accurate, we adjust some kasan/slub meta data
> handling. Also add a slub kunit test case for krealloc().
>
> Many thanks to syzbot and V, Narasimhan for detecting issues of the
> v2 patches.
>
> This is again linux-slab tree's 'for-6.13/fixes' branch
Thanks, added there.
Vlastimil
> [1]. https://lore.kernel.org/lkml/20240812223707.32049-1-dakr@kernel.org/
>
> Thanks,
> Feng
>
> Changelog:
>
> Since v2:
> * Fix NULL pointer issue related to big kmalloc object which has
> no associated slab (V, Narasimhan, syzbot)
> * Fix issue related handling for kfence allocated object (syzbot,
> Marco Elver)
> * drop the 0001 and 0003 patch whch have been merged to slab tree
>
> Since v1:
> * Drop the patch changing generic kunit code from this patchset,
> and will send it separately.
> * Separate the krealloc moving form slab_common.c to slub.c to a
> new patch for better review (Danilo/Vlastimil)
> * Improve commit log and comments (Vlastimil/Danilo)
> * Rework the kunit test case to remove its dependency over
> slub_debug (which is incomplete in v1) (Vlastimil)
> * Add ack and review tag from developers.
>
>
>
> Feng Tang (3):
> mm/slub: Consider kfence case for get_orig_size()
> mm/slub: Improve redzone check and zeroing for krealloc()
> mm/slub, kunit: Add testcase for krealloc redzone and zeroing
>
> lib/slub_kunit.c | 42 +++++++++++++++++++++++
> mm/slub.c | 87 +++++++++++++++++++++++++++++++++++-------------
> 2 files changed, 105 insertions(+), 24 deletions(-)
>
prev parent reply other threads:[~2024-10-18 9:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 15:41 Feng Tang
2024-10-16 15:41 ` [PATCH v3 1/3] mm/slub: Consider kfence case for get_orig_size() Feng Tang
2024-11-14 13:38 ` Hyeonggon Yoo
2024-10-16 15:41 ` [PATCH v3 2/3] mm/slub: Improve redzone check and zeroing for krealloc() Feng Tang
2024-11-14 13:34 ` Hyeonggon Yoo
2024-11-15 13:29 ` Vlastimil Babka
2024-10-16 15:41 ` [PATCH v3 3/3] mm/slub, kunit: Add testcase for krealloc redzone and zeroing Feng Tang
2024-10-18 9:51 ` Vlastimil Babka [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=c4a55668-dfdf-42f3-89b7-eb9c5ded4c81@suse.cz \
--to=vbabka@suse.cz \
--cc=42.hyeyoo@gmail.com \
--cc=Narasimhan.V@amd.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=cl@linux.com \
--cc=dakr@kernel.org \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=feng.tang@intel.com \
--cc=glider@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=kasan-dev@googlegroups.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 \
/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