History

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

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.

Max Filippov committed 3 years ago

Commit 5b24ac21 parent 88603b61 file · +6 −1Browse files

Unified · Split

kernel/kcsan/kcsan_test.c+6−1
@@ -159,7 +159,7 @@ static bool __report_matches(const struct expect_report *r) · 158 unmodified lines
159 const bool is_assert = (r->access[0].type | r->access[1].type) & KCSAN_ACCESS_ASSERT;159 const bool is_assert = (r->access[0].type | r->access[1].type) & KCSAN_ACCESS_ASSERT;
160 bool ret = false;160 bool ret = false;
161 unsigned long flags;161 unsigned long flags;
162 typeof(observed.lines) expect;162 typeof(*observed.lines) *expect;
163 const char *end;163 const char *end;
164 char *cur;164 char *cur;
165 int i;165 int i;
@@ -168,6 +168,10 @@ static bool __report_matches(const struct expect_report *r) · 2 unmodified lines
168 if (!report_available())168 if (!report_available())
169 return false;169 return false;
170 170
171 expect = kmalloc(sizeof(observed.lines), GFP_KERNEL);
172 if (WARN_ON(!expect))
173 return false;
174
171 /* Generate expected report contents. */175 /* Generate expected report contents. */
172 176
173 /* Title */177 /* Title */
@@ -253,6 +257,7 @@ static bool __report_matches(const struct expect_report *r) · 79 unmodified lines
253 strstr(observed.lines[2], expect[1])));257 strstr(observed.lines[2], expect[1])));
254out:258out:
255 spin_unlock_irqrestore(&observed.lock, flags);259 spin_unlock_irqrestore(&observed.lock, flags);
260 kfree(expect);
256 return ret;261 return ret;
257}262}
258 263