linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: viro@ZenIV.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: fs: Uninitialized memory read at take_dentry_name_snapshot
Date: Mon, 4 Sep 2017 23:11:04 +0900	[thread overview]
Message-ID: <201709042311.IIE60447.OJSQFMHtOFLVOF@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <20170904132106.GU5426@ZenIV.linux.org.uk>

Al Viro wrote:
> On Mon, Sep 04, 2017 at 09:12:38PM +0900, Tetsuo Handa wrote:
> > Hello.
> > 
> > I hit kmemcheck splat on commit 49d31c2f389acfe8 ("dentry name snapshots") using linux-next-20170901.
> > Changing to strncpy() fixes this problem, but using strncpy() only if CONFIG_KMEMCHECK=y is better
> > for performance?
> 
> *shrug*
> 
> If anything, use dentry->d_name.len + 1 instead of DNAME_INLINE_LEN there, but
> that's really a false positive.

A false positive? Isn't it because we do

  dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
  (...snipped...)
  dname = dentry->d_iname;
  (...snipped...)
  memcpy(dname, name->name, name->len);
  dname[name->len] = 0;

at __d_alloc() which leaves a room for some of d_iname[] bytes uninitialized?
So, I think either pad explicitly at __f_alloc() or use dentry->d_name.len + 1 is needed.

  reply	other threads:[~2017-09-04 14:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-04 12:12 fs: Uninitialized memory read at take_dentry_name_snapshot Tetsuo Handa
2017-09-04 13:21 ` Al Viro
2017-09-04 14:11   ` Tetsuo Handa [this message]
2017-09-04 14:22     ` Al Viro
2017-09-04 16:56       ` Vegard Nossum
2017-09-13 10:12         ` [PATCH] dentry: Fix kmemcheck splat at take_dentry_name_snapshot() Tetsuo Handa

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=201709042311.IIE60447.OJSQFMHtOFLVOF@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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 NNTP newsgroup(s).