[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e4f7ae0c-5397-4b20-80e8-6c0baece3e8c@suse.cz>
Date: Mon, 31 Jul 2023 09:56:20 +0200
From: Vlastimil Babka <vbabka@...e.cz>
To: Boqun Feng <boqun.feng@...il.com>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Cc: Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Martin Rodriguez Reboredo <yakoyoku@...il.com>,
Alice Ryhl <aliceryhl@...gle.com>,
Dariusz Sosnowski <dsosnowski@...snowski.pl>,
Geoffrey Thomas <geofft@...reload.com>,
Fox Chen <foxhlchen@...il.com>,
John Baublitz <john.m.baublitz@...il.com>,
Christoph Lameter <cl@...ux.com>,
Pekka Enberg <penberg@...nel.org>,
David Rientjes <rientjes@...gle.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Hyeonggon Yoo <42.hyeyoo@...il.com>,
Kees Cook <keescook@...omium.org>, stable@...r.kernel.org,
Andreas Hindborg <nmi@...aspace.dk>
Subject: Re: [PATCH 1/3] rust: allocator: Prevent mis-aligned allocation
On 7/30/23 03:29, Boqun Feng wrote:
> Currently the rust allocator simply passes the size of the type Layout
> to krealloc(), and in theory the alignment requirement from the type
> Layout may be larger than the guarantee provided by SLAB, which means
> the allocated object is mis-aligned.
>
> Fix this by adjusting the allocation size to the nearest power of two,
> which SLAB always guarantees a size-aligned allocation. And because Rust
> guarantees that the original size must be a multiple of alignment and
> the alignment must be a power of two, then the alignment requirement is
> satisfied.
>
> Suggested-by: Vlastimil Babka <vbabka@...e.cz>
> Co-developed-by: Andreas Hindborg (Samsung) <nmi@...aspace.dk>
> Signed-off-by: Andreas Hindborg (Samsung) <nmi@...aspace.dk>
> Signed-off-by: Boqun Feng <boqun.feng@...il.com>
> Cc: stable@...r.kernel.org # v6.1+
Acked-by: Vlastimil Babka <vbabka@...e.cz>
Powered by blists - more mailing lists