Re: [PATCH 01/12] mm, slab: ignore hardened usercopy parameters when disabled

From: Vlastimil Babka
Date: Thu Nov 24 2022 - 06:26:47 EST


On 11/24/22 12:16, Hyeonggon Yoo wrote:
>> /* Fail closed on bad usersize of useroffset values. */
>> - if (WARN_ON(!usersize && useroffset) ||
>> + if (!IS_ENABLED(CONFIG_HARDENED_USERCOPY) ||
>> + WARN_ON(!usersize && useroffset) ||
>> WARN_ON(size < usersize || size - usersize < useroffset))
>> usersize = useroffset = 0;
>
> I think this change is no longer needed as slab_unmergeable()
> now does not check usersize when CONFIG_HARDENED_USERCOPY=n?

True, but the code here still follows by

if (!usersize)
s = __kmem_cache_alias(name, size, align, flags, ctor);

So it seemed simplest just to leave it like that.