From: Christian Brauner <brauner@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: linux-fsdevel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Seth Forshee <sforshee@kernel.org>,
Tycho Andersen <tycho@tycho.pizza>,
Heiko Carstens <hca@linux.ibm.com>
Subject: Re: [PATCH 2/2] pidfd: add pidfdfs
Date: Fri, 23 Feb 2024 22:26:21 +0100 [thread overview]
Message-ID: <20240223-schusselig-windschatten-a108c9034c5b@brauner> (raw)
In-Reply-To: <20240223-delfin-achtlos-e03fd4276a34@brauner>
On Fri, Feb 23, 2024 at 12:55:07PM +0100, Christian Brauner wrote:
> > Apologies if this has already been reported or fixed but I did not see
> > anything on the mailing list.
> >
> > On next-20240221 and next-20240222, with CONFIG_FS_PID=y, some of my
> > services such as abrtd, dbus, and polkit fail to start on my Fedora
> > machines, which causes further isssues like failing to start network
> > interfaces with NetworkManager. I can easily reproduce this in a Fedora
> > 39 QEMU virtual machine, which has:
> >
> > # systemctl --version
> > systemd 254 (254.9-1.fc39)
>
> If something fails for completely inexplicable reasons:
>
> Feb 23 12:09:58 fed1 audit[353]: AVC avc: denied { read write open } for pid=353 comm="systemd-userdbd" path="pidfd:[709]" dev="pidfs" ino=709 scontext=system_u:system_r:systemd_userdbd_t:>
>
> > +SELINUX
>
> pidfd creation can now be mediated by LSMs since we can finally go
> through the regular open path. That wasn't possible before but LSM
> mediation ability had been requested a few times.
>
> In short, we have to update the selinux policy for Fedora. (Fwiw, went
> through the same excercise with nsfs back then.)
>
> I've created a pull-request here:
>
> https://github.com/fedora-selinux/selinux-policy/pull/2050
>
> and filed an issue here:
>
> https://bugzilla.redhat.com/show_bug.cgi?id=2265630
>
> We have sufficient time to get this resolved and I was assured that this
> would be resolved. If we can't get it resolved in a timely manner we'll
> default to N for a while until everything's updated but I'd like to
> avoid that. I'll track that issue.
So I want to provide more context since I took the time to track this
all down in detail.
The failure you are seeing is indeed an selinux denial as I've pointed
out. The core failure is dbus-broker. That cascades into all the other
services failing. When dbus-broker fails to start polkit and all the
others won't be able to work because they depend on dbus-broker.
The reason for dbus-broker failing is because it doesn't handle failures
for SO_PEERPIDFD correctly. Last kernel release (either v6.7 or v6.6,
I'm not completely sure right now) we introduced SO_PEERPIDFD (and
SCM_PIDFD). SO_PEERPIDFD allows dbus-broker and polkit and others to
receive a pidfd for the peer of an AF_UNIX socket. This is the first
time in the history of Linux that we can safely authenticate clients in
a race-free manner. :)
dbus-broker immediately made use of this but messed up the error
checking. It only allowed EINVAL as a valid failure for SO_PEERPIDFD.
That's obviously problematic not just because of LSM denials but because
of seccomp denials that would prevent SO_PEERPIDFD from working; or any
other new error code from there.
So this is catching a flawed implementation in dbus-broker as well. It
_has_ to fallback to the old pid-based authentication when SO_PEERPIDFD
doesn't work no matter the reasons otherwise it'll always risk such
failures.
So, the immediate fix separate from the selinux policy update is to fix
dbus-broker which we've done now:
https://github.com/bus1/dbus-broker/pull/343
That should make it into Fedora asap as well.
The selinux reference policy is also updated in addition to the Fedora
policy:
https://github.com/bus1/dbus-broker/pull/343
So overall that LSM denial should not have caused dbus-broker to fail.
It can never assume that a feature released one kernel ago like
SO_PEERPIDFD can be assumed to be available.
next prev parent reply other threads:[~2024-02-23 21:26 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 16:45 [PATCH 0/2] Move pidfd to tiny pseudo fs Christian Brauner
2024-02-13 16:45 ` [PATCH 1/2] pidfd: move struct pidfd_fops Christian Brauner
2024-02-13 16:45 ` [PATCH 2/2] pidfd: add pidfdfs Christian Brauner
2024-02-13 17:17 ` Linus Torvalds
2024-02-14 14:40 ` Christian Brauner
2024-02-14 18:27 ` Christian Brauner
2024-02-14 18:37 ` Linus Torvalds
2024-02-15 16:11 ` Christian Brauner
2024-02-16 11:50 ` Christian Brauner
2024-02-16 16:41 ` Christian Brauner
2024-02-17 13:59 ` Oleg Nesterov
2024-02-17 17:30 ` Linus Torvalds
2024-02-17 17:38 ` Linus Torvalds
2024-02-18 11:15 ` Christian Brauner
2024-02-18 11:33 ` Christian Brauner
2024-02-18 17:54 ` Christian Brauner
2024-02-18 18:08 ` Linus Torvalds
2024-02-18 18:57 ` Linus Torvalds
2024-02-19 18:05 ` Christian Brauner
2024-02-19 18:34 ` Linus Torvalds
2024-02-19 21:18 ` Christian Brauner
2024-02-19 23:24 ` Linus Torvalds
2024-02-18 14:27 ` Oleg Nesterov
2024-02-18 9:30 ` Christian Brauner
2024-02-22 19:03 ` Nathan Chancellor
2024-02-23 10:18 ` Heiko Carstens
2024-02-23 11:56 ` Christian Brauner
2024-02-23 11:55 ` Christian Brauner
2024-02-23 12:57 ` Heiko Carstens
2024-02-23 13:27 ` Christian Brauner
2024-02-23 13:35 ` Heiko Carstens
2024-02-23 13:41 ` Christian Brauner
2024-02-23 21:26 ` Christian Brauner [this message]
2024-02-23 21:58 ` Linus Torvalds
2024-02-24 5:52 ` Christian Brauner
2024-02-24 6:05 ` Christian Brauner
2024-02-24 18:48 ` Linus Torvalds
2024-02-24 19:15 ` Christian Brauner
2024-02-24 19:19 ` Christian Brauner
2024-02-24 19:21 ` Linus Torvalds
2024-02-27 19:26 ` Nathan Chancellor
2024-02-27 22:13 ` Christian Brauner
2024-03-12 10:35 ` Geert Uytterhoeven
2024-03-12 14:09 ` Christian Brauner
2024-05-15 11:10 ` Jiri Slaby
2024-05-15 16:39 ` Christian Brauner
2024-05-16 5:28 ` Jiri Slaby
2024-05-17 7:09 ` Jiri Slaby
2024-05-17 7:54 ` Jiri Slaby
2024-05-17 20:07 ` Linus Torvalds
2024-05-20 8:23 ` Jiri Slaby
2024-05-20 19:01 ` Linus Torvalds
2024-05-20 19:15 ` Linus Torvalds
2024-05-21 6:07 ` Jiri Slaby
2024-05-21 6:13 ` Jiri Slaby
2024-05-21 12:33 ` Christian Brauner
2024-05-21 12:40 ` Christian Brauner
2024-05-21 15:10 ` Linus Torvalds
2024-05-25 11:57 ` Christian Brauner
2024-05-21 12:16 ` Christian Brauner
2024-02-13 17:02 ` [PATCH 0/2] Move pidfd to tiny pseudo fs 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=20240223-schusselig-windschatten-a108c9034c5b@brauner \
--to=brauner@kernel.org \
--cc=hca@linux.ibm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=sforshee@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tycho@tycho.pizza \
--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