提交 d56c6615 编写于 作者: K Kees Cook 提交者: Zheng Zengkai

lib/test_stackinit: Fix static initializer test

stable inclusion
from stable-5.10.67
commit 5944d0e2b0ab7f85cc32f216dd534aa91630ba04
bugzilla: 182619 https://gitee.com/openeuler/kernel/issues/I4EWO7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=5944d0e2b0ab7f85cc32f216dd534aa91630ba04

--------------------------------

commit f9398f15 upstream.

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.

Fixes: 50ceaa95 ("lib: Introduce test_stackinit module")
Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: NKees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210723221933.3431999-2-keescook@chromium.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 ec09230c
...@@ -67,10 +67,10 @@ static bool range_contains(char *haystack_start, size_t haystack_size, ...@@ -67,10 +67,10 @@ static bool range_contains(char *haystack_start, size_t haystack_size,
#define INIT_STRUCT_none /**/ #define INIT_STRUCT_none /**/
#define INIT_STRUCT_zero = { } #define INIT_STRUCT_zero = { }
#define INIT_STRUCT_static_partial = { .two = 0, } #define INIT_STRUCT_static_partial = { .two = 0, }
#define INIT_STRUCT_static_all = { .one = arg->one, \ #define INIT_STRUCT_static_all = { .one = 0, \
.two = arg->two, \ .two = 0, \
.three = arg->three, \ .three = 0, \
.four = arg->four, \ .four = 0, \
} }
#define INIT_STRUCT_dynamic_partial = { .two = arg->two, } #define INIT_STRUCT_dynamic_partial = { .two = arg->two, }
#define INIT_STRUCT_dynamic_all = { .one = arg->one, \ #define INIT_STRUCT_dynamic_all = { .one = arg->one, \
...@@ -84,8 +84,7 @@ static bool range_contains(char *haystack_start, size_t haystack_size, ...@@ -84,8 +84,7 @@ static bool range_contains(char *haystack_start, size_t haystack_size,
var.one = 0; \ var.one = 0; \
var.two = 0; \ var.two = 0; \
var.three = 0; \ var.three = 0; \
memset(&var.four, 0, \ var.four = 0
sizeof(var.four))
/* /*
* @name: unique string name for the test * @name: unique string name for the test
...@@ -210,18 +209,13 @@ struct test_small_hole { ...@@ -210,18 +209,13 @@ struct test_small_hole {
unsigned long four; unsigned long four;
}; };
/* Try to trigger unhandled padding in a structure. */ /* Trigger unhandled padding in a structure. */
struct test_aligned {
u32 internal1;
u64 internal2;
} __aligned(64);
struct test_big_hole { struct test_big_hole {
u8 one; u8 one;
u8 two; u8 two;
u8 three; u8 three;
/* 61 byte padding hole here. */ /* 61 byte padding hole here. */
struct test_aligned four; u8 four __aligned(64);
} __aligned(64); } __aligned(64);
struct test_trailing_hole { struct test_trailing_hole {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册