diff options
author | Jens Axboe <axboe@kernel.dk> | 2019-07-01 10:16:08 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-07-01 10:16:08 -0400 |
commit | 5be1f9d82fa73c199ebeee2866dbac83e419c897 (patch) | |
tree | aed1aec34f40b5e0f36dceea8b58d9cfdb41d233 /lib/test_stackinit.c | |
parent | ff91064ea37c8323eba31cc3d2e22464f107b50d (diff) | |
parent | 4b972a01a7da614b4796475f933094751a295a2f (diff) |
Merge tag 'v5.2-rc6' into for-5.3/block
Merge 5.2-rc6 into for-5.3/block, so we get the same page merge leak
fix. Otherwise we end up having conflicts with future patches between
for-5.3/block and master that touch this area. In particular, it makes
the bio_full() fix hard to backport to stable.
* tag 'v5.2-rc6': (482 commits)
Linux 5.2-rc6
Revert "iommu/vt-d: Fix lock inversion between iommu->lock and device_domain_lock"
Bluetooth: Fix regression with minimum encryption key size alignment
tcp: refine memory limit test in tcp_fragment()
x86/vdso: Prevent segfaults due to hoisted vclock reads
SUNRPC: Fix a credential refcount leak
Revert "SUNRPC: Declare RPC timers as TIMER_DEFERRABLE"
net :sunrpc :clnt :Fix xps refcount imbalance on the error path
NFS4: Only set creation opendata if O_CREAT
ARM: 8867/1: vdso: pass --be8 to linker if necessary
KVM: nVMX: reorganize initial steps of vmx_set_nested_state
KVM: PPC: Book3S HV: Invalidate ERAT when flushing guest TLB entries
habanalabs: use u64_to_user_ptr() for reading user pointers
nfsd: replace Jeff by Chuck as nfsd co-maintainer
inet: clear num_timeout reqsk_alloc()
PCI/P2PDMA: Ignore root complex whitelist when an IOMMU is present
net: mvpp2: debugfs: Add pmap to fs dump
ipv6: Default fib6_type to RTN_UNICAST when not set
net: hns3: Fix inconsistent indenting
net/af_iucv: always register net_device notifier
...
Diffstat (limited to 'lib/test_stackinit.c')
-rw-r--r-- | lib/test_stackinit.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/test_stackinit.c b/lib/test_stackinit.c index e97dc54b4fdf..2d7d257a430e 100644 --- a/lib/test_stackinit.c +++ b/lib/test_stackinit.c | |||
@@ -12,7 +12,7 @@ | |||
12 | 12 | ||
13 | /* Exfiltration buffer. */ | 13 | /* Exfiltration buffer. */ |
14 | #define MAX_VAR_SIZE 128 | 14 | #define MAX_VAR_SIZE 128 |
15 | static char check_buf[MAX_VAR_SIZE]; | 15 | static u8 check_buf[MAX_VAR_SIZE]; |
16 | 16 | ||
17 | /* Character array to trigger stack protector in all functions. */ | 17 | /* Character array to trigger stack protector in all functions. */ |
18 | #define VAR_BUFFER 32 | 18 | #define VAR_BUFFER 32 |
@@ -106,9 +106,18 @@ static noinline __init int test_ ## name (void) \ | |||
106 | \ | 106 | \ |
107 | /* Fill clone type with zero for per-field init. */ \ | 107 | /* Fill clone type with zero for per-field init. */ \ |
108 | memset(&zero, 0x00, sizeof(zero)); \ | 108 | memset(&zero, 0x00, sizeof(zero)); \ |
109 | /* Clear entire check buffer for 0xFF overlap test. */ \ | ||
110 | memset(check_buf, 0x00, sizeof(check_buf)); \ | ||
109 | /* Fill stack with 0xFF. */ \ | 111 | /* Fill stack with 0xFF. */ \ |
110 | ignored = leaf_ ##name((unsigned long)&ignored, 1, \ | 112 | ignored = leaf_ ##name((unsigned long)&ignored, 1, \ |
111 | FETCH_ARG_ ## which(zero)); \ | 113 | FETCH_ARG_ ## which(zero)); \ |
114 | /* Verify all bytes overwritten with 0xFF. */ \ | ||
115 | for (sum = 0, i = 0; i < target_size; i++) \ | ||
116 | sum += (check_buf[i] != 0xFF); \ | ||
117 | if (sum) { \ | ||
118 | pr_err(#name ": leaf fill was not 0xFF!?\n"); \ | ||
119 | return 1; \ | ||
120 | } \ | ||
112 | /* Clear entire check buffer for later bit tests. */ \ | 121 | /* Clear entire check buffer for later bit tests. */ \ |
113 | memset(check_buf, 0x00, sizeof(check_buf)); \ | 122 | memset(check_buf, 0x00, sizeof(check_buf)); \ |
114 | /* Extract stack-defined variable contents. */ \ | 123 | /* Extract stack-defined variable contents. */ \ |
@@ -126,9 +135,9 @@ static noinline __init int test_ ## name (void) \ | |||
126 | return 1; \ | 135 | return 1; \ |
127 | } \ | 136 | } \ |
128 | \ | 137 | \ |
129 | /* Look for any set bits in the check region. */ \ | 138 | /* Look for any bytes still 0xFF in check region. */ \ |
130 | for (i = 0; i < sizeof(check_buf); i++) \ | 139 | for (sum = 0, i = 0; i < target_size; i++) \ |
131 | sum += (check_buf[i] != 0); \ | 140 | sum += (check_buf[i] == 0xFF); \ |
132 | \ | 141 | \ |
133 | if (sum == 0) \ | 142 | if (sum == 0) \ |
134 | pr_info(#name " ok\n"); \ | 143 | pr_info(#name " ok\n"); \ |
@@ -162,13 +171,13 @@ static noinline __init int leaf_ ## name(unsigned long sp, \ | |||
162 | * Keep this buffer around to make sure we've got a \ | 171 | * Keep this buffer around to make sure we've got a \ |
163 | * stack frame of SOME kind... \ | 172 | * stack frame of SOME kind... \ |
164 | */ \ | 173 | */ \ |
165 | memset(buf, (char)(sp && 0xff), sizeof(buf)); \ | 174 | memset(buf, (char)(sp & 0xff), sizeof(buf)); \ |
166 | /* Fill variable with 0xFF. */ \ | 175 | /* Fill variable with 0xFF. */ \ |
167 | if (fill) { \ | 176 | if (fill) { \ |
168 | fill_start = &var; \ | 177 | fill_start = &var; \ |
169 | fill_size = sizeof(var); \ | 178 | fill_size = sizeof(var); \ |
170 | memset(fill_start, \ | 179 | memset(fill_start, \ |
171 | (char)((sp && 0xff) | forced_mask), \ | 180 | (char)((sp & 0xff) | forced_mask), \ |
172 | fill_size); \ | 181 | fill_size); \ |
173 | } \ | 182 | } \ |
174 | \ | 183 | \ |