[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6e61f06f-2411-0bcb-926b-0a6927096f20@gmail.com>
Date: Wed, 14 Jun 2023 13:30:54 -0300
From: Martin Rodriguez Reboredo <yakoyoku@...il.com>
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>,
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>,
Vlastimil Babka <vbabka@...e.cz>,
Roman Gushchin <roman.gushchin@...ux.dev>,
Hyeonggon Yoo <42.hyeyoo@...il.com>,
Kees Cook <keescook@...omium.org>,
Andreas Hindborg <nmi@...aspace.dk>, stable@...r.kernel.org
Subject: Re: [PATCH] rust: allocator: Prevents mis-aligned allocation
On 6/13/23 13:42, Boqun Feng wrote:
> Currently the KernelAllocator 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.
>
> Fixes 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 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+
> ---
> [...]
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@...il.com>
Powered by blists - more mailing lists