Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__attribute__((no_stack_protector)) is overridden by inlining #52886

Closed
duk-37 opened this issue Dec 27, 2021 · 10 comments
Closed

__attribute__((no_stack_protector)) is overridden by inlining #52886

duk-37 opened this issue Dec 27, 2021 · 10 comments
Labels
bug Indicates an unexpected problem or unintended behavior llvm:core miscompilation

Comments

@duk-37
Copy link
Contributor

duk-37 commented Dec 27, 2021

Repro

Root cause seems to be that Attributes.cpp::adjustCallerSSPLevel does not have a way to check whether this attribute was added.

@duk-37 duk-37 added bug Indicates an unexpected problem or unintended behavior llvm:core miscompilation labels Dec 27, 2021
@duk-37
Copy link
Contributor Author

duk-37 commented Dec 30, 2021

Thanks, after checking the code, I think it might be a bug. Do you try to fix it? If not, I will fix it

Well I think a decent solution here would be to add a string attribute like no-jump-tables that just tells that function that changing stack protection levels on the caller is a no-no.

@dongAxis
Copy link
Contributor

after checking the review, https://reviews.llvm.org/D91816, always_inline might be a special case for ssp and no-ssp

@duk-37
Copy link
Contributor Author

duk-37 commented Dec 30, 2021

after checking the review, https://reviews.llvm.org/D91816, always_inline might be a special case for ssp and no-ssp

Hm, so this might be intended behavior?

@dongAxis
Copy link
Contributor

might be cc @nickdesaulniers

@nickdesaulniers
Copy link
Member

yes, that's the intention, though @zmodem also brought up that maybe we should change this for always_inline (further weakening the "always" part of "always inline").

@duk-37
Copy link
Contributor Author

duk-37 commented Dec 30, 2021

yes, that's the intention, though @zmodem also brought up that maybe we should change this for always_inline (further weakening the "always" part of "always inline").

I don't really know how I feel about this.. I'd rather have something marked always_inline be, well, inlined, without a stack protector; for example, if you have a set of performance-critical functions separated out to not duplicate code, or some thirdparty dependency that you expect to be inlined when using always_inline, behavior like this would very much subvert expectations. I don't know what the right answer is here, but either way the documentation for this should probably be very explicit.

@dongAxis
Copy link
Contributor

yes, that's the intention, though @zmodem also brought up that maybe we should change this for always_inline (further weakening the "always" part of "always inline").

I don't really know how I feel about this.. I'd rather have something marked always_inline be, well, inlined, without a stack protector; for example, if you have a set of performance-critical functions separated out to not duplicate code, or some thirdparty dependency that you expect to be inlined when using always_inline, behavior like this would very much subvert expectations. I don't know what the right answer is here, but either way the documentation for this should probably be very explicit.

I will try to update the document in clang and try to connect with @nickdesaulniers .

@zmodem
Copy link
Collaborator

zmodem commented Dec 31, 2021

(The discussion from Chromium is here: https://crbug.com/1274129)

My preference would be to not bring along the stack protector when inlining.

@zmodem
Copy link
Collaborator

zmodem commented Jan 4, 2022

Taking a stab at this here: https://reviews.llvm.org/D116589

@zmodem
Copy link
Collaborator

zmodem commented Jan 13, 2022

Taking a stab at this here: https://reviews.llvm.org/D116589

Committed as 2bc57d8.

@zmodem zmodem closed this as completed Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior llvm:core miscompilation
Projects
None yet
Development

No branches or pull requests

4 participants