lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8bd3c3e8-9865-4467-86d5-17d891f6f21b@suse.cz>
Date: Tue, 20 Jan 2026 13:55:09 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Hao Li <hao.li@...ux.dev>
Cc: Harry Yoo <harry.yoo@...cle.com>, Eric Dumazet <edumazet@...gle.com>,
 Christoph Lameter <cl@...two.org>, David Rientjes <rientjes@...gle.com>,
 Roman Gushchin <roman.gushchin@...ux.dev>, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] slab: replace cache_from_obj() with inline checks

On 1/20/26 12:57, Hao Li wrote:

>> @@ -6774,11 +6770,21 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
>>   */
>>  void kmem_cache_free(struct kmem_cache *s, void *x)
>>  {
>> -	s = cache_from_obj(s, x);
>> -	if (!s)
>> -		return;
>> +	struct slab *slab;
>> +
>> +	slab = virt_to_slab(x);
>> +
>> +	if (IS_ENABLED(CONFIG_SLAB_FREELIST_HARDENED) ||
>> +	    kmem_cache_debug_flags(s, SLAB_CONSISTENCY_CHECKS)) {
>> +
>> +		if (unlikely(!slab || (slab->slab_cache != s))) {
>> +			warn_free_bad_obj(s, x);
> 
> Just to make sure I'm understanding correctly, are we intentionally not
> releasing the object x in this case? Thanks.

Yes, it means something went wrong so it's better not to do anything. That
was true before this patch as well.

>> +			return;
>> +		}
>> +	}
>> +
>>  	trace_kmem_cache_free(_RET_IP_, x, s);
>> -	slab_free(s, virt_to_slab(x), x, _RET_IP_);
>> +	slab_free(s, slab, x, _RET_IP_);
>>  }
>>  EXPORT_SYMBOL(kmem_cache_free);
>>  
>> @@ -7305,7 +7311,7 @@ int build_detached_freelist(struct kmem_cache *s, size_t size,
>>  		df->s = slab->slab_cache;
>>  	} else {
>>  		df->slab = slab;
>> -		df->s = cache_from_obj(s, object); /* Support for memcg */
>> +		df->s = s;
>>  	}
>>  
>>  	/* Start new detached freelist */
>> 
>> ---
>> base-commit: 0f61b1860cc3f52aef9036d7235ed1f017632193
>> change-id: 20260120-b4-remove_cache_from_obj-190fcaf16789
>> 
>> Best regards,
>> -- 
>> Vlastimil Babka <vbabka@...e.cz>
>> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ