Skip to content

Commit 6df27ef

Browse files
also update windows slack-protector tests
1 parent daaaacd commit 6df27ef

File tree

2 files changed

+16
-44
lines changed

2 files changed

+16
-44
lines changed

tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-32bit.rs

+8-22
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,9 @@ pub fn array_char(f: fn(*const char)) {
3737
f(&b as *const _);
3838
f(&c as *const _);
3939

40-
// Any type of local array variable leads to stack protection with the
41-
// "strong" heuristic. The 'basic' heuristic only adds stack protection to
42-
// functions with local array variables of a byte-sized type, however. Since
43-
// 'char' is 4 bytes in Rust, this function is not protected by the 'basic'
44-
// heuristic
45-
//
46-
// (This test *also* takes the address of the local stack variables. We
47-
// cannot know that this isn't what triggers the `strong` heuristic.
48-
// However, the test strategy of passing the address of a stack array to an
49-
// external function is sufficient to trigger the `basic` heuristic (see
50-
// test `array_u8_large()`). Since the `basic` heuristic only checks for the
51-
// presence of stack-local array variables, we can be confident that this
52-
// test also captures this part of the `strong` heuristic specification.)
53-
5440
// all: __security_check_cookie
5541
// strong: __security_check_cookie
56-
// basic-NOT: __security_check_cookie
42+
// basic: __security_check_cookie
5743
// none-NOT: __security_check_cookie
5844
// missing-NOT: __security_check_cookie
5945
}
@@ -231,8 +217,8 @@ pub fn local_large_var_moved(f: fn(Gigastruct)) {
231217
// Even though the local variable conceptually doesn't have its address
232218
// taken, it's so large that the "move" is implemented with a reference to a
233219
// stack-local variable in the ABI. Consequently, this function *is*
234-
// protected by the `strong` heuristic. This is also the case for
235-
// rvalue-references in C++, regardless of struct size:
220+
// protected. This is also the case for rvalue-references in C++,
221+
// regardless of struct size:
236222
// ```
237223
// cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk
238224
// #include <cstdint>
@@ -246,7 +232,7 @@ pub fn local_large_var_moved(f: fn(Gigastruct)) {
246232

247233
// all: __security_check_cookie
248234
// strong: __security_check_cookie
249-
// basic-NOT: __security_check_cookie
235+
// basic: __security_check_cookie
250236
// none-NOT: __security_check_cookie
251237
// missing-NOT: __security_check_cookie
252238
}
@@ -259,9 +245,9 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
259245
// A new instance of `Gigastruct` is passed to `f()`, without any apparent
260246
// connection to this stack frame. Still, since instances of `Gigastruct`
261247
// are sufficiently large, it is allocated in the caller stack frame and
262-
// passed as a pointer. As such, this function is *also* protected by the
263-
// `strong` heuristic, just like `local_large_var_moved`. This is also the
264-
// case for pass-by-value of sufficiently large structs in C++:
248+
// passed as a pointer. As such, this function is *also* protected, just
249+
// like `local_large_var_moved`. This is also the case for pass-by-value
250+
// of sufficiently large structs in C++:
265251
// ```
266252
// cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk
267253
// #include <cstdint>
@@ -276,7 +262,7 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
276262

277263
// all: __security_check_cookie
278264
// strong: __security_check_cookie
279-
// basic-NOT: __security_check_cookie
265+
// basic: __security_check_cookie
280266
// none-NOT: __security_check_cookie
281267
// missing-NOT: __security_check_cookie
282268
}

tests/assembly/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs

+8-22
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,9 @@ pub fn array_char(f: fn(*const char)) {
3737
f(&b as *const _);
3838
f(&c as *const _);
3939

40-
// Any type of local array variable leads to stack protection with the
41-
// "strong" heuristic. The 'basic' heuristic only adds stack protection to
42-
// functions with local array variables of a byte-sized type, however. Since
43-
// 'char' is 4 bytes in Rust, this function is not protected by the 'basic'
44-
// heuristic
45-
//
46-
// (This test *also* takes the address of the local stack variables. We
47-
// cannot know that this isn't what triggers the `strong` heuristic.
48-
// However, the test strategy of passing the address of a stack array to an
49-
// external function is sufficient to trigger the `basic` heuristic (see
50-
// test `array_u8_large()`). Since the `basic` heuristic only checks for the
51-
// presence of stack-local array variables, we can be confident that this
52-
// test also captures this part of the `strong` heuristic specification.)
53-
5440
// all: __security_check_cookie
5541
// strong: __security_check_cookie
56-
// basic-NOT: __security_check_cookie
42+
// basic: __security_check_cookie
5743
// none-NOT: __security_check_cookie
5844
// missing-NOT: __security_check_cookie
5945
}
@@ -239,8 +225,8 @@ pub fn local_large_var_moved(f: fn(Gigastruct)) {
239225
// Even though the local variable conceptually doesn't have its address
240226
// taken, it's so large that the "move" is implemented with a reference to a
241227
// stack-local variable in the ABI. Consequently, this function *is*
242-
// protected by the `strong` heuristic. This is also the case for
243-
// rvalue-references in C++, regardless of struct size:
228+
// protected. This is also the case for rvalue-references in C++,
229+
// regardless of struct size:
244230
// ```
245231
// cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk
246232
// #include <cstdint>
@@ -254,7 +240,7 @@ pub fn local_large_var_moved(f: fn(Gigastruct)) {
254240

255241
// all: __security_check_cookie
256242
// strong: __security_check_cookie
257-
// basic-NOT: __security_check_cookie
243+
// basic: __security_check_cookie
258244
// none-NOT: __security_check_cookie
259245
// missing-NOT: __security_check_cookie
260246
}
@@ -267,9 +253,9 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
267253
// A new instance of `Gigastruct` is passed to `f()`, without any apparent
268254
// connection to this stack frame. Still, since instances of `Gigastruct`
269255
// are sufficiently large, it is allocated in the caller stack frame and
270-
// passed as a pointer. As such, this function is *also* protected by the
271-
// `strong` heuristic, just like `local_large_var_moved`. This is also the
272-
// case for pass-by-value of sufficiently large structs in C++:
256+
// passed as a pointer. As such, this function is *also* protected, just
257+
// like `local_large_var_moved`. This is also the case for pass-by-value
258+
// of sufficiently large structs in C++:
273259
// ```
274260
// cat <<EOF | clang++ -O2 -fstack-protector-strong -S -x c++ - -o - | grep stack_chk
275261
// #include <cstdint>
@@ -284,7 +270,7 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
284270

285271
// all: __security_check_cookie
286272
// strong: __security_check_cookie
287-
// basic-NOT: __security_check_cookie
273+
// basic: __security_check_cookie
288274
// none-NOT: __security_check_cookie
289275
// missing-NOT: __security_check_cookie
290276
}

0 commit comments

Comments
 (0)