From: daw@cs.berkeley.edu (David Wagner)
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] security/selinux: decrement sizeof size in strncmp
Date: Sat, 14 Nov 2009 03:44:14 +0000 (UTC) [thread overview]
Message-ID: <hdl92e$srv$1@taverner.cs.berkeley.edu> (raw)
In-Reply-To: 4AFE1EA9.60102@schaufler-ca.com
Casey Schaufler wrote:
> No, but I hate arguing with people who think that every time
> they see strcmp that they have found a security flaw.
Valdis.Kletnieks@vt.edu wrote:
> How do you feel about people who think every time they see strcmp()
> "Oh crap, something that needs auditing"? ;)
Casey Schaufler wrote:
> They have my deep sympathy. Which is why I'm advocating leaving
> the perfectly functional and correct use of strncmp() as it is.
Personally, I think this is catering to irrational kneejerk responses,
from hypothetical people who may or may not exist. I have yet to see a
single person stand up on the linux-kernel mailing list, endorse such
a position, and put their own name behind it. That's no surprise,
because it looks to me like an illogical and unjustified position that
would reflect poorly on anyone who adopted such a position in this case.
I do not think it makes sense to make a decision based upon the hypothesis
that maybe unidentified others will think that way, particularly when
no one can put forward a convincing argument that "thinking that way"
is reasonable in light of the technical facts.
I personally don't find
strncmp(foo, "constant", sizeof("constant")) // first snippet
to be more readable, auditable, or obviously correct than
strcmp(foo, "constant"). // second snippet
Do you? Does anyone?
Of course, those two code snippets have exactly the same behavior, so
there is no difference in their actual security properties. The only
possible difference I can imagine would be if one code snippet is
more readable, intuitive, or obviously correct than the other -- but I
would think strcmp() is no worse under those criteria, and if anything
modestly better. Is there a technical basis for arguing that the first
snippet is better than the second snippet?
next prev parent reply other threads:[~2009-11-14 3:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-12 7:49 [PATCH 3/4] security/selinux: decrement sizeof size in strncmp Julia Lawall
2009-11-12 8:16 ` James Morris
2009-11-12 14:53 ` Serge E. Hallyn
2009-11-12 14:57 ` Julia Lawall
2009-11-12 16:21 ` Casey Schaufler
2009-11-12 18:28 ` David Wagner
2009-11-12 21:41 ` James Morris
2009-11-12 21:59 ` Julia Lawall
2009-11-12 23:56 ` David Wagner
2009-11-13 2:11 ` Casey Schaufler
2009-11-13 20:32 ` David Wagner
2009-11-13 21:23 ` Valdis.Kletnieks
2009-11-13 21:26 ` Julia Lawall
2009-11-13 23:08 ` Valdis.Kletnieks
2009-11-14 0:41 ` David Wagner
2009-11-14 5:08 ` Valdis.Kletnieks
2009-11-14 15:22 ` Julia Lawall
2009-11-13 23:06 ` David Wagner
2009-11-14 3:06 ` Casey Schaufler
2009-11-14 3:44 ` David Wagner [this message]
2009-11-14 3:48 ` Joe Perches
2009-11-14 5:12 ` Casey Schaufler
2009-11-14 5:26 ` Joe Perches
2009-11-14 7:20 ` Casey Schaufler
2009-11-15 7:45 ` Raja R Harinath
2009-11-15 18:44 ` Casey Schaufler
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='hdl92e$srv$1@taverner.cs.berkeley.edu' \
--to=daw@cs.berkeley.edu \
--cc=daw-news@taverner.cs.berkeley.edu \
--cc=linux-kernel@vger.kernel.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