Gentoo Archives: gentoo-user

From: R0b0t1 <r030t1@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] memset_s
Date: Wed, 15 Nov 2017 04:42:58
Message-Id: CAAD4mYhWmDwrosnDjhb_6zNNKyqoLvf2CpVat47U9FQ2sma3ZA@mail.gmail.com
In Reply to: Re: [gentoo-user] memset_s by Jorge Almeida
1 On Tue, Nov 14, 2017 at 11:36 AM, Jorge Almeida <jjalmeida@×××××.com> wrote:
2 > On Fri, Nov 10, 2017 at 12:09 PM, Jorge Almeida <jjalmeida@×××××.com> wrote:
3 >
4 >> http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html
5 >>
6 >>
7 >>>> Of course, what would really solve the optimize-into-oblivion problem
8 >>>> is a pragma that when invoked on a particular block of code (maybe
9 >>>> only a function definition) would tell the compiler to do what the
10 >>>> programmer says rather than viewing a function as a kind of black box.
11 >>>>
12 >>>
13 >
14 > It seems a solution exists with gcc:
15 >
16 > https://stackoverflow.com/questions/2219829/how-to-prevent-gcc-optimizing-some-statements-in-c
17 >
18 > The last reply:
19 >
20 > void __attribute__((optimize("O0"))) foo(unsigned char data) {
21 > // unmodifiable compiler code
22 > }
23 >
24 > Any comments, anyone? Yes, it's gcc, but IMO this should be in the
25 > language itself. Am I right to assume this is a poorly known feature
26 > of gcc?
27 > It allows, for example, to replace sensitive data by random bytes,
28 > existing system callls like memset() or getrandom() can be used as
29 > they are, no reimplementation needed.
30 >
31
32 Very interesting. I imagine the opinion of the standards committee
33 would be that the variability in code generation precludes a standard
34 interface to optimization controls. This might seem unusual, but
35 languages with a very controlling standard (like Java or C#) are a new
36 concept.
37
38 What I am wondering about is if C code which uses
39 __attribute__((optimize(...))) is against Gentoo package standards and
40 would have to be removed from the Portage tree.
41
42 Cheers,
43 R0b0t1

Replies

Subject Author
Re: [gentoo-user] memset_s Jorge Almeida <jjalmeida@×××××.com>
[gentoo-user] Re: memset_s Grant Edwards <grant.b.edwards@×××××.com>