lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250506003514.66821-1-kuniyu@amazon.com>
Date: Mon, 5 May 2025 17:35:10 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <paul@...l-moore.com>
CC: <andrii@...nel.org>, <ast@...nel.org>, <bpf@...r.kernel.org>,
	<brauner@...nel.org>, <casey@...aufler-ca.com>, <daniel@...earbox.net>,
	<eddyz87@...il.com>, <gnoack@...gle.com>, <haoluo@...gle.com>,
	<jmorris@...ei.org>, <john.fastabend@...il.com>, <jolsa@...nel.org>,
	<kpsingh@...nel.org>, <kuni1840@...il.com>, <kuniyu@...zon.com>,
	<linux-security-module@...r.kernel.org>, <martin.lau@...ux.dev>,
	<mic@...ikod.net>, <netdev@...r.kernel.org>, <omosnace@...hat.com>,
	<sdf@...ichev.me>, <selinux@...r.kernel.org>, <serge@...lyn.com>,
	<song@...nel.org>, <stephen.smalley.work@...il.com>,
	<yonghong.song@...ux.dev>
Subject: Re: [PATCH v1 bpf-next 0/5] af_unix: Allow BPF LSM to scrub SCM_RIGHTS at sendmsg().

From: Paul Moore <paul@...l-moore.com>
Date: Mon, 5 May 2025 19:21:25 -0400
> On Mon, May 5, 2025 at 5:58 PM Kuniyuki Iwashima <kuniyu@...zon.com> wrote:
> >
> > As long as recvmsg() or recvmmsg() is used with cmsg, it is not
> > possible to avoid receiving file descriptors via SCM_RIGHTS.
> >
> > This behaviour has occasionally been flagged as problematic.
> >
> > For instance, as noted on the uAPI Group page [0], an untrusted peer
> > could send a file descriptor pointing to a hung NFS mount and then
> > close it.  Once the receiver calls recvmsg() with msg_control, the
> > descriptor is automatically installed, and then the responsibility
> > for the final close() now falls on the receiver, which may result
> > in blocking the process for a long time.
> >
> > systemd calls cmsg_close_all() [1] after each recvmsg() to close()
> > unwanted file descriptors sent via SCM_RIGHTS.
> >
> > However, this cannot work around the issue because the last fput()
> > could occur on the receiver side once sendmsg() with SCM_RIGHTS
> > succeeds.  Also, even filtering by LSM at recvmsg() does not work
> > for the same reason.
> >
> > Thus, we need a better way to filter SCM_RIGHTS on the sender side.
> >
> > This series allows BPF LSM to inspect skb at sendmsg() and scrub
> > SCM_RIGHTS fds by kfunc.
> 
> I'll take a closer look later this week, but generally speaking LSM
> hooks are intended for observability and access control, not data
> modification, which means what you are trying to accomplish may not be
> a good fit for a LSM hook.  Have you considered simply inspecting the
> skb at sendmsg() and rejecting the send in the LSM hook if a
> SCM_RIGHTS cmsg is present that doesn't fit within the security policy
> implemented in your BPF program?

I think the simple inspection (accept all or deny) does not cover
a real use case and is not that helpful.

I don't like to add another hook point in AF_UNIX code just because
of it and rather want to reuse the exisiting hook as we have a nice
place.

Also, passing skb makes it possible to build much more flexible
policy as it allows bpf prog to inspect the skb payload with
existing bpf helpers.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ