From: sashiko-bot@kernel.org
To: "Mina Almasry" <almasrymina@google.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH net v1 4/4] selftests: net: add devmem RX and TX netdev unregister tests
Date: Sun, 11 Oct 2026 02:55:43 +0000 [thread overview]
Message-ID: <sashiko-outbox-166987@kernel.org> (raw)
In-Reply-To: <20261010025532.839559-5-almasrymina@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] selftests: net: global dmabuf debugfs parsing causes spurious test failures
- [Low] selftests: net: resource leak on exception in devmem unregister tests
--
commit 920bd7824b195d91554d5afd53f2bc33d3bbf933
Author: Mina Almasry <almasrymina@google.com>
Subject: selftests: net: add devmem RX and TX netdev unregister tests
This commit adds devmem_bind_rx_unregister_check and
devmem_bind_tx_unregister_check to verify that unregistering a netdevsim
device synchronously detaches dma_buf attachments. It ensures netlink
sockets close cleanly without page faults or use-after-free bugs.
> diff --git a/tools/testing/selftests/net/nl_netdev.py b/tools/testing/selftests/net/nl_netdev.py
> index ceb44c8e1fec5..bad230ee9dcd2 100755
> --- a/tools/testing/selftests/net/nl_netdev.py
> +++ b/tools/testing/selftests/net/nl_netdev.py
[ ... ]
> +def _dmabuf_attached_devs():
> + """Return attached device names from debugfs dma_buf/bufinfo if available."""
> + path = "/sys/kernel/debug/dma_buf/bufinfo"
> + if not os.path.exists(path):
> + return None
> + with open(path, "r", encoding="utf-8") as f:
> + text = f.read()
> + attached = []
> + in_attached = False
> + for line in text.splitlines():
> + if line.strip() == "Attached Devices:":
> + in_attached = True
> + continue
> + if in_attached:
> + if line.startswith("\t") and line.strip():
> + attached.append(line.strip())
> + else:
> + in_attached = False
[Severity: Medium]
Will this loop blindly accumulate attached devices for all dma_bufs
system-wide without filtering by inode or specific fd?
If there are other active dma_bufs on the system, such as from DRM or V4L2
workloads, it looks like their attachments would all be unconditionally
appended to this global list.
> + return attached
> +
> +
> +def devmem_bind_rx_unregister_check(_nf) -> None:
> + """Verify RX devmem bindings detach dma_buf synchronously on netdev unregister."""
> + dmabuf_fd = _create_udmabuf()
> + nf_priv = NetdevFamily()
> + ef = EthtoolFamily()
> + nsimdev = NetdevSimDev(queue_count=2)
> + nsim = nsimdev.nsims[0]
> +
> + ip(f"link set dev {nsim.ifname} up")
[Severity: Low]
If a test helper like ip() or nf_priv.bind_rx() raises an exception, will
these resources be permanently leaked?
The file descriptor from _create_udmabuf() and the NetdevSimDev are created
but do not appear to be protected by defer(). If an exception occurs, it
could skip the manual cleanup calls at the end of the function.
> + ef.rings_set({"header": {"dev-index": nsim.ifindex},
> + "tcp-data-split": "enabled"})
> + nf_priv.bind_rx({
> + "ifindex": nsim.ifindex,
> + "fd": dmabuf_fd,
> + "queues": [{"id": 1, "type": "rx"}],
> + })
> +
> + attached = _dmabuf_attached_devs()
> + if attached is not None:
> + ksft_ge(len(attached), 1)
> +
> + nsimdev.remove()
> +
> + attached = _dmabuf_attached_devs()
> + if attached is not None:
> + ksft_eq(len(attached), 0)
[Severity: Medium]
Because _dmabuf_attached_devs() aggregates attachments system-wide, does
this make the test exceedingly brittle?
If any unrelated dma_buf has attachments, this assertion could incorrectly
fail and cause spurious test failures in CI environments.
> +
> + del nf_priv
> + os.close(dmabuf_fd)
> +
> +
> +def devmem_bind_tx_unregister_check(_nf) -> None:
> + """Verify TX devmem bindings detach cleanly on netdev unregister without UAF."""
> + dmabuf_fd = _create_udmabuf()
> + nf_priv = NetdevFamily()
> + nsimdev = NetdevSimDev(queue_count=2)
> + nsim = nsimdev.nsims[0]
> +
> + ip(f"link set dev {nsim.ifname} up")
[Severity: Low]
Similar to the RX test above, does this code leak the simulated netdev and
file descriptor if an exception is raised before the manual cleanup?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261010025532.839559-1-almasrymina@google.com?part=4
next prev parent reply other threads:[~2026-10-11 2:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 2:55 [PATCH net v1 0/4] net: devmem: fix RX and TX binding teardown on device unregistration Mina Almasry
2026-10-10 2:55 ` [PATCH net v1 1/4] net: devmem: unmap dma_buf synchronously on queue uninstall Mina Almasry
2026-10-10 14:02 ` Pavel Begunkov
2026-10-11 3:38 ` netdev-bot+sashiko
2026-10-11 15:51 ` Mina Almasry
2026-10-10 2:55 ` [PATCH net v1 2/4] net: devmem: detach TX bindings on NETDEV_UNREGISTER Mina Almasry
2026-10-11 3:38 ` netdev-bot+sashiko
2026-10-12 16:57 ` Stanislav Fomichev
2026-10-10 2:55 ` [PATCH net v1 3/4] netdevsim: support devmem RX and TX bindings Mina Almasry
2026-10-11 2:55 ` sashiko-bot
2026-10-11 3:38 ` netdev-bot+sashiko
2026-10-10 2:55 ` [PATCH net v1 4/4] selftests: net: add devmem RX and TX netdev unregister tests Mina Almasry
2026-10-11 2:55 ` sashiko-bot [this message]
2026-10-11 3:38 ` netdev-bot+sashiko
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=sashiko-outbox-166987@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=almasrymina@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=media-ci@linuxtv.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.