Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jiri Pirko" <jiri@resnulli.us>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
	tj@kernel.org, mkoutny@suse.com, hannes@cmpxchg.org,
	"Heiko Carstens" <hca@linux.ibm.com>,
	linux-s390@vger.kernel.org,
	"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH rdma-next v2 11/14] RDMA/core: Make device names unique per net namespace
Date: Wed, 15 Jul 2026 14:30:44 +0000	[thread overview]
Message-ID: <20260715143044.E91711F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714142927.1298897-12-jiri@resnulli.us>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Format String Vulnerability / Arbitrary Memory Write
--

--- Patch [11]: [PATCH rdma-next v2 11/14] RDMA/core: Make device names unique per net namespace ---
commit db3597c8065e66f96858593e01ba04bca7a7d075
Author: Jiri Pirko <jiri@nvidia.com>

RDMA/core: Make device names unique per net namespace

This commit updates RDMA device name lookups and index allocations to be
scoped within the relevant net namespace. It uses rdma_dev_access_netns()
to ensure name uniqueness per namespace while maintaining system-wide
behavior in shared mode.

> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c

[ ... ]

> @@ -452,7 +457,7 @@ static int __alloc_name_id(struct net *net, const char *name,
>  	xa_for_each (&devices, index, device) {
>  		char buf[IB_DEVICE_NAME_MAX];
>  
> -		if (device == skip)
> +		if (device == skip || !rdma_dev_access_netns(device, net))
>  			continue;
>  		if (sscanf(dev_name(&device->dev), name, &i) != 1)
>  			continue;

[Severity: Critical]
This isn't a bug introduced by this patch, but is it possible that the
sscanf call here is vulnerable to a format string injection?

Since name can be user-supplied via the RDMA_NLDEV_CMD_NEWDEV netlink
command in nldev_newdev() and is copied without checking for '%' characters:

drivers/infiniband/core/nldev.c:nldev_newdev() {
        ...
        nla_strscpy(name, tb[RDMA_NLDEV_ATTR_DEV_NAME], sizeof(name));
        ...
}

The string is passed down through ib_register_device() and assign_name()
into __alloc_name_id(). Could a user with CAP_NET_ADMIN supply a malicious
format string containing format specifiers like %n?

If an attacker sets up a device with a matching prefix, sscanf would
parse the attacker's format string and write to memory addresses beyond
the supplied &i pointer.

Since CAP_NET_ADMIN can be acquired within a user namespace, could this
allow unprivileged local attackers to corrupt memory and trigger an
arbitrary memory write?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260714142927.1298897-1-jiri@resnulli.us?part=11

  reply	other threads:[~2026-07-15 14:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 14:29 [PATCH rdma-next v2 00/14] RDMA: Make device names unique per net namespace Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 01/14] RDMA/core: Pass the net namespace to the device name lookups Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 02/14] RDMA/core: Handle device name conflicts when changing net namespace Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 03/14] RDMA/core: Support renaming a device when changing its " Jiri Pirko
2026-07-15 14:30   ` sashiko-bot
2026-07-14 14:29 ` [PATCH rdma-next v2 04/14] RDMA/nldev: Report net namespace move errors through extack Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 05/14] RDMA/nldev: Allow setting the device name while changing net namespace Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 06/14] net/smc: Look up the pnetid ib device within the " Jiri Pirko
2026-07-15 14:30   ` sashiko-bot
2026-07-14 14:29 ` [PATCH rdma-next v2 07/14] RDMA/srp: Make the SRP sysfs class net namespace aware Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 08/14] RDMA/cgroup: Disambiguate devices across net namespaces Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 09/14] RDMA/cma: Document that CM configfs cannot be net namespace scoped Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 10/14] RDMA/core: Document the SELinux ibendport net namespace limitation Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 11/14] RDMA/core: Make device names unique per net namespace Jiri Pirko
2026-07-15 14:30   ` sashiko-bot [this message]
2026-07-14 14:29 ` [PATCH rdma-next v2 12/14] RDMA/rxe: Allow queue VMAs to outlive ucontexts Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 13/14] RDMA/rxe: Implement disassociate_ucontext callback Jiri Pirko
2026-07-14 14:29 ` [PATCH rdma-next v2 14/14] RDMA/selftests: Add rxe_netns_names test Jiri Pirko
2026-07-15 14:30   ` sashiko-bot

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=20260715143044.E91711F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hannes@cmpxchg.org \
    --cc=hca@linux.ibm.com \
    --cc=jiri@resnulli.us \
    --cc=linux-s390@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tj@kernel.org \
    /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