Article View: linux.kernel.netdev
Article #27552Re: [PATCH net-next v5 4/6] net: devmem: synchronize and unmap all device bindings on unregister
From: netdev-bot+sashiko
Date: Sun, 06 Dec 2026 00:07
Date: Sun, 06 Dec 2026 00:07
126 lines
12606 bytes
12606 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] Issue #1 in the commit message is not a real defect, and the new
synchronize_net() does not change what can happen.
--
net: devmem: synchronize and unmap all device bindings on unregister
This commit splits net_devmem_dev_unregister() into two passes with one
synchronize_net() between them. The first pass clears binding->vdev and
the NET_DEVMEM_BINDING_LIVE mark. The second pass unmaps every binding
whose binding->dev matches the unregistering device, including RX
bindings that still had LIVE set, and drops the netif_is_queue_leasee()
check.
> 1. For TX bindings, it clears NET_DEVMEM_BINDING_LIVE and immediately
> calls net_devmem_dmabuf_binding_unmap() without waiting for an RCU
> grace period, racing with in-flight net_devmem_get_binding() lookups
> (both direct on dev and leased via binding->vdev).
[ ... ]
> diff --git a/net/core/devmem.c b/net/core/devmem.c
> index 3a894ff06b32b..a395f100d2f33 100644
> --- a/net/core/devmem.c
> +++ b/net/core/devmem.c
[ ... ]
> + xa_unlock(&net_devmem_dmabuf_bindings);
> +
> + if (!unmap)
> + return;
> +
> + /* Ensure no tx net_devmem_get_binding() are in flight after the
> + * mark is cleared.
> + */
> + synchronize_net();
>
> - xa_unlock(&net_devmem_dmabuf_bindings);
> - if (!netif_is_queue_leasee(dev))
> + xa_lock(&net_devmem_dmabuf_bindings);
> + xa_for_each(&net_devmem_dmabuf_bindings, xa_idx, binding) {
> + if (READ_ONCE(binding->dev) == dev) {
> + xa_unlock(&net_devmem_dmabuf_bindings);
> net_devmem_dmabuf_binding_unmap(binding);
[Severity: Low]
Is the race in item 1 of the changelog accurate? The changelog doesn't
say what goes wrong when the unmap happens right after the LIVE mark is
cleared.
net_devmem_get_binding() reads the xarray entry, the LIVE mark, tx_vec,
net and uid. It compares the dev/vdev pointers and then takes a ref:
net/core/devmem.c:net_devmem_get_binding() {
...
if (unlikely(!dst_dev) ||
unlikely(dst_dev != READ_ONCE(binding->dev) &&
dst_dev != READ_ONCE(binding->vdev))) {
err = -ENODEV;
goto out_unlock;
}
if (!net_devmem_dmabuf_binding_get(binding)) {
...
}
It never reads binding->sgt or binding->attachment. Those are the only
fields net_devmem_dmabuf_binding_unmap() tears down.
A lookup that completed before __xa_clear_mark() also still returns a
referenced binding. tcp_sendmsg_locked() keeps using it until
net_devmem_dmabuf_binding_put(), and that can be after this second pass
has unmapped it, with or without the new synchronize_net(). So waiting
for in-flight lookups doesn't seem to change whether a binding can be
used after it is unmapped.
What keeps this safe looks the same as before the patch. The device is
already closed by the time reg_state is NETREG_UNREGISTERING. Also,
validate_xmit_unreadable_skb() drops skbs whose binding->dev no longer
matches, and this pass sets binding->dev to NULL:
net/core/dev.c:validate_xmit_unreadable_skb() {
...
if (net_is_devmem_iov(niov) &&
(net_devmem_iov_binding(niov)->direction != DMA_TO_DEVICE ||
READ_ONCE(net_devmem_iov_binding(niov)->dev) != dev))
goto out_free;
...
}
This also goes against commit ede1618064a9 ("net: devmem: detach TX
bindings on NETDEV_UNREGISTER"), which said:
No grace period is needed: the device is already closed, so nothing
hands the DMA addresses to the hardware anymore, and concurrent
senders only compare against binding->dev.
The changelog doesn't say why that reasoning no longer holds.
The v4 -> v5 notes say the barrier was added at a reviewer's request.
Could the commit message and the comment above synchronize_net() say
what it actually guarantees, which is that no new TX references are
taken after this point? As written, they suggest it closes a hazard
with the unmap. Later patches in the series leave this code unchanged.
> - xa_lock(&net_devmem_dmabuf_bindings);
> - WRITE_ONCE(binding->dev, NULL);
> + xa_lock(&net_devmem_dmabuf_bindings);
> + WRITE_ONCE(binding->dev, NULL);
> + }
> }
> xa_unlock(&net_devmem_dmabuf_bindings);
> }
[ ... ]
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204231030.3815575-1-almasrymina%40google.com
Technical Details
Message-ID:
<179651566257.3148.13711388561537542637@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378189-linux-kernel-netdev=dewy.ruReferences:
<20261204231030.3815575-5-almasrymina@google.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378189-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v5 4/6] net: devmem: synchronize and unmap all device bindings on unregister Date: Sun, 06 Dec 2026 00:07:42 +0000 Organization: Usenet Network Message-ID: <179651566257.3148.13711388561537542637@kernel.org> References: <20261204231030.3815575-5-almasrymina@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3148191"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:X4j6lhyPrgxG++BHazoWSRheCuQ= sha256:wsNRHNJGCJuMdLP4DxvhEwLT5lqZAI4sMSLAr0G47RM= sha1:44qKb9eTQdJEXbliaMkeUPIURyA= sha256:g+ZyW1B242inEpB7kTmnNIu1P294NW4dPDf7L6i0WYE= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 5F575117ECA; Sun, 6 Dec 2026 03:08:00 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.64 X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Xb_fq_MJv0IK; Sun, 6 Dec 2026 03:07:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-378189-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 25A6C117EFC; Sun, 6 Dec 2026 03:07:47 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 08CA229135; Sun, 6 Dec 2026 00:07:46 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796515665; b=0zVuyH2CJy1SnehxmyeK0rq5PSowbKthZclch7fxezdgvOrUNlSESsEAeHsEvyx3Jfrf erkiuCZaC9BkGczxCJgAqDrSCxaEogNXZFrTm0xJUlgxncQOCSb4/eG0W5JTWUNgTwnr+ Ol68iVZjZ5axm3qh1oXuQnnBSdUpwFL1urljdPSED779CXMhqR1z7x3jdqW3yr4Ex0Kol rrgxqMzApPlltzv9T53j2+2pTAAxYWxVCIx33+gz0Pt6XRQe3/R0GE4mEk+kvp/DXD7ff 8NJD+7HOGI5mElW8jlkHZQUSfHEUT/KHj/z1/zryGrUHhB4SRObU/QPTmOdgLZBTheQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796515665; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=URGnOM0EI0EtcSw3Nlsx6IkODxn07SrX0PuVEFd+NGw=; b=nuR+RbWNKbPZ7WoHjbJrBQeOrbr8NActhY0J9z+2u0IF8tMEna/PjsYptm7LWybSKoN9 zjJA1xP9gdjI2Y9lW0ZJseXI63bBsoUxXXUF0qImm+RCHLSFHz/tZCj5W3M8I677zCQ3c /ixTJLTIZEzHIsOOnIM3zzx5dZ02sX3yiadQCzHVsbPrRD078fwPJtOCpLconKzLr1x6x gykyhleTFbRyxMqQeM+ExrGRni6AVv4jPAhKXX29veJXUkTxxEZ3NFdBRvBJcstqubjwq KoB/Atoc/oiZtwA3mJwEHfCfXECCLs6C+Uh1Gl5YmhXiUo6P/bo/DxQl0la/wgIUxJA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eWBRjVuy; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27096606A33C; Sun, 6 Dec 2026 00:07:45 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eWBRjVuy X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796515664; b=bhJyAl911hWLZN6ChFxu7GMfMrKOJwnn919jpSK2an0xvR39rl0GgQCsVvViQAPSA9g5 prh8GFEVyLOelZQOuzKBtpwNbK96dzClt/h7ad6jFN8fDESeERcVw/qI1wJJGlgT0+2Au rTxkt+vOqLKhdgEP8o0q+6g4BP7PjTgz+0rnH9UgDw6IMJT8wAq+nqdjYCZh6WW1RwGAp mK/RA8mcCUKwKklRRTzkqk/6IERohO/fZ2EcvzBhehHLI55d3Jg/1WtTyILKjyXzQCZBM REwAcIAhaqRqRrwbhfzXlmP56zJ9gffSmhEqEbfVpoHUoKEZUcLsbco8j9LnmFIA4Fw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796515664; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=URGnOM0EI0EtcSw3Nlsx6IkODxn07SrX0PuVEFd+NGw=; b=JbpNjecXcTam+2H/tna4AH/A6EjbDkJ/5BE2+QUla8bbV+nqFuDa4rhbB+5V2c6KOEPZ 8cPSMqU+GwclO4YNp1hAhhNHamtpx1BTqnf+pmLS0SXIea607UFKqdtp4JdM9ssRwkqsl ttc4KOQsxvfox39BJ5zlJmt30dl44rklK/2QFMNzmWrI9jpOu+evEoWo0aCWnRz/jZyTM M6Wq5STBnBretz56w3NLovc9orRIU1kpXpgCuLQZwyEjV/zjtDkd87BFg2LuD1qKUvFSq /40xgXkvuXrskoF2OKzkJa7bpEXMIIaWMacFFNU0FO2AxFOT7mkGB8npmnKlBPpSteA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eWBRjVuy; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41F6F606A32F; Sun, 6 Dec 2026 00:07:44 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 042481F0092B; Sun, 6 Dec 2026 00:07:42 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796515664; bh=URGnOM0EI0EtcSw3Nlsx6IkODxn07SrX0PuVEFd+NGw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=eWBRjVuyX2OvM754yqFOMq4YbLUQyGUaVcZuWOVKNlNIfMT5Lvj0LPYhxbz+D4GtX r7qi8hy3I8Iv4/nNhCCA6Ggq8Tu71hZhzouXpQslIPZvuUJWu0KqtL6PAs72XlZvx4 kZadeCOXwvtRdRDuO+/DlfCZEbdQhU7H3XFDUlPkrgAbBywI741HrHAu4X+wXf9v4s wZ4TEM6bXYrMIBdTorWZANPWvFTIzNsv/exkWu/QEvT+7/kLhr53VqKiCRPKqyFrYb 0cSt3XmCR2B057t7vEmhZ20Ia0e097/kKNzda6CpLIxEZG3ajIgERKLIYBSHT0NtXQ TA3fgBMeFOEtQ== X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org, sdf.kernel@gmail.com, bobbyeshleman@meta.com, razor@blackwall.org, daniel@iogearbox.net, dw@davidwei.uk, asml.silence@gmail.com, axboe@kernel.dk, bestswngs@gmail.com, io-uring@vger.kernel.org, hawk@kernel.org, ilias.apalodimas@linaro.org X-In-Reply-To: <20261204231030.3815575-5-almasrymina@google.com> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list