提交 1f051704 编写于 作者: M Max Filippov 提交者: sanglipeng

kcsan: test: don't put the expect array on the stack

stable inclusion
from stable-v5.10.166
commit 3b154d5204ff8aa82a2bd4d5ed29a7cf80723706
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7TH9O

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

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

[ Upstream commit 5b24ac2d ]

Size of the 'expect' array in the __report_matches is 1536 bytes, which
is exactly the default frame size warning limit of the xtensa
architecture.
As a result allmodconfig xtensa kernel builds with the gcc that does not
support the compiler plugins (which otherwise would push the said
warning limit to 2K) fail with the following message:

  kernel/kcsan/kcsan_test.c:257:1: error: the frame size of 1680 bytes
    is larger than 1536 bytes

Fix it by dynamically allocating the 'expect' array.
Signed-off-by: NMax Filippov <jcmvbkbc@gmail.com>
Reviewed-by: NMarco Elver <elver@google.com>
Tested-by: NMarco Elver <elver@google.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nsanglipeng <sanglipeng1@jd.com>
上级 ee1edd9f
...@@ -149,7 +149,7 @@ static bool report_matches(const struct expect_report *r) ...@@ -149,7 +149,7 @@ static bool report_matches(const struct expect_report *r)
const bool is_assert = (r->access[0].type | r->access[1].type) & KCSAN_ACCESS_ASSERT; const bool is_assert = (r->access[0].type | r->access[1].type) & KCSAN_ACCESS_ASSERT;
bool ret = false; bool ret = false;
unsigned long flags; unsigned long flags;
typeof(observed.lines) expect; typeof(*observed.lines) *expect;
const char *end; const char *end;
char *cur; char *cur;
int i; int i;
...@@ -158,6 +158,10 @@ static bool report_matches(const struct expect_report *r) ...@@ -158,6 +158,10 @@ static bool report_matches(const struct expect_report *r)
if (!report_available()) if (!report_available())
return false; return false;
expect = kmalloc(sizeof(observed.lines), GFP_KERNEL);
if (WARN_ON(!expect))
return false;
/* Generate expected report contents. */ /* Generate expected report contents. */
/* Title */ /* Title */
...@@ -241,6 +245,7 @@ static bool report_matches(const struct expect_report *r) ...@@ -241,6 +245,7 @@ static bool report_matches(const struct expect_report *r)
strstr(observed.lines[2], expect[1]))); strstr(observed.lines[2], expect[1])));
out: out:
spin_unlock_irqrestore(&observed.lock, flags); spin_unlock_irqrestore(&observed.lock, flags);
kfree(expect);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册