From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Jonny Grant <jg@jguk.org>
Cc: gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: Avoiding stack buffer clear being optimised out
Date: Thu, 1 Dec 2022 11:34:03 +0000 [thread overview]
Message-ID: <CAH6eHdTq=BQGkAY=1w0QvXghkVmE-SRYEfip9vMqn-dO6twYZA@mail.gmail.com> (raw)
In-Reply-To: <CAH6eHdTE_GGFt+iOuONXNJRp5s9MoNymC-FXxpnoSbVMe+1n4g@mail.gmail.com>
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
next prev parent reply other threads:[~2022-12-01 11:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-30 16:26 Jonny Grant
2022-11-30 17:40 ` Jonathan Wakely
2022-11-30 17:41 ` Jonathan Wakely
2022-12-01 10:44 ` Jonny Grant
2022-12-01 11:31 ` Jonathan Wakely
2022-12-01 11:34 ` Jonathan Wakely [this message]
2022-12-01 11:55 ` Jonny Grant
2022-12-13 20:12 ` Jonny Grant
2022-12-13 20:31 ` Jonathan Wakely
2022-12-13 22:07 ` Jonny Grant
2022-12-13 23:13 ` Jonathan Wakely
2022-12-13 23:16 ` Jonny Grant
2023-01-24 13:52 ` Jonny Grant
2023-01-24 14:26 ` Jonathan Wakely
2022-11-30 18:47 ` David Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH6eHdTq=BQGkAY=1w0QvXghkVmE-SRYEfip9vMqn-dO6twYZA@mail.gmail.com' \
--to=jwakely.gcc@gmail.com \
--cc=gcc-help@gcc.gnu.org \
--cc=jg@jguk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).