Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e201f7dc authored by Kees Cook's avatar Kees Cook Committed by Lee Jones
Browse files

UPSTREAM: lib/test_stackinit: Fix static initializer test



The static initializer test got accidentally converted to a dynamic
initializer. Fix this and retain the giant padding hole without using
an aligned struct member.

Bug: 254441685
Fixes: 50ceaa95ea09 ("lib: Introduce test_stackinit module")
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210723221933.3431999-2-keescook@chromium.org


(cherry picked from commit f9398f15605a50110bf570aaa361163a85113dd1)
Signed-off-by: default avatarLee Jones <joneslee@google.com>
Change-Id: I4829d109eed03f2d16f1d544fe0f94296d3c8927
parent eab875b4
Loading
Loading
Loading
Loading
+7 −13
Original line number Diff line number Diff line
@@ -67,10 +67,10 @@ static bool range_contains(char *haystack_start, size_t haystack_size,
#define INIT_STRUCT_none		/**/
#define INIT_STRUCT_zero		= { }
#define INIT_STRUCT_static_partial	= { .two = 0, }
#define INIT_STRUCT_static_all		= { .one = arg->one,		\
					    .two = arg->two,		\
					    .three = arg->three,	\
					    .four = arg->four,		\
#define INIT_STRUCT_static_all		= { .one = 0,			\
					    .two = 0,			\
					    .three = 0,			\
					    .four = 0,			\
					}
#define INIT_STRUCT_dynamic_partial	= { .two = arg->two, }
#define INIT_STRUCT_dynamic_all		= { .one = arg->one,		\
@@ -84,8 +84,7 @@ static bool range_contains(char *haystack_start, size_t haystack_size,
					var.one = 0;			\
					var.two = 0;			\
					var.three = 0;			\
					memset(&var.four, 0,		\
					       sizeof(var.four))
					var.four = 0

/*
 * @name: unique string name for the test
@@ -210,18 +209,13 @@ struct test_small_hole {
	unsigned long four;
};

/* Try to trigger unhandled padding in a structure. */
struct test_aligned {
	u32 internal1;
	u64 internal2;
} __aligned(64);

/* Trigger unhandled padding in a structure. */
struct test_big_hole {
	u8 one;
	u8 two;
	u8 three;
	/* 61 byte padding hole here. */
	struct test_aligned four;
	u8 four __aligned(64);
} __aligned(64);

struct test_trailing_hole {