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] [day] [month] [year] [list]
Message-Id: <DBCREQ7KNW50.1CB6ZO5GZHDW9@kernel.org>
Date: Tue, 15 Jul 2025 18:12:16 +0200
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Vlastimil Babka" <vbabka@...e.cz>
Cc: "Vitaly Wool" <vitaly.wool@...sulko.se>, "Linus Torvalds"
 <torvalds@...ux-foundation.org>, <linux-mm@...ck.org>,
 <akpm@...ux-foundation.org>, <linux-kernel@...r.kernel.org>, "Uladzislau
 Rezki" <urezki@...il.com>, "Alice Ryhl" <aliceryhl@...gle.com>,
 <rust-for-linux@...r.kernel.org>, "Lorenzo Stoakes"
 <lorenzo.stoakes@...cle.com>, "Liam R . Howlett" <Liam.Howlett@...cle.com>,
 <linux-bcachefs@...r.kernel.org>, <bpf@...r.kernel.org>, "Herbert Xu"
 <herbert@...dor.apana.org.au>, "Jann Horn" <jannh@...gle.com>, "Pedro
 Falcato" <pfalcato@...e.de>, "Kent Overstreet" <kent.overstreet@...ux.dev>
Subject: Re: [PATCH v13 2/4] mm/slub: allow to set node and align in
 k[v]realloc

On Tue Jul 15, 2025 at 5:48 PM CEST, Danilo Krummrich wrote:
> On Tue Jul 15, 2025 at 5:34 PM CEST, Vlastimil Babka wrote:
>> On 7/15/25 16:33, Danilo Krummrich wrote:
>>> On Tue Jul 15, 2025 at 3:58 PM CEST, Vitaly Wool wrote:
>>>> diff --git a/fs/bcachefs/darray.c b/fs/bcachefs/darray.c
>>>> index e86d36d23e9e..928e83a1ce42 100644
>>>> --- a/fs/bcachefs/darray.c
>>>> +++ b/fs/bcachefs/darray.c
>>>> @@ -21,7 +21,7 @@ int __bch2_darray_resize_noprof(darray_char *d, size_t element_size, size_t new_
>>>>  			return -ENOMEM;
>>>>  
>>>>  		void *data = likely(bytes < INT_MAX)
>>>> -			? kvmalloc_noprof(bytes, gfp)
>>>> +			? kvmalloc_node_align_noprof(bytes, 1, gfp, NUMA_NO_NODE)
>>>>  			: vmalloc_noprof(bytes);
>>>>  		if (!data)
>>>>  			return -ENOMEM;
>>>> diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
>>>> index 0a4b1d433621..2d6d4b547db8 100644
>>>> --- a/fs/bcachefs/util.h
>>>> +++ b/fs/bcachefs/util.h
>>>> @@ -61,7 +61,7 @@ static inline void *bch2_kvmalloc_noprof(size_t n, gfp_t flags)
>>>>  {
>>>>  	void *p = unlikely(n >= INT_MAX)
>>>>  		? vmalloc_noprof(n)
>>>> -		: kvmalloc_noprof(n, flags & ~__GFP_ZERO);
>>>> +		: kvmalloc_node_align_noprof(n, 1, flags & ~__GFP_ZERO, NUMA_NO_NODE);
>>>>  	if (p && (flags & __GFP_ZERO))
>>>>  		memset(p, 0, n);
>>>>  	return p;
>>> 
>>> I assume this is because kvmalloc(), and hence kvrealloc(), does this:
>>> 
>>> 	/* Don't even allow crazy sizes */
>>> 	if (unlikely(size > INT_MAX)) {
>>> 		WARN_ON_ONCE(!(flags & __GFP_NOWARN));
>>> 		return NULL;
>>> 	}
>>> 
>>> Do we still consider this a "crazy size"? :)
>>
>> Yeah, with "we" including Linus:
>> https://lore.kernel.org/all/CAHk-=wi=PrbZnwnvhKEF6UUQNCZdNsUbr+hk-jOWGr-q4Mmz=Q@mail.gmail.com/
>
> I don't know why bcachefs needs this, hence my question. But I agree that this
> clearly raises an eyebrow. :)

I.e. this is me noting that we're considering anything larger to be unreasonable
while having an in-tree user bypassing this check intentionally.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ