LKML Archive on
help / color / mirror / Atom feed
From: Dmitry Kadashev <>
To: Stephen Brennan <>
Cc: Alexander Viro <>,
	Jens Axboe <>,
	linux-fsdevel <>,
Subject: Re: [PATCH] namei: Fix use after free in kern_path_locked
Date: Wed, 1 Sep 2021 14:35:08 +0700	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Wed, Sep 1, 2021 at 7:13 AM Stephen Brennan
<> wrote:
> In 0ee50b47532a ("namei: change filename_parentat() calling
> conventions"), filename_parentat() was made to always put the struct
> filename before returning, and kern_path_locked() was migrated to this
> calling convention. However, kern_path_locked() uses the "last"
> parameter to lookup and potentially create a new dentry. The last
> parameter contains the last component of the path and points within the
> filename, which was recently freed at the end of filename_parentat().
> Thus, when kern_path_locked() calls __lookup_hash(), it is using the
> filename after it has already been freed.
> To avoid this, switch back to __filename_parentat() and place a putname
> at the end of the function, once all uses are completed.

Ouch. Thanks for taking care of this, Stephen. I guess
filename_parentat() should be killed, since kern_path_locked() was the
only place it's used in and it always results in danging "last",
provoking bugs just like this one. I can send a patch on top of this if
you prefer.


  reply	other threads:[~2021-09-01  7:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01  0:13 Stephen Brennan
2021-09-01  7:35 ` Dmitry Kadashev [this message]
2021-09-01  9:12   ` Christoph Hellwig
2021-09-01 14:47     ` Dmitry Kadashev

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \ \ \ \ \
    --subject='Re: [PATCH] namei: Fix use after free in kern_path_locked' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).