Re: [PATCH V4 0/5] mlx5 ConnectX control misc driver

From: Jakub Kicinski
Date: Thu Feb 15 2024 - 20:40:44 EST


On Wed, 14 Feb 2024 14:37:55 -0400 Jason Gunthorpe wrote:
> On Wed, Feb 14, 2024 at 10:11:26AM -0800, Jakub Kicinski wrote:
> > On Wed, 14 Feb 2024 13:57:35 -0400 Jason Gunthorpe wrote:
> > > There is a clear split in my mind between:
> > > - inspection debugging
> > > - invasive mutating debugging
> > > - configuration
> >
> > Yes there's a clear split, and how are you going to enforce it on
> > an opaque interface? Put an "evil" bit in the common header?
>
> The interface is opaque through a subsystem, it doesn't mean it is
> completely opaque to every driver layer in the kernel. There is still a
> HW specific kernel driver that delivers the FW command to the actual
> HW.
>
> In the mlx5 model the kernel driver stamps the command with "uid"
> which is effectively a security scope label. This cannot be avoided by
> userspace and is fundamental to why mlx5ctl is secure in a lockdown
> kernel.
>
> For example mlx5's FW interface has the concept of security scopes. We
> have several defined today:
> - Kernel
> - Userspace rdma
> - Userspace rdma with CAP_NET_RAW
> - Userspace rdma with CAP_SYS_RAWIO
>
> So we trivally add three more for the scopes I listed above. The
> mlx5ctl driver as posted already introduced a new scope, for example.
>
> Userspace will ask the kernel for an appropriate security scope after
> opening the char-device. If userspace asks for invasive then you get a
> taint. Issuing an invasive command without a kernel applied invasive
> security label will be rejected by the FW.
>
> We trust the kernel to apply the security label for the origin of the
> command. We trust the the device FW to implement security scopes,
> because these are RDMA devices and all of RDMA and all of SRIOV
> virtualization are totally broken if the device FW cannot be trusted
> to maintain security separation between scopes.

You have changed the argument.

The problem Andy was raising is that users having access to low level
configuration will make it impossible for distro's support to tell
device configuration. There won't be any trace of activity at the OS
level.

To which you replied that you can differentiate between debugging and
configuration on an opaque interface, _in the kernel_.

Which I disagree with, obviously.

And now you're saying that you can maintain security if you trust
the firmware to enforce some rules.

I'm not talking about security here, the evil bit is just an example
of an unsound design.