Thread View: linux.kernel.netdev
13 messages
13 total messages
Started by Leon Romanovsky
Sun, 22 Nov 2026 07:31
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Leon Romanovsky
Date: Sun, 22 Nov 2026 07:31
Date: Sun, 22 Nov 2026 07:31
136 lines
13247 bytes
13247 bytes
On Tue, Nov 17, 2026 at 07:09:14PM +0200, Yishai Hadas wrote:
> Userspace must know when a device is in adversarial mode, and an
> unaware rdma-core must not get a context on such a device, as it
> doesn't harden itself against the NIC.
Why is this a “must”? If it is required, please describe in the commit
message the scenario that cannot be supported without this new UAPI flag.
>
> Report the mode with IB_UVERBS_CORE_SUPPORT_ADVERSARIAL in the
> core_support of GET_CONTEXT and QUERY_CONTEXT. Add an optional
> UVERBS_ATTR_GET_CONTEXT_FLAGS input, where userspace declares
> UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED. In adversarial
> mode, GET_CONTEXT without that flag fails with -EPERM, and so does the
> legacy write() GET_CONTEXT, which has no way to pass it.
The above is AI generated useless information, completely useless.
Thanks
>
> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> ---
> drivers/infiniband/core/uverbs_cmd.c | 5 +++++
> .../infiniband/core/uverbs_std_types_device.c | 16 ++++++++++++++++
> include/uapi/rdma/ib_user_ioctl_cmds.h | 5 +++++
> include/uapi/rdma/ib_user_ioctl_verbs.h | 1 +
> 4 files changed, 27 insertions(+)
>
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index aca7c6ab55cd..b78207a81091 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -292,6 +292,11 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs)
> goto err_ucontext;
> }
>
> + if (ib_dev->adversarial_mode) {
> + ret = -EPERM;
> + goto err_uobj;
> + }
> +
> resp = (struct ib_uverbs_get_context_resp){
> .num_comp_vectors = attrs->ufile->device->num_comp_vectors,
> .async_fd = uobj->id,
> diff --git a/drivers/infiniband/core/uverbs_std_types_device.c b/drivers/infiniband/core/uverbs_std_types_device.c
> index db65032e80b4..72c67f09533e 100644
> --- a/drivers/infiniband/core/uverbs_std_types_device.c
> +++ b/drivers/infiniband/core/uverbs_std_types_device.c
> @@ -248,6 +248,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
> u32 num_comp = attrs->ufile->device->num_comp_vectors;
> u64 core_support = IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS;
> struct ib_device *ib_dev;
> + u32 ctx_flags;
> int ret;
>
> ib_dev = srcu_dereference(attrs->ufile->device->ib_dev,
> @@ -255,6 +256,15 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
> if (!ib_dev)
> return -EIO;
>
> + ret = uverbs_get_flags32(&ctx_flags, attrs, UVERBS_ATTR_GET_CONTEXT_FLAGS,
> + UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED);
> + if (ret)
> + return ret;
> +
> + if (ib_dev->adversarial_mode &&
> + !(ctx_flags & UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED))
> + return -EPERM;
> +
> ret = uverbs_copy_to(attrs, UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
> &num_comp, sizeof(num_comp));
> if (IS_UVERBS_COPY_ERR(ret))
> @@ -262,6 +272,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
>
> if (ib_dev->ops.uverbs_robust_udata)
> core_support |= IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA;
> + if (ib_dev->adversarial_mode)
> + core_support |= IB_UVERBS_CORE_SUPPORT_ADVERSARIAL;
> ret = uverbs_copy_to(attrs, UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT,
> &core_support, sizeof(core_support));
> if (IS_UVERBS_COPY_ERR(ret))
> @@ -303,6 +315,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QUERY_CONTEXT)(
> if (IS_UVERBS_COPY_ERR(ret))
> return ret;
>
> + if (ib_dev->adversarial_mode)
> + core_support |= IB_UVERBS_CORE_SUPPORT_ADVERSARIAL;
> ret = uverbs_copy_to(attrs, UVERBS_ATTR_QUERY_CONTEXT_CORE_SUPPORT,
> &core_support, sizeof(core_support));
> if (IS_UVERBS_COPY_ERR(ret))
> @@ -519,6 +533,8 @@ DECLARE_UVERBS_NAMED_METHOD(
> UVERBS_ATTR_MIN_SIZE(sizeof(int)),
> UA_OPTIONAL,
> UA_ALLOC_AND_COPY),
> + UVERBS_ATTR_FLAGS_IN(UVERBS_ATTR_GET_CONTEXT_FLAGS, u32,
> + UA_OPTIONAL),
> UVERBS_ATTR_UHW());
>
> DECLARE_UVERBS_NAMED_METHOD(
> diff --git a/include/uapi/rdma/ib_user_ioctl_cmds.h b/include/uapi/rdma/ib_user_ioctl_cmds.h
> index 816b3107464f..3e482a4338f9 100644
> --- a/include/uapi/rdma/ib_user_ioctl_cmds.h
> +++ b/include/uapi/rdma/ib_user_ioctl_cmds.h
> @@ -101,10 +101,15 @@ enum uverbs_attrs_query_comp_cntr_caps_attr_ids {
> UVERBS_ATTR_QUERY_COMP_CNTR_CAPS_SUPPORTED_QP_ATTACH_OPS,
> };
>
> +enum uverbs_attrs_get_context_flags {
> + UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED = 1 << 0,
> +};
> +
> enum uverbs_attrs_get_context_attr_ids {
> UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
> UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT,
> UVERBS_ATTR_GET_CONTEXT_FD_ARR,
> + UVERBS_ATTR_GET_CONTEXT_FLAGS,
> };
>
> enum uverbs_attrs_query_context_attr_ids {
> diff --git a/include/uapi/rdma/ib_user_ioctl_verbs.h b/include/uapi/rdma/ib_user_ioctl_verbs.h
> index 21f86cc7bb1f..5861f34f8343 100644
> --- a/include/uapi/rdma/ib_user_ioctl_verbs.h
> +++ b/include/uapi/rdma/ib_user_ioctl_verbs.h
> @@ -47,6 +47,7 @@
> enum ib_uverbs_core_support {
> IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS = 1 << 0,
> IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA = 1 << 1,
> + IB_UVERBS_CORE_SUPPORT_ADVERSARIAL = 1 << 2,
> };
>
> enum ib_uverbs_access_flags {
> --
> 2.18.1
>
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Leon Romanovsky
Date: Tue, 24 Nov 2026 12:53
Date: Tue, 24 Nov 2026 12:53
163 lines
15354 bytes
15354 bytes
On Sun, Nov 22, 2026 at 11:33:44AM +0200, Yishai Hadas wrote:
> On 22/11/2026 9:31, Leon Romanovsky wrote:
> > On Tue, Nov 17, 2026 at 07:09:14PM +0200, Yishai Hadas wrote:
> > > Userspace must know when a device is in adversarial mode, and an
> > > unaware rdma-core must not get a context on such a device, as it
> > > doesn't harden itself against the NIC.
> >
> > Why is this a “must”? If it is required, please describe in the commit
> > message the scenario that cannot be supported without this new UAPI flag.
> >
>
> User space must protect itself from an untrusted NIC, as the kernel
> does. Hardening has a cost, so user space must know when to apply it,
> and unhardened user space must not run on such a device.
>
> More details are in the suggested commit message below.
>
> > >
> > > Report the mode with IB_UVERBS_CORE_SUPPORT_ADVERSARIAL in the
> > > core_support of GET_CONTEXT and QUERY_CONTEXT. Add an optional
> > > UVERBS_ATTR_GET_CONTEXT_FLAGS input, where userspace declares
> > > UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED. In adversarial
> > > mode, GET_CONTEXT without that flag fails with -EPERM, and so does the
> > > legacy write() GET_CONTEXT, which has no way to pass it.
> >
> > The above is AI generated useless information, completely useless.
> >
>
> Sure, it's dropped in the suggested commit message below.
>
> If no V3 is needed, could you please replace the commit message with this
> one when applying?
>
> RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
>
> In adversarial mode the NIC is not trusted. As the kernel protects its
> own code from it, user space has to protect its own area, e.g. the data
> path that polls CQEs directly from the HW.
>
> Hardened user space might use a different data path, with extra checks,
> and support a smaller surface. This isn't needed for a trusted NIC, so user
> space must know when a device is in adversarial mode.
This information is part of trust level series. Why is this a “must” in RDMA UAPI?
>
> Add a GET_CONTEXT handshake. User space that supports adversarial mode
> declares it, and the kernel reports the mode back, so user space moves
> to the hardened mode. If user space doesn't declare it, GET_CONTEXT
> fails with -EPERM on a device in adversarial mode. This prevents unhardened
> user space from running on such a device.
>
> Yishai
>
> >
> > >
> > > Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> > > ---
> > > drivers/infiniband/core/uverbs_cmd.c | 5 +++++
> > > .../infiniband/core/uverbs_std_types_device.c | 16 ++++++++++++++++
> > > include/uapi/rdma/ib_user_ioctl_cmds.h | 5 +++++
> > > include/uapi/rdma/ib_user_ioctl_verbs.h | 1 +
> > > 4 files changed, 27 insertions(+)
> > >
> > > diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> > > index aca7c6ab55cd..b78207a81091 100644
> > > --- a/drivers/infiniband/core/uverbs_cmd.c
> > > +++ b/drivers/infiniband/core/uverbs_cmd.c
> > > @@ -292,6 +292,11 @@ static int ib_uverbs_get_context(struct uverbs_attr_bundle *attrs)
> > > goto err_ucontext;
> > > }
> > > + if (ib_dev->adversarial_mode) {
> > > + ret = -EPERM;
> > > + goto err_uobj;
> > > + }
> > > +
> > > resp = (struct ib_uverbs_get_context_resp){
> > > .num_comp_vectors = attrs->ufile->device->num_comp_vectors,
> > > .async_fd = uobj->id,
> > > diff --git a/drivers/infiniband/core/uverbs_std_types_device.c b/drivers/infiniband/core/uverbs_std_types_device.c
> > > index db65032e80b4..72c67f09533e 100644
> > > --- a/drivers/infiniband/core/uverbs_std_types_device.c
> > > +++ b/drivers/infiniband/core/uverbs_std_types_device.c
> > > @@ -248,6 +248,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
> > > u32 num_comp = attrs->ufile->device->num_comp_vectors;
> > > u64 core_support = IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS;
> > > struct ib_device *ib_dev;
> > > + u32 ctx_flags;
> > > int ret;
> > > ib_dev = srcu_dereference(attrs->ufile->device->ib_dev,
> > > @@ -255,6 +256,15 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
> > > if (!ib_dev)
> > > return -EIO;
> > > + ret = uverbs_get_flags32(&ctx_flags, attrs, UVERBS_ATTR_GET_CONTEXT_FLAGS,
> > > + UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED);
> > > + if (ret)
> > > + return ret;
> > > +
> > > + if (ib_dev->adversarial_mode &&
> > > + !(ctx_flags & UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED))
> > > + return -EPERM;
> > > +
> > > ret = uverbs_copy_to(attrs, UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
> > > &num_comp, sizeof(num_comp));
> > > if (IS_UVERBS_COPY_ERR(ret))
> > > @@ -262,6 +272,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_GET_CONTEXT)(
> > > if (ib_dev->ops.uverbs_robust_udata)
> > > core_support |= IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA;
> > > + if (ib_dev->adversarial_mode)
> > > + core_support |= IB_UVERBS_CORE_SUPPORT_ADVERSARIAL;
> > > ret = uverbs_copy_to(attrs, UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT,
> > > &core_support, sizeof(core_support));
> > > if (IS_UVERBS_COPY_ERR(ret))
> > > @@ -303,6 +315,8 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QUERY_CONTEXT)(
> > > if (IS_UVERBS_COPY_ERR(ret))
> > > return ret;
> > > + if (ib_dev->adversarial_mode)
> > > + core_support |= IB_UVERBS_CORE_SUPPORT_ADVERSARIAL;
> > > ret = uverbs_copy_to(attrs, UVERBS_ATTR_QUERY_CONTEXT_CORE_SUPPORT,
> > > &core_support, sizeof(core_support));
> > > if (IS_UVERBS_COPY_ERR(ret))
> > > @@ -519,6 +533,8 @@ DECLARE_UVERBS_NAMED_METHOD(
> > > UVERBS_ATTR_MIN_SIZE(sizeof(int)),
> > > UA_OPTIONAL,
> > > UA_ALLOC_AND_COPY),
> > > + UVERBS_ATTR_FLAGS_IN(UVERBS_ATTR_GET_CONTEXT_FLAGS, u32,
> > > + UA_OPTIONAL),
> > > UVERBS_ATTR_UHW());
> > > DECLARE_UVERBS_NAMED_METHOD(
> > > diff --git a/include/uapi/rdma/ib_user_ioctl_cmds.h b/include/uapi/rdma/ib_user_ioctl_cmds.h
> > > index 816b3107464f..3e482a4338f9 100644
> > > --- a/include/uapi/rdma/ib_user_ioctl_cmds.h
> > > +++ b/include/uapi/rdma/ib_user_ioctl_cmds.h
> > > @@ -101,10 +101,15 @@ enum uverbs_attrs_query_comp_cntr_caps_attr_ids {
> > > UVERBS_ATTR_QUERY_COMP_CNTR_CAPS_SUPPORTED_QP_ATTACH_OPS,
> > > };
> > > +enum uverbs_attrs_get_context_flags {
> > > + UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED = 1 << 0,
> > > +};
> > > +
> > > enum uverbs_attrs_get_context_attr_ids {
> > > UVERBS_ATTR_GET_CONTEXT_NUM_COMP_VECTORS,
> > > UVERBS_ATTR_GET_CONTEXT_CORE_SUPPORT,
> > > UVERBS_ATTR_GET_CONTEXT_FD_ARR,
> > > + UVERBS_ATTR_GET_CONTEXT_FLAGS,
> > > };
> > > enum uverbs_attrs_query_context_attr_ids {
> > > diff --git a/include/uapi/rdma/ib_user_ioctl_verbs.h b/include/uapi/rdma/ib_user_ioctl_verbs.h
> > > index 21f86cc7bb1f..5861f34f8343 100644
> > > --- a/include/uapi/rdma/ib_user_ioctl_verbs.h
> > > +++ b/include/uapi/rdma/ib_user_ioctl_verbs.h
> > > @@ -47,6 +47,7 @@
> > > enum ib_uverbs_core_support {
> > > IB_UVERBS_CORE_SUPPORT_OPTIONAL_MR_ACCESS = 1 << 0,
> > > IB_UVERBS_CORE_SUPPORT_ROBUST_UDATA = 1 << 1,
> > > + IB_UVERBS_CORE_SUPPORT_ADVERSARIAL = 1 << 2,
> > > };
> > > enum ib_uverbs_access_flags {
> > > --
> > > 2.18.1
> > >
>
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Jason Gunthorpe
Date: Tue, 24 Nov 2026 12:59
Date: Tue, 24 Nov 2026 12:59
20 lines
11835 bytes
11835 bytes
> > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > > > In adversarial mode the NIC is not trusted. As the kernel protects its > > own code from it, user space has to protect its own area, e.g. the data > > path that polls CQEs directly from the HW. > > > > Hardened user space might use a different data path, with extra checks, > > and support a smaller surface. This isn't needed for a trusted NIC, so user > > space must know when a device is in adversarial mode. > > This information is part of trust level series. Why is this a “must” in RDMA UAPI? Userspace has to work differently if the kernel driver is in the adversarial mode, and the kernel should not permit an old non-supporting rdma-core from loading to prevent a security downgrade. So it has to be in the GET_CONTEXT handshake to do all of this. Jason
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Leon Romanovsky
Date: Tue, 24 Nov 2026 13:33
Date: Tue, 24 Nov 2026 13:33
36 lines
9506 bytes
9506 bytes
On Tue, Nov 24, 2026 at 08:59:50AM -0400, Jason Gunthorpe wrote: > > > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > > > > > In adversarial mode the NIC is not trusted. As the kernel protects its > > > own code from it, user space has to protect its own area, e.g. the data > > > path that polls CQEs directly from the HW. > > > > > > Hardened user space might use a different data path, with extra checks, > > > and support a smaller surface. This isn't needed for a trusted NIC, so user > > > space must know when a device is in adversarial mode. > > > > This information is part of trust level series. Why is this a “must” in RDMA UAPI? > > Userspace has to work differently if the kernel driver is in the > adversarial mode, and the kernel should not permit an old non-supporting > rdma-core from loading to prevent a security downgrade. I understand the first part of the sentence above, but the second part is unclear. Why should this prevent it? In adversarial mode, the kernel simply isolates that device from the others. Moreover, the kernel cannot determine whether rdma-core has actually been adapted. A locally cloned version of rdma-core can set the new adversarial flag without changing the old, legacy version. Once that flag is set, the kernel allows the patched rdma-core to proceed. Therefore, saying that it “should not permit” this makes no sense. Thanks > > So it has to be in the GET_CONTEXT handshake to do all of this. > > Jason >
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Jason Gunthorpe
Date: Tue, 24 Nov 2026 13:47
Date: Tue, 24 Nov 2026 13:47
39 lines
12812 bytes
12812 bytes
On Tue, Nov 24, 2026 at 03:33:53PM +0200, Leon Romanovsky wrote: > On Tue, Nov 24, 2026 at 08:59:50AM -0400, Jason Gunthorpe wrote: > > > > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > > > > > > > In adversarial mode the NIC is not trusted. As the kernel protects its > > > > own code from it, user space has to protect its own area, e.g. the data > > > > path that polls CQEs directly from the HW. > > > > > > > > Hardened user space might use a different data path, with extra checks, > > > > and support a smaller surface. This isn't needed for a trusted NIC, so user > > > > space must know when a device is in adversarial mode. > > > > > > This information is part of trust level series. Why is this a “must” in RDMA UAPI? > > > > Userspace has to work differently if the kernel driver is in the > > adversarial mode, and the kernel should not permit an old non-supporting > > rdma-core from loading to prevent a security downgrade. > > I understand the first part of the sentence above, but the second part is > unclear. Why should this prevent it? In adversarial mode, the kernel simply > isolates that device from the others. Userspace needs to do it too or it is not a complete defense. > Moreover, the kernel cannot determine whether rdma-core has actually been > adapted. A locally cloned version of rdma-core can set the new adversarial > flag without changing the old, legacy version. > > Once that flag is set, the kernel allows the patched rdma-core to proceed. > Therefore, saying that it “should not permit” this makes no sense. If someone makes a non-official version of rdma-core that doesn't work securely then I don't care one bit. I care that the official versions are not improperly mismtached to give something insecure. Jason
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Leon Romanovsky
Date: Tue, 24 Nov 2026 14:09
Date: Tue, 24 Nov 2026 14:09
52 lines
10372 bytes
10372 bytes
On Tue, Nov 24, 2026 at 09:47:51AM -0400, Jason Gunthorpe wrote: > On Tue, Nov 24, 2026 at 03:33:53PM +0200, Leon Romanovsky wrote: > > On Tue, Nov 24, 2026 at 08:59:50AM -0400, Jason Gunthorpe wrote: > > > > > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > > > > > > > > > In adversarial mode the NIC is not trusted. As the kernel protects its > > > > > own code from it, user space has to protect its own area, e.g. the data > > > > > path that polls CQEs directly from the HW. > > > > > > > > > > Hardened user space might use a different data path, with extra checks, > > > > > and support a smaller surface. This isn't needed for a trusted NIC, so user > > > > > space must know when a device is in adversarial mode. > > > > > > > > This information is part of trust level series. Why is this a “must” in RDMA UAPI? > > > > > > Userspace has to work differently if the kernel driver is in the > > > adversarial mode, and the kernel should not permit an old non-supporting > > > rdma-core from loading to prevent a security downgrade. > > > > I understand the first part of the sentence above, but the second part is > > unclear. Why should this prevent it? In adversarial mode, the kernel simply > > isolates that device from the others. > > Userspace needs to do it too or it is not a complete defense. > > > Moreover, the kernel cannot determine whether rdma-core has actually been > > adapted. A locally cloned version of rdma-core can set the new adversarial > > flag without changing the old, legacy version. > > > > Once that flag is set, the kernel allows the patched rdma-core to proceed. > > Therefore, saying that it “should not permit” this makes no sense. > > If someone makes a non-official version of rdma-core that doesn't work > securely then I don't care one bit. > > I care that the official versions are not improperly mismtached to > give something insecure. You explain why rdma-core needs to know about adversarial mode, which is fine. However, you also say that rdma-core MUST send this new flag back to justify the statement, “The kernel should not permit an old, non-supporting ...”. However, in your last reply, you said that the kernel does not actually care about the rdma-core mode. Thanks > > Jason >
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Jason Gunthorpe
Date: Tue, 24 Nov 2026 14:30
Date: Tue, 24 Nov 2026 14:30
55 lines
14107 bytes
14107 bytes
On Tue, Nov 24, 2026 at 04:09:06PM +0200, Leon Romanovsky wrote: > On Tue, Nov 24, 2026 at 09:47:51AM -0400, Jason Gunthorpe wrote: > > On Tue, Nov 24, 2026 at 03:33:53PM +0200, Leon Romanovsky wrote: > > > On Tue, Nov 24, 2026 at 08:59:50AM -0400, Jason Gunthorpe wrote: > > > > > > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > > > > > > > > > > > In adversarial mode the NIC is not trusted. As the kernel protects its > > > > > > own code from it, user space has to protect its own area, e.g. the data > > > > > > path that polls CQEs directly from the HW. > > > > > > > > > > > > Hardened user space might use a different data path, with extra checks, > > > > > > and support a smaller surface. This isn't needed for a trusted NIC, so user > > > > > > space must know when a device is in adversarial mode. > > > > > > > > > > This information is part of trust level series. Why is this a “must” in RDMA UAPI? > > > > > > > > Userspace has to work differently if the kernel driver is in the > > > > adversarial mode, and the kernel should not permit an old non-supporting > > > > rdma-core from loading to prevent a security downgrade. > > > > > > I understand the first part of the sentence above, but the second part is > > > unclear. Why should this prevent it? In adversarial mode, the kernel simply > > > isolates that device from the others. > > > > Userspace needs to do it too or it is not a complete defense. > > > > > Moreover, the kernel cannot determine whether rdma-core has actually been > > > adapted. A locally cloned version of rdma-core can set the new adversarial > > > flag without changing the old, legacy version. > > > > > > Once that flag is set, the kernel allows the patched rdma-core to proceed. > > > Therefore, saying that it “should not permit” this makes no sense. > > > > If someone makes a non-official version of rdma-core that doesn't work > > securely then I don't care one bit. > > > > I care that the official versions are not improperly mismtached to > > give something insecure. > > You explain why rdma-core needs to know about adversarial mode, which is > fine. However, you also say that rdma-core MUST send this new flag back > to justify the statement, “The kernel should not permit an old, > non-supporting ...”. > > However, in your last reply, you said that the kernel does not actually care about > the rdma-core mode. What do you mean? This is a mechanism to help the user manage software versions by not accepting incompatible rdma-cores. It is not a security mechanism to hard guarantee that rdma-core has no bugs. Jason
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Leon Romanovsky
Date: Wed, 25 Nov 2026 09:03
Date: Wed, 25 Nov 2026 09:03
82 lines
11651 bytes
11651 bytes
On Tue, Nov 24, 2026 at 10:30:24AM -0400, Jason Gunthorpe wrote: > On Tue, Nov 24, 2026 at 04:09:06PM +0200, Leon Romanovsky wrote: > > On Tue, Nov 24, 2026 at 09:47:51AM -0400, Jason Gunthorpe wrote: > > > On Tue, Nov 24, 2026 at 03:33:53PM +0200, Leon Romanovsky wrote: > > > > On Tue, Nov 24, 2026 at 08:59:50AM -0400, Jason Gunthorpe wrote: > > > > > > > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > > > > > > > > > > > > > In adversarial mode the NIC is not trusted. As the kernel protects its > > > > > > > own code from it, user space has to protect its own area, e.g. the data > > > > > > > path that polls CQEs directly from the HW. > > > > > > > > > > > > > > Hardened user space might use a different data path, with extra checks, > > > > > > > and support a smaller surface. This isn't needed for a trusted NIC, so user > > > > > > > space must know when a device is in adversarial mode. > > > > > > > > > > > > This information is part of trust level series. Why is this a “must” in RDMA UAPI? > > > > > > > > > > Userspace has to work differently if the kernel driver is in the > > > > > adversarial mode, and the kernel should not permit an old non-supporting > > > > > rdma-core from loading to prevent a security downgrade. > > > > > > > > I understand the first part of the sentence above, but the second part is > > > > unclear. Why should this prevent it? In adversarial mode, the kernel simply > > > > isolates that device from the others. > > > > > > Userspace needs to do it too or it is not a complete defense. > > > > > > > Moreover, the kernel cannot determine whether rdma-core has actually been > > > > adapted. A locally cloned version of rdma-core can set the new adversarial > > > > flag without changing the old, legacy version. > > > > > > > > Once that flag is set, the kernel allows the patched rdma-core to proceed. > > > > Therefore, saying that it “should not permit” this makes no sense. > > > > > > If someone makes a non-official version of rdma-core that doesn't work > > > securely then I don't care one bit. > > > > > > I care that the official versions are not improperly mismtached to > > > give something insecure. > > > > You explain why rdma-core needs to know about adversarial mode, which is > > fine. However, you also say that rdma-core MUST send this new flag back > > to justify the statement, “The kernel should not permit an old, > > non-supporting ...”. > > > > However, in your last reply, you said that the kernel does not actually care about > > the rdma-core mode. > > What do you mean? This is a mechanism to help the user manage software > versions by not accepting incompatible rdma-cores. Please take a look at the patch. User space provides that new adversarial flag. + ret = uverbs_get_flags32(&ctx_flags, attrs, UVERBS_ATTR_GET_CONTEXT_FLAGS, + UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED); + if (ret) + return ret; + + if (ib_dev->adversarial_mode && + !(ctx_flags & UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED)) + return -EPERM; ... + UVERBS_ATTR_FLAGS_IN(UVERBS_ATTR_GET_CONTEXT_FLAGS, u32, + UA_OPTIONAL), The kernel does not care whether rdma-core is up to date. It works either way, so why should we prohibit older userspace on these systems? > > It is not a security mechanism to hard guarantee that rdma-core has no > bugs. It is you who talked about "... security downgrade ...". Thanks > > Jason >
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Jason Gunthorpe
Date: Wed, 25 Nov 2026 14:45
Date: Wed, 25 Nov 2026 14:45
53 lines
13205 bytes
13205 bytes
On Wed, Nov 25, 2026 at 11:03:09AM +0200, Leon Romanovsky wrote: > > What do you mean? This is a mechanism to help the user manage software > > versions by not accepting incompatible rdma-cores. > > Please take a look at the patch. > User space provides that new adversarial flag. > > + ret = uverbs_get_flags32(&ctx_flags, attrs, UVERBS_ATTR_GET_CONTEXT_FLAGS, > + UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED); > + if (ret) > + return ret; > + > + if (ib_dev->adversarial_mode && > + !(ctx_flags & UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED)) > + return -EPERM; > > ... > + UVERBS_ATTR_FLAGS_IN(UVERBS_ATTR_GET_CONTEXT_FLAGS, u32, > + UA_OPTIONAL), What's the issue? If the user space doesn't ACK it has the new software then it doesn't create the context? This is how we do every feature that needs rdma-core support, though more often there is a fallback in the kernel. > The kernel does not care whether rdma-core is up to date. It works either > way, so why should we prohibit older userspace on these systems? What do you mean? + if (ib_dev->adversarial_mode && + !(ctx_flags & UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED)) + return -EPERM; That is not "works either way" that is requiring new software. Which is exactly what I want to see here. > > It is not a security mechanism to hard guarantee that rdma-core has no > > bugs. > > It is you who talked about "... security downgrade ...". Yes, in that I want people using normal software to have a safer more secure experience. Meaning you need supporting rdma-core if the kernel is in adversarial mode, because otherwise you don't get the right security outcome. You took it to some absurd scenario of a user hacking their rdma-core to defeat the check, which is not the point at all. Jason
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Leon Romanovsky
Date: Thu, 26 Nov 2026 14:05
Date: Thu, 26 Nov 2026 14:05
62 lines
10277 bytes
10277 bytes
On Wed, Nov 25, 2026 at 10:45:21AM -0400, Jason Gunthorpe wrote: > On Wed, Nov 25, 2026 at 11:03:09AM +0200, Leon Romanovsky wrote: > > > What do you mean? This is a mechanism to help the user manage software > > > versions by not accepting incompatible rdma-cores. > > > > Please take a look at the patch. > > User space provides that new adversarial flag. > > > > + ret = uverbs_get_flags32(&ctx_flags, attrs, UVERBS_ATTR_GET_CONTEXT_FLAGS, > > + UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED); > > + if (ret) > > + return ret; > > + > > + if (ib_dev->adversarial_mode && > > + !(ctx_flags & UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED)) > > + return -EPERM; > > > > ... > > + UVERBS_ATTR_FLAGS_IN(UVERBS_ATTR_GET_CONTEXT_FLAGS, u32, > > + UA_OPTIONAL), > > What's the issue? If the user space doesn't ACK it has the new > software then it doesn't create the context? > > This is how we do every feature that needs rdma-core support, though > more often there is a fallback in the kernel. > > > The kernel does not care whether rdma-core is up to date. It works either > > way, so why should we prohibit older userspace on these systems? > > What do you mean? > > + if (ib_dev->adversarial_mode && > + !(ctx_flags & UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED)) > + return -EPERM; > > That is not "works either way" that is requiring new software. Which > is exactly what I want to see here. > > > > It is not a security mechanism to hard guarantee that rdma-core has no > > > bugs. > > > > It is you who talked about "... security downgrade ...". > > Yes, in that I want people using normal software to have a safer more > secure experience. Meaning you need supporting rdma-core if the kernel > is in adversarial mode, because otherwise you don't get the right > security outcome. > > You took it to some absurd scenario of a user hacking their rdma-core > to defeat the check, which is not the point at all. No. I'm evaluating each newly added UAPI field passed from userspace to determine whether the kernel needs it. In this case, it does not. The kernel will behave EXACTLY the same with or without this flag. Thanks > > Jason >
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Leon Romanovsky
Date: Thu, 26 Nov 2026 14:12
Date: Thu, 26 Nov 2026 14:12
140 lines
14788 bytes
14788 bytes
On Wed, Nov 25, 2026 at 01:41:50PM +0200, Yishai Hadas wrote: > On 25/11/2026 11:03, Leon Romanovsky wrote: > > On Tue, Nov 24, 2026 at 10:30:24AM -0400, Jason Gunthorpe wrote: > > > On Tue, Nov 24, 2026 at 04:09:06PM +0200, Leon Romanovsky wrote: > > > > On Tue, Nov 24, 2026 at 09:47:51AM -0400, Jason Gunthorpe wrote: > > > > > On Tue, Nov 24, 2026 at 03:33:53PM +0200, Leon Romanovsky wrote: > > > > > > On Tue, Nov 24, 2026 at 08:59:50AM -0400, Jason Gunthorpe wrote: > > > > > > > > > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > > > > > > > > > > > > > > > > > In adversarial mode the NIC is not trusted. As the kernel protects its > > > > > > > > > own code from it, user space has to protect its own area, e.g. the data > > > > > > > > > path that polls CQEs directly from the HW. > > > > > > > > > > > > > > > > > > Hardened user space might use a different data path, with extra checks, > > > > > > > > > and support a smaller surface. This isn't needed for a trusted NIC, so user > > > > > > > > > space must know when a device is in adversarial mode. > > > > > > > > > > > > > > > > This information is part of trust level series. Why is this a “must” in RDMA UAPI? > > > > > > > > > > > > > > Userspace has to work differently if the kernel driver is in the > > > > > > > adversarial mode, and the kernel should not permit an old non-supporting > > > > > > > rdma-core from loading to prevent a security downgrade. > > > > > > > > > > > > I understand the first part of the sentence above, but the second part is > > > > > > unclear. Why should this prevent it? In adversarial mode, the kernel simply > > > > > > isolates that device from the others. > > > > > > > > > > Userspace needs to do it too or it is not a complete defense. > > > > > > > > > > > Moreover, the kernel cannot determine whether rdma-core has actually been > > > > > > adapted. A locally cloned version of rdma-core can set the new adversarial > > > > > > flag without changing the old, legacy version. > > > > > > > > > > > > Once that flag is set, the kernel allows the patched rdma-core to proceed. > > > > > > Therefore, saying that it “should not permit” this makes no sense. > > > > > > > > > > If someone makes a non-official version of rdma-core that doesn't work > > > > > securely then I don't care one bit. > > > > > > > > > > I care that the official versions are not improperly mismtached to > > > > > give something insecure. > > > > > > > > You explain why rdma-core needs to know about adversarial mode, which is > > > > fine. However, you also say that rdma-core MUST send this new flag back > > > > to justify the statement, “The kernel should not permit an old, > > > > non-supporting ...”. > > > > > > > > However, in your last reply, you said that the kernel does not actually care about > > > > the rdma-core mode. > > > > > > What do you mean? This is a mechanism to help the user manage software > > > versions by not accepting incompatible rdma-cores. > > > > Please take a look at the patch. > > User space provides that new adversarial flag. > > > > + ret = uverbs_get_flags32(&ctx_flags, attrs, UVERBS_ATTR_GET_CONTEXT_FLAGS, > > + UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED); > > + if (ret) > > + return ret; > > + > > + if (ib_dev->adversarial_mode && > > + !(ctx_flags & UVERBS_ATTR_GET_CONTEXT_FLAG_ADVERSARIAL_SUPPORTED)) > > + return -EPERM; > > > > ... > > + UVERBS_ATTR_FLAGS_IN(UVERBS_ATTR_GET_CONTEXT_FLAGS, u32, > > + UA_OPTIONAL), > > > > The kernel does not care whether rdma-core is up to date. It works either > > way, so why should we prohibit older userspace on these systems? > > Older userspace is prohibited only in adversarial mode. > > The new attribute is optional on both sides. An older rdma-core doesn't > pass it, and the kernel declares it as UA_OPTIONAL, so > uverbs_get_flags32() returns 0 flags when it's not supplied. > The -EPERM is hit only when ib_dev->adversarial_mode is set. In generic > mode, nothing changes for older userspace. I understand that. I am referring to adversarial_mode, which should allow legacy applications to continue working. Applications that require protected rdma-core can use it directly, without requiring the kernel to check this unnecessary flag. > > In adversarial mode, the kernel side works either way, but the process > doesn't. The threat is the NIC, and rdma-core polls HW-written data > (e.g. CQEs) directly, so an rdma-core that predates this support leaves > the process unprotected. > > The flag doesn't authenticate rdma-core, and isn't meant to. The process > is the one at risk, so it has no reason to claim support it doesn't > have. The check catches a mismatch between official versions, e.g. an > adversarial-mode kernel with an older rdma-core, which would otherwise > run unprotected without anyone noticing. With the check, it fails at > GET_CONTEXT instead. > > > > > > > > > It is not a security mechanism to hard guarantee that rdma-core has no > > > bugs. > > > > It is you who talked about "... security downgrade ...". > > The downgrade is a silent mismatch, where an older rdma-core runs in > adversarial mode without protecting the process from the NIC. Failing > GET_CONTEXT turns this into a visible error. > > Would the below commit message make it clearer ? No, we're discussing the flag sent to the kernel. Once we clear it, I would argue that the flag from the kernel to rdma-core is unnecessary too. Thanks > > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > In adversarial mode the NIC is not trusted. The kernel protects itself, > but user space has to protect its own memory as well, since rdma-core > parses HW-written data, such as CQEs, directly. Hardened user space > might use a different data path with extra checks, so it has to know > when a device is in adversarial mode. > > An rdma-core without this support uses that data without validating > it, so on a device in adversarial mode the process runs without > protection from the NIC, a silent mismatch. Such versions are already > released and can't detect this, so fail GET_CONTEXT in the kernel to > turn the mismatch into a visible error. > > The kernel reports adversarial mode in the GET_CONTEXT core_support, > and user space declares its support with a new optional GET_CONTEXT > flag. In adversarial mode, a GET_CONTEXT without that flag fails. In > generic mode, nothing changes for older user space. > > Yishai > >
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Jason Gunthorpe
Date: Thu, 26 Nov 2026 15:17
Date: Thu, 26 Nov 2026 15:17
28 lines
12502 bytes
12502 bytes
On Thu, Nov 26, 2026 at 04:05:11PM +0200, Leon Romanovsky wrote: > > > > It is not a security mechanism to hard guarantee that rdma-core has no > > > > bugs. > > > > > > It is you who talked about "... security downgrade ...". > > > > Yes, in that I want people using normal software to have a safer more > > secure experience. Meaning you need supporting rdma-core if the kernel > > is in adversarial mode, because otherwise you don't get the right > > security outcome. > > > > You took it to some absurd scenario of a user hacking their rdma-core > > to defeat the check, which is not the point at all. > > No. I'm evaluating each newly added UAPI field passed from userspace to > determine whether the kernel needs it. In this case, it does not. The > kernel will behave EXACTLY the same with or without this flag. Not at all, the kernel will accept an old rdma-core that should not be used in this mode instead of rejecting it. That is not "Exactly" the same and is the behavior this is all intended to create. It is simple version negotiation and since this is security related we do need to do a minimum to help users. Jason
Re: [PATCH V2 rdma-next 21/21] RDMA/core: Report and enforce adversarial mode via GET_CONTEXT
Author: Leon Romanovsky
Date: Thu, 26 Nov 2026 15:57
Date: Thu, 26 Nov 2026 15:57
46 lines
9972 bytes
9972 bytes
On Wed, Nov 25, 2026 at 01:41:50PM +0200, Yishai Hadas wrote: > On 25/11/2026 11:03, Leon Romanovsky wrote: > > On Tue, Nov 24, 2026 at 10:30:24AM -0400, Jason Gunthorpe wrote: > > > On Tue, Nov 24, 2026 at 04:09:06PM +0200, Leon Romanovsky wrote: > > > > On Tue, Nov 24, 2026 at 09:47:51AM -0400, Jason Gunthorpe wrote: > > > > > On Tue, Nov 24, 2026 at 03:33:53PM +0200, Leon Romanovsky wrote: > > > > > > On Tue, Nov 24, 2026 at 08:59:50AM -0400, Jason Gunthorpe wrote: <...> > Would the below commit message make it clearer ? > > RDMA/core: Report and enforce adversarial mode via GET_CONTEXT > > In adversarial mode the NIC is not trusted. The kernel protects itself, > but user space has to protect its own memory as well, since rdma-core > parses HW-written data, such as CQEs, directly. Hardened user space > might use a different data path with extra checks, so it has to know > when a device is in adversarial mode. > > An rdma-core without this support uses that data without validating > it, so on a device in adversarial mode the process runs without > protection from the NIC, a silent mismatch. Such versions are already > released and can't detect this, so fail GET_CONTEXT in the kernel to > turn the mismatch into a visible error. This part is fine for the rdma-core-to-kernel direction. You should also explain why the kernel-to-rdma-core direction is important. The main reason is that rdma-core wants to move away from sysfs files. They are unreliable in RDMA containers, are prone to races with device renaming, and provide no generic way to locate the trust-level sysfs file for an IB device. That file is buried under the device's PCI directory. Thanks > > The kernel reports adversarial mode in the GET_CONTEXT core_support, > and user space declares its support with a new optional GET_CONTEXT > flag. In adversarial mode, a GET_CONTEXT without that flag fails. In > generic mode, nothing changes for older user space. > > Yishai > >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads