From: R0b0t1 <r030t1@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] memset_s
Date: Fri, 10 Nov 2017 17:19:31 -0600 [thread overview]
Message-ID: <CAAD4mYg96zgLaSTEENtgjXuuNM7L1rwdmFU=rqT_0HYE5zNOYA@mail.gmail.com> (raw)
In-Reply-To: <CAKpSnp+jw=Xdq7V4ZZDzdFb7GMTb+ES7Mxq2PwQH-EcVqBHhdA@mail.gmail.com>
On Fri, Nov 10, 2017 at 2:09 PM, Jorge Almeida <jjalmeida@gmail.com> wrote:
> On Fri, Nov 10, 2017 at 4:25 PM, R0b0t1 <r030t1@gmail.com> wrote:
>> Hello,
>>
>
>>
>> I'm having trouble finding the article again, but these functions look
>> very similar to Microsoft's extensions to the C standard. There is a
>> good case to be made that they are counterproductive.
>
> Yes, it looks like it. No wonder, if it's MS inspired. But what I care
> about is the fact that it's not optimized away, not the boundaries
> checking stuff. It's hard to believe that it is practically impossible
> to clean up a buffer, unless one is willing to forego all
> optimizations:
>
> http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html
>
I really think there is a deeper issue here then, which is that the
compiler takes a lot of liberties when translating a program
description into machine code. There have been suggestions made that
this makes very nearly all compilers unsuitable for high reliability
purposes. Cryptographic or user security code is likely a candidate
for the label "high reliability."
To further explain why the additions are counterproductive: the
programmer still has to remember to use them. It is just as likely
that the programmer will forget to use memset_s properly as any of the
other functions in string.h (possibly by forgetting to sanitize input
i.e. the memory segment boundaries).
>
>>> Of course, what would really solve the optimize-into-oblivion problem
>>> is a pragma that when invoked on a particular block of code (maybe
>>> only a function definition) would tell the compiler to do what the
>>> programmer says rather than viewing a function as a kind of black box.
>>>
>>
>> This would probably be useful. It may be wise to reimplement important
>> functionality.
>>
> No idea how difficult it would be to implement, of course. There might
> even exist a C keyword for that. After all, the C standard states the
> "as-if" rule, it might as well establish such an exception.
>
Sorry, I misrepresented what I meant. I meant to suggest
reimplementing, apart from a standard library, any critical code. This
is generally recommended against but unless there is a hand-tuned
version that has been guaranteed to work around quirks in your
compiler, you are now the person who has to write and maintain that
hand-tuned version.
If you don't mind I might post this concern to the GCC mailing list,
or you can take it up if you want.
Cheers,
R0b0t1
next prev parent reply other threads:[~2017-11-10 23:19 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-10 9:54 [gentoo-user] memset_s Jorge Almeida
2017-11-10 10:52 ` Marc Joliet
2017-11-10 11:34 ` Jorge Almeida
2017-11-10 16:25 ` R0b0t1
2017-11-10 18:20 ` Alexander Kapshuk
2017-11-10 20:09 ` Jorge Almeida
2017-11-10 23:19 ` R0b0t1 [this message]
2017-11-11 0:10 ` Jorge Almeida
2017-11-13 3:03 ` Mart Raudsepp
2017-11-13 7:17 ` Jorge Almeida
2017-11-13 10:44 ` [gentoo-user] memset_s Nikos Chantziaras
2017-11-13 11:16 ` Jorge Almeida
2017-11-13 11:38 ` Mart Raudsepp
2017-11-13 14:26 ` Nikos Chantziaras
2017-11-14 17:36 ` [gentoo-user] memset_s Jorge Almeida
2017-11-15 4:42 ` R0b0t1
2017-11-15 7:22 ` Jorge Almeida
2017-11-15 15:28 ` [gentoo-user] memset_s Grant Edwards
2017-11-15 15:41 ` R0b0t1
2017-11-15 15:48 ` R0b0t1
2017-11-15 21:42 ` Grant Edwards
2017-11-16 0:19 ` R0b0t1
2017-11-15 15:50 ` Jorge Almeida
2017-11-15 17:39 ` Michael Orlitzky
2017-11-15 8:54 ` Nikos Chantziaras
2017-11-15 9:05 ` Jorge Almeida
2017-11-15 10:31 ` Nikos Chantziaras
2017-11-10 11:38 ` Nikos Chantziaras
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='CAAD4mYg96zgLaSTEENtgjXuuNM7L1rwdmFU=rqT_0HYE5zNOYA@mail.gmail.com' \
--to=r030t1@gmail.com \
--cc=gentoo-user@lists.gentoo.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