Thread (20 messages) 20 messages, 5 authors, 12h ago

Re: [PATCH v4 2/7] mm/slab: Give bucket caches the alignment of the caches they mirror

From: Kees Cook <kees@kernel.org>
Date: 2026-09-25 01:00:45
Also in: linux-hardening, linux-mm, lkml

On Thu, Sep 24, 2026 at 07:22:58PM +0100, Harry Yoo wrote:
On Mon, Sep 21, 2026 at 04:25:25PM -0700, Kees Cook wrote:
quoted
On Mon, Sep 21, 2026 at 02:17:21PM +0100, Harry Yoo wrote:
quoted
On Mon, Sep 21, 2026 at 12:58:13AM -0700, Kees Cook wrote:
quoted
 			if (WARN_ON(!cache_name))
 				goto fail;
 			(*b)[aligned_idx] = kmem_cache_create_usercopy(cache_name, size,
-					0, flags, cache_useroffset,
+					kmalloc_caches[KMALLOC_NORMAL][idx]->align,
+					flags, cache_useroffset,
 					cache_usersize, ctor);
 			kfree(cache_name);
 			if (WARN_ON(!(*b)[aligned_idx]))
It looks "obviously correct", but I probably failed to correctly
describe it. I'm happy to do whatever here.
That is correct, but is there any reason why kmem_buckets users should
not specify their own alignment requirement and inherit the alignment
from kmalloc?

For DMA yeah it might be confusing for every user to figure out that
the alignment should be __kmalloc_minalign(), but otherwise there isn't
really a good enough reason to inherit the alignment from kmalloc, no?
Oh, so you mean explicitly add an alignment arg to kmem_buckets_create()?
And perhaps if _that_ one is "0" we can fallback to whatever
kmalloc_caches uses?

-- 
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help