From: Al Viro <viro@zeniv.linux.org.uk>
To: Boris Burkov <boris@bur.io>
Cc: linux-fsdevel@vger.kernel.org, daan.j.demeyer@gmail.com
Subject: Re: Possible bug with open between unshare(CLONE_NEWNS) calls
Date: Thu, 16 Jan 2025 05:12:47 +0000 [thread overview]
Message-ID: <20250116051247.GE1977892@ZenIV> (raw)
In-Reply-To: <20250116045241.GA2456181@zen.localdomain>
On Wed, Jan 15, 2025 at 08:52:41PM -0800, Boris Burkov wrote:
> So in your opinion, what is the bug here?
>
> btrfs started using d_path and checking that the device source file was
> in /dev, to avoid putting nonsense like /proc/self/fd/3 into the mount
> table, where it makes userspace fall over.
>
> (https://bugzilla.suse.com/show_bug.cgi?id=1230641)
>
> I'd be loathe to call the userspace program hitting the
> 'unshare; open; unshare' sequence buggy, as we don't fail any of the
> syscalls in a particularly sensible way. And if you use unshare -m, you
> now have to vet the program you call doesn't use unshare itself?
>
> You've taught me that d_path is working as intended in the face of the
> namespace lifetime, so we can't rely on it to produce the "real"
> (original?) path, in general.
>
> So, to me, that leaves the bug as
> "btrfs shouldn't assume/validate that device files will be in /dev."
>
> We can do the d_path resolution thing anyway to cover the common case,
> in the bugzilla, but shouldn't fail on something like /loop0 when that
> is what we get out of d_path?
You are asking for a pathname associated with an open file on a mount
that is not within your namespace. "The path from the root of whatever
namespace it's in starts with /dev" is an odd predicate to check.
Note that the same namespace may have a very different meaning in your
namespace, so... I'd say that predicate is very likely not doing what
your userland expects anyway.
What is that code trying to do? is_good_path() looks very... misguided.
next prev parent reply other threads:[~2025-01-16 5:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 18:56 Possible bug with open between unshare(CLONE_NEWNS) calls Boris Burkov
2025-01-16 4:14 ` Al Viro
2025-01-16 4:52 ` Boris Burkov
2025-01-16 5:12 ` Al Viro [this message]
2025-01-16 10:46 ` Christian Brauner
2025-01-16 21:09 ` Qu Wenruo
2025-01-16 21:29 ` Al Viro
2025-01-16 21:42 ` Qu Wenruo
2025-01-20 15:37 ` Christian Brauner
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=20250116051247.GE1977892@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=boris@bur.io \
--cc=daan.j.demeyer@gmail.com \
--cc=linux-fsdevel@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