Re: [PATCH bpf-next v4 3/7] bpf: Introduce BPF_MODIFY_RETURN
From: Stephen Smalley <stephen.smalley.work@gmail.com>
Date: 2020-03-05 18:02:23
Also in:
bpf, lkml
On Thu, Mar 5, 2020 at 12:35 PM Casey Schaufler [off-list ref] wrote:
I believe that I have stated that order isn't my issue. Go first, last or as specified in the lsm list, I really don't care. We'll talk about what does matter in the KRSI thread.
Order matters when the security module logic (in this case, the BPF program) is loaded from userspace and the userspace process isn't already required to be fully privileged with respect to the in-kernel security modules. CAP_MAC_ADMIN was their (not unreasonable) attempt to check that requirement; it just doesn't happen to convey the same meaning for SELinux since SELinux predates the introduction of CAP_MAC_ADMIN (in Linux at least) and since SELinux was designed to confine even processes with capabilities.
Then I'm fine with using the LSM ordering mechanisms that Kees thought through to run the BPF last. Although I think it's somewhat concerning that SELinux cares what other security models might be in place. If BPF programs can violate SELinux (or traditional DAC) policies there are bigger issues than ordering.
It is only safe for Smack because CAP_MAC_ADMIN already conveys all privileges with respect to Smack. Otherwise, the BPF program can access information about the object attributes, e.g. inode attributes, and leak that information to userspace even if SELinux would have denied the process that loaded the BPF program permissions to directly obtain that information. This is also why Landlock has to be last in the LSM list.