mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-25 13:43:55 +08:00
compiler-based memory initialization update
- Update stack auto-initialization selftest for Clang initialization pattern -----BEGIN PGP SIGNATURE----- Comment: Kees Cook <kees@outflux.net> iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAl0IYMcWHGtlZXNjb29r QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJsgVD/wO3F1KkJ4UtTd81RMlsouBgK/q XsYhuQ6YcOvsh41te8SUmY1YS7/SdtmfIjtTlS42pLVcNT+XROVNRSCCnuETd/lW Zp6SjfMU3Dd2zn6oVQRAYtO40YAGWqOvFwp4lHNXLo9zObqXOe/JrmPrLpnmEFeX 7ZQ0yFGWq4No5CKs6M8G/gNKI1z7DOlXtV/jT/otjekqukJnpwDdjBqhkPZpOMuC RyHgp9fFvnOBqMgPwUlzwDZLP3zCw/5N01myJZibTFCcFlZGD4IpuBJojrXwm3t4 +0Qx/Uz52pOTyUKkg26iIDJkX9LqBHxFeuPBVOxWXDW0xoMFqroDa/jWom5uFenK wYllZ0ixmlrHNqn1WlQsPjs5Awomh4btJ60D8JK7URhGWt34uzqH651aJaBoa9i3 jwCpiog4k/4r6nTKCQ5L1FiZoAAbmt2liv2MkQMYTdUoqlg7/gbgA3FPaIPN+969 WhBY6NqGrDVHyorQdAGw/Hmajj96A+d0pXtZUDZnYUke6IT1iuzr75adyZVNUNav 0/Rq2wDIa801tA2upe8GwCeYihhUyWnCPbPo+h4YaPQnb9UA9ScWbrR0rihHy1eu htmLdDR7/p0p8w1o17dOwm7V9pY/qtxwlKm+VxKNLSfvuMHhVJyLePE9hrgeXXxr 0Rt//ZrZfPnUIu5tkw== =bBoU -----END PGP SIGNATURE----- Merge tag 'meminit-v5.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux Pull stack init fix from Kees Cook: "This is a small update to the stack auto-initialization self-test code to deal with the Clang initialization pattern. It's been in linux-next for a couple weeks; I had waited a bit wondering if anything more substantial was going to show up, but nothing has, so I'm sending this now before it gets too late" * tag 'meminit-v5.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: lib/test_stackinit: Handle Clang auto-initialization pattern
This commit is contained in:
commit
915ed9320c
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
/* Exfiltration buffer. */
|
/* Exfiltration buffer. */
|
||||||
#define MAX_VAR_SIZE 128
|
#define MAX_VAR_SIZE 128
|
||||||
static char check_buf[MAX_VAR_SIZE];
|
static u8 check_buf[MAX_VAR_SIZE];
|
||||||
|
|
||||||
/* Character array to trigger stack protector in all functions. */
|
/* Character array to trigger stack protector in all functions. */
|
||||||
#define VAR_BUFFER 32
|
#define VAR_BUFFER 32
|
||||||
@ -106,9 +106,18 @@ static noinline __init int test_ ## name (void) \
|
|||||||
\
|
\
|
||||||
/* Fill clone type with zero for per-field init. */ \
|
/* Fill clone type with zero for per-field init. */ \
|
||||||
memset(&zero, 0x00, sizeof(zero)); \
|
memset(&zero, 0x00, sizeof(zero)); \
|
||||||
|
/* Clear entire check buffer for 0xFF overlap test. */ \
|
||||||
|
memset(check_buf, 0x00, sizeof(check_buf)); \
|
||||||
/* Fill stack with 0xFF. */ \
|
/* Fill stack with 0xFF. */ \
|
||||||
ignored = leaf_ ##name((unsigned long)&ignored, 1, \
|
ignored = leaf_ ##name((unsigned long)&ignored, 1, \
|
||||||
FETCH_ARG_ ## which(zero)); \
|
FETCH_ARG_ ## which(zero)); \
|
||||||
|
/* Verify all bytes overwritten with 0xFF. */ \
|
||||||
|
for (sum = 0, i = 0; i < target_size; i++) \
|
||||||
|
sum += (check_buf[i] != 0xFF); \
|
||||||
|
if (sum) { \
|
||||||
|
pr_err(#name ": leaf fill was not 0xFF!?\n"); \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
/* Clear entire check buffer for later bit tests. */ \
|
/* Clear entire check buffer for later bit tests. */ \
|
||||||
memset(check_buf, 0x00, sizeof(check_buf)); \
|
memset(check_buf, 0x00, sizeof(check_buf)); \
|
||||||
/* Extract stack-defined variable contents. */ \
|
/* Extract stack-defined variable contents. */ \
|
||||||
@ -126,9 +135,9 @@ static noinline __init int test_ ## name (void) \
|
|||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
/* Look for any set bits in the check region. */ \
|
/* Look for any bytes still 0xFF in check region. */ \
|
||||||
for (i = 0; i < sizeof(check_buf); i++) \
|
for (sum = 0, i = 0; i < target_size; i++) \
|
||||||
sum += (check_buf[i] != 0); \
|
sum += (check_buf[i] == 0xFF); \
|
||||||
\
|
\
|
||||||
if (sum == 0) \
|
if (sum == 0) \
|
||||||
pr_info(#name " ok\n"); \
|
pr_info(#name " ok\n"); \
|
||||||
@ -162,13 +171,13 @@ static noinline __init int leaf_ ## name(unsigned long sp, \
|
|||||||
* Keep this buffer around to make sure we've got a \
|
* Keep this buffer around to make sure we've got a \
|
||||||
* stack frame of SOME kind... \
|
* stack frame of SOME kind... \
|
||||||
*/ \
|
*/ \
|
||||||
memset(buf, (char)(sp && 0xff), sizeof(buf)); \
|
memset(buf, (char)(sp & 0xff), sizeof(buf)); \
|
||||||
/* Fill variable with 0xFF. */ \
|
/* Fill variable with 0xFF. */ \
|
||||||
if (fill) { \
|
if (fill) { \
|
||||||
fill_start = &var; \
|
fill_start = &var; \
|
||||||
fill_size = sizeof(var); \
|
fill_size = sizeof(var); \
|
||||||
memset(fill_start, \
|
memset(fill_start, \
|
||||||
(char)((sp && 0xff) | forced_mask), \
|
(char)((sp & 0xff) | forced_mask), \
|
||||||
fill_size); \
|
fill_size); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
Loading…
Reference in New Issue
Block a user