Skip to content

Conversation

@cezarbbb
Copy link

@cezarbbb cezarbbb commented Sep 28, 2025

I've added some tests related to the stack protector. These tests were originally in the LLVM stack protector test project.
These tests were written for the "Stabilize stack-protector" proposal, and therefore removed the "stack-protector=basic" test option, as this stack protector was considered ineffective in Rust.
For the proposal, see: #146369
For the discussion, see zulip: https://rust-lang.zulipchat.com/#narrow/channel/233931-t-compiler.2Fmajor-changes/topic/Proposal.20for.20Adapt.20Stack.20Protector.20for.20Ru.E2.80.A6.20compiler-team.23841

r? @wesleywiser (feel free to reassign)
cc @nikic, @rcvalle, @davidtwco, @arielb1, @Darksonn, @Noratrieb, @SparrowLii

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 28, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 28, 2025

wesleywiser is currently at their maximum review capacity.
They may take a while to respond.

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 10, 2025
@rustbot

This comment has been minimized.

@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Oct 10, 2025
@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 10, 2025

⚠️ Warning ⚠️

@rustbot rustbot removed has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 10, 2025
@rcvalle rcvalle added the PG-exploit-mitigations Project group: Exploit mitigations label Oct 13, 2025
@SparrowLii SparrowLii self-assigned this Oct 25, 2025
@SparrowLii
Copy link
Member

I'm looking this and gonna give some comments, expecting in the next week

Copy link
Member

@SparrowLii SparrowLii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split the PR into multiple commits according to the logical organization of the test, which makes it easier for others to review.

And if your tests are coming from llvm tests, could you write something like a sheet to explain if these result in rustc are all expected?

View changes since this review

fn dummy(_: ...) -> i32;

static STR: [u8; 1];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some comments about why we need these extern functions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names of these functions have no special meaning; they simply correspond to the corresponding test functions in LLVM, because parameter passing checks are also an important part of checking whether stack protector is working properly (e.g., sspstrong).

Comment on lines 46 to 49
// #[repr(C)]
// struct A {
// data: [u8; 2],
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these code left here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edited. Because it became unnecessary due to unnecessary testing.

}

// Note: test2
// struct -> flat aggregate -> array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These codes too, please add some comments to explain why keep these codes

Copy link
Author

@cezarbbb cezarbbb Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The corresponding comments have been removed. The following explains why these tests are considered unnecessary.

test2/4: The struct structures in test2 and test4 will be "flat aggregated" into arrays, becoming identical to those in test1 and test3.

test17: There is no such type in rustc corresponding to '%struct.vec = type { <4 x i32> }' in LLVM.

test22: [2 x i8] in struct will be automatically optimized to i16 and will not trigger the sspstrong.

test23: [2 x i8] nested in several layers of structs and unions: same as test22.

test24: Variable sized alloca (VLA): see https://github.com/rust-lang/rfcs/pull/1909

test28/29/30/31: These tests were originally used to verify whether the 'basic' mode worked correctly. Since the community has decided to remove the 'basic' mode, these tests will also become useless.


// CHECK-LABEL: test3{{:|\[}}
#[no_mangle]
pub fn test3(a: *const u8) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make these test function names more meaningful? Or add some comments to explain

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each function has been commented accordingly.

@rust-log-analyzer

This comment has been minimized.

// test3: array [4 x i8]
// CHECK-LABEL: test3{{:|\[}}
#[no_mangle]
pub fn test3(a: *const u8) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we delete some unneccesary tests, I think these function names are no need to be consistent with ones in llvm's tests. You can just name test2 or test_array4_i8.

Same for all functiosn below

Copy link
Member

@SparrowLii SparrowLii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'd like to r+ this after fixing nits for test function names

View changes since this review

@cezarbbb
Copy link
Author

cezarbbb commented Nov 5, 2025

Edited.

@SparrowLii
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Nov 5, 2025

📌 Commit c49f4e1 has been approved by SparrowLii

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 5, 2025
bors added a commit that referenced this pull request Nov 5, 2025
More robust stack protector testing

I've added some tests related to the stack protector. These tests were originally in the LLVM stack protector test project.
These tests were written for the "Stabilize stack-protector" proposal, and therefore removed the "stack-protector=basic" test option, as this stack protector was considered ineffective in Rust.
For the proposal, see: #146369
For the discussion, see zulip: https://rust-lang.zulipchat.com/#narrow/channel/233931-t-compiler.2Fmajor-changes/topic/Proposal.20for.20Adapt.20Stack.20Protector.20for.20Ru.E2.80.A6.20compiler-team.23841

r? `@wesleywiser` (feel free to reassign)
cc `@nikic,` `@rcvalle,` `@davidtwco,` `@arielb1,` `@Darksonn,` `@Noratrieb,` `@SparrowLii`
@bors
Copy link
Collaborator

bors commented Nov 5, 2025

⌛ Testing commit c49f4e1 with merge 41d1d86...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Nov 5, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 5, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants