Thread (15 messages) 15 messages, 4 authors, 2024-03-04

Re: [PATCH v2 5/9] mm: Initialize struct vm_unmapped_area_info

From: Kees Cook <hidden>
Date: 2024-02-27 18:07:28
Also in: linux-alpha, linux-mips, linux-mm, linux-s390, linux-sh, linuxppc-dev, lkml, loongarch, sparclinux

On Tue, Feb 27, 2024 at 07:02:59AM +0000, Christophe Leroy wrote:

Le 26/02/2024 à 20:09, Rick Edgecombe a écrit :
quoted
Future changes will need to add a field to struct vm_unmapped_area_info.
This would cause trouble for any archs that don't initialize the
struct. Currently every user sets each field, so if new fields are
added, the core code parsing the struct will see garbage in the new
field.

It could be possible to initialize the new field for each arch to 0, but
instead simply inialize the field with a C99 struct inializing syntax.
Why doing a full init of the struct when all fields are re-written a few 
lines after ?
It's a nice change for robustness and makes future changes easier. It's
not actually wasteful since the compiler will throw away all redundant
stores.
If I take the exemple of powerpc function slice_find_area_bottomup():

	struct vm_unmapped_area_info info;

	info.flags = 0;
	info.length = len;
	info.align_mask = PAGE_MASK & ((1ul << pshift) - 1);
	info.align_offset = 0;
But one cleanup that is possible from explicitly zero-initializing the
whole structure would be dropping all the individual "= 0" assignments.
:)

-- 
Kees Cook

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help