Re: Avoiding stack buffer clear being optimised out

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 1 Dec 2022 at 11:31, Jonathan Wakely wrote:
>
> On Thu, 1 Dec 2022 at 10:44, Jonny Grant wrote:
> > Thank you Jonathan and David for your replies.
> >
> > That "noipa" looks to have sorted this issue
> >
> > https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
> >
> > That page also suggests "noinline" attribute which seems to suggest I'd need to add asm (""); in each wrapper of memset()
>
> I already used the noinline attribute in my example above.
>
> > I'd much rather have memset_s - Jonathan, do you think GCC could add some built-in functions for memset_s ?     __builtin_memset_s() would be great.
>
> No.
>
> But C2x adds a memset_explicit function that does what you want, so
> that should arrive in glibc soonish.
> I thought it had been added, but was searching the C2x draft for
> "memset_secure" and other incorrect names.
>
> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2631.htm was the
> proposal adding it.

Ah, and that proposal links to an example implementation which uses
glibc's explicit_bzero which already exists (since glibc 2.25, and
also in some BSDs) and does what you want.
https://github.com/ojeda/secure_clear/blob/master/example-implementation/secure_clear.h



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux