From: Leon Romanovsky <leon@kernel.org>
To: "david.lenrow@illumio.com" <david.lenrow@illumio.com>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"yishaih@nvidia.com" <yishaih@nvidia.com>,
"jgg@nvidia.com" <jgg@nvidia.com>
Subject: Re: [RFC PATCH] libibverbs: add authorization plugin hook for QP creation
Date: Mon, 16 Nov 2026 15:28:58 +0200 [thread overview]
Message-ID: <20261116132858.GN11319@unreal> (raw)
In-Reply-To: <DS0PR06MB11128BECCB1916D97FFC8372D9F7D2@DS0PR06MB11128.namprd06.prod.outlook.com>
On Sun, Nov 15, 2026 at 03:38:54PM +0000, david.lenrow@illumio.com wrote:
> Hi,
>
> I'd like to propose adding an optional authorization hook to
> ibv_create_qp in libibverbs.
>
> ibv_create_qp dispatches directly to the provider with no
> interposition point. Other parts of the stack have grown
> optional policy hooks over time, but QP creation — the point
> at which a process gains the ability to issue RDMA operations —
> has none.
>
> Multi-tenant clusters and shared-fabric deployments increasingly
> need a way to enforce workload identity or access policy at QP
> creation time. Today the only options are kernel-level hooks
> (eBPF, LSM) or LD_PRELOAD interposition, both of which have
> deployment and portability costs that a simple in-library plugin
> point would avoid.
1. Your email didn't reach the mailing list; you may have sent it as HTML.
2. There must be a very good reason to duplicate existing functionality in
libibverbs. Deployment and portability costs aren't it.
Thanks
>
> Proposed change:
>
> A new environment variable IBV_AUTH_PLUGIN. When set to a
> shared library path, libibverbs dlopen's it once (via
> pthread_once) and calls its exported symbol before every
> ibv_create_qp dispatch:
>
> int ibv_auth_check_qp_create(struct ibv_pd *pd,
> struct ibv_qp_init_attr *attr);
>
> Returns 0 to allow, non-zero to deny (ibv_create_qp returns
> NULL with errno = EPERM).
>
> When IBV_AUTH_PLUGIN is unset, the overhead is one pthread_once
> (a memory barrier after the first call) and one NULL pointer
> check. No new exported symbols, no ABI change, no functional
> change for existing users.
>
> I chose a plugin over a built-in policy because the right
> policy varies by deployment — cgroup-based identity on
> Kubernetes, namespace checks on shared clusters, site-specific
> allowlists on bare metal. libibverbs should not embed any of
> these; it just needs the hook.
>
> I've tested this on SoftRoCE with a plugin that checks the
> calling process's cgroup ID against an allowlist. Five test
> cases pass: no plugin (baseline), allowed, denied, empty
> allowlist, and invalid plugin path (graceful fallthrough).
>
> The patch is below. I'll open a GitHub PR once I have feedback
> on the approach.
>
> Questions for maintainers:
>
> 1. Is an env-var-triggered dlopen plugin acceptable, or would
> you prefer a different configuration mechanism (e.g., a
> config file in /etc/libibverbs.d/)?
>
> 2. Should this also cover ibv_create_qp_ex? The same pattern
> applies; I kept the initial patch minimal.
>
> 3. Any concerns about the dlopen happening inside pthread_once
> on the ibv_create_qp path? It runs exactly once, but it
> is on the first call.
>
> Thanks,
> Dave Lenrow
> Illumio
>
> ---
>
> libibverbs/verbs.c | 57 +++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 56 insertions(+), 1 deletion(-)
>
> diff --git a/libibverbs/verbs.c b/libibverbs/verbs.c
> index 1959fcf..7390605 100644
> --- a/libibverbs/verbs.c
> +++ b/libibverbs/verbs.c
> @@ -54,6 +54,8 @@
> #include <net/if.h>
> #include <net/if_arp.h>
> #include "neigh.h"
> +#include <dlfcn.h>
> +#include <pthread.h>
>
> #undef ibv_query_port
>
> @@ -916,12 +918,65 @@ LATEST_SYMVER_FUNC(ibv_destroy_srq, 1_1, "IBVERBS_1.1",
> return get_ops(srq->context)->destroy_srq(srq);
> }
>
> +/*
> + * Optional authorization plugin for QP creation.
> + *
> + * When IBV_AUTH_PLUGIN names a shared library, it is dlopen'd once and
> + * its ibv_auth_check_qp_create() symbol is called before every
> + * ibv_create_qp(). Returns 0 to allow, negative errno to deny.
> + *
> + * When the variable is unset, the overhead is a pthread_once and a
> + * NULL check per ibv_create_qp call.
> + */
> +typedef int (*ibv_auth_check_fn)(struct ibv_pd *pd,
> + struct ibv_qp_init_attr *attr);
> +
> +static ibv_auth_check_fn auth_check;
> +static pthread_once_t auth_once = PTHREAD_ONCE_INIT;
> +
> +static void auth_init(void)
> +{
> + const char *plugin_path;
> + void *handle;
> +
> + plugin_path = getenv("IBV_AUTH_PLUGIN");
> + if (!plugin_path || !*plugin_path)
> + return;
> +
> + handle = dlopen(plugin_path, RTLD_NOW | RTLD_LOCAL);
> + if (!handle) {
> + fprintf(stderr, "IBV_AUTH_PLUGIN: cannot load %s: %s\n",
> + plugin_path, dlerror());
> + return;
> + }
> +
> + auth_check = (ibv_auth_check_fn)dlsym(handle,
> + "ibv_auth_check_qp_create");
> + if (!auth_check)
> + fprintf(stderr, "IBV_AUTH_PLUGIN: %s missing "
> + "ibv_auth_check_qp_create symbol\n",
> + plugin_path);
> +}
> +
> LATEST_SYMVER_FUNC(ibv_create_qp, 1_1, "IBVERBS_1.1",
> struct ibv_qp *,
> struct ibv_pd *pd,
> struct ibv_qp_init_attr *qp_init_attr)
> {
> - struct ibv_qp *qp = get_ops(pd->context)->create_qp(pd, qp_init_attr);
> + struct ibv_qp *qp;
> +
> + pthread_once(&auth_once, auth_init);
> +
> + if (auth_check) {
> + int rc = auth_check(pd, qp_init_attr);
> +
> + if (rc) {
> + errno = EPERM;
> + return NULL;
> + }
> + }
> +
> + qp = get_ops(pd->context)->create_qp(pd, qp_init_attr);
>
> return qp;
> }
> --
> 2.43.0
>
parent reply other threads:[~2026-11-16 13:29 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <DS0PR06MB11128BECCB1916D97FFC8372D9F7D2@DS0PR06MB11128.namprd06.prod.outlook.com>]
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=20261116132858.GN11319@unreal \
--to=leon@kernel.org \
--cc=david.lenrow@illumio.com \
--cc=jgg@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=yishaih@nvidia.com \
/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