Thread (19 messages) flat view 19 messages, 4 authors, 1d ago

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

From: Harry Yoo <harry@kernel.org>
Date: 2026-09-24 18:23:01
Also in: linux-hardening, linux-mm, lkml

On Mon, Sep 21, 2026 at 04:25:25PM -0700, Kees Cook wrote:
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?

-- 
Cheers,
Harry / Hyeonggon
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help