public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Evgeny Kuznetsov <EXT-Eugeny.Kuznetsov@nokia.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	akpm@linux-foundation.org, phillip@lougher.demon.co.uk,
	hsweeten@visionengravers.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] initramfs: strcpy destination string overflow
Date: Tue, 5 Oct 2010 17:51:59 +0100	[thread overview]
Message-ID: <20101005165159.GQ19804@ZenIV.linux.org.uk> (raw)
In-Reply-To: <AANLkTinoCgO56O1kPNW3vjd9Nd1kY2SU34UH2RQa9qkE@mail.gmail.com>

On Tue, Oct 05, 2010 at 08:55:01AM -0700, Linus Torvalds wrote:

> I think this is wrong.
> 
> If the name is too long to fit in the hash table, we should not create
> a new hash entry at all, because we'd be returning the wrong
> (truncated) name when we find it next time.
> 
> So it would be much better to just do
> 
>    if (strlen(name) >= sizeof(q->name))
>       return NULL;
> 
> in find_link(), because as far as I can tell, the hard-linking is
> always just an optimization.
> 
> Comments? Peter?

Take a look at struct hash definition.  That sizeof is PATH_MAX and
do_header() will reject an entry with name longer than that.  IOW,
the whole thing is a non-issue; we can add
	if (strlen(name) >= PATH_MAX)
		BUG();
if we really care, but that's it.

As a side note, it looks like we need a fat warning about blind "improvements"
of that kind in CodingStyle; cargo-cult replacements like that can easily
hide real bugs... ;-/

  parent reply	other threads:[~2010-10-05 16:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05  8:44 [PATCH 0/1] initramfs: strcpy destination string overflow Evgeny Kuznetsov
2010-10-05  8:44 ` [PATCH 1/1] " Evgeny Kuznetsov
2010-10-05 11:44   ` Américo Wang
2010-10-05 15:55   ` Linus Torvalds
2010-10-05 16:00     ` H. Peter Anvin
2010-10-05 16:51     ` Al Viro [this message]
2010-10-05 18:09       ` H. Peter Anvin
2010-10-06  8:58         ` Evgeny Kuznetsov

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=20101005165159.GQ19804@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=EXT-Eugeny.Kuznetsov@nokia.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@lougher.demon.co.uk \
    --cc=torvalds@linux-foundation.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