๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27554

Re: [PATCH net-next v5 3/6] net: devmem: resolve leased RX queues to physical device on bind

#27554
From: netdev-bot+sashiko
Date: Sun, 06 Dec 2026 00:07
78 lines
11210 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] Commit "net: devmem: resolve leased RX queues to physical device
  on bind" fixes a memory-safety bug in leased-queue devmem RX teardown,โ€ฆ

--

net: devmem: resolve leased RX queues to physical device on bind

At bind-rx time, this commit resolves leased RX queues to the physical
net_device and its physical rx_queue indices. It holds
netdev_lock(virt_dev) and then netdev_lock(phys_dev) across the DMA
device lookup, the dmabuf mapping and the queue opens.

phys_dev and phys_rxq are stored in the binding so that teardown paths
serialize on the physical device lock. The rxq->mp_params clearing moves
into __netif_mp_uninstall_rxq().

> - When the physical device unregisters first,
>   dev_memory_provider_uninstall(phys_dev) passes phys_rxq to
>   mp_dmabuf_devmem_uninstall(), which searches binding->bound_rxqs for
>   virt_rxq, fails to match, and leaves the dmabuf mapped.

[ ... ]

> These issues were identified by code inspection and selftest development
> while extending devmem unregister teardown to leased queues; they have not
> been observed in production or tested on real hardware. Verified with
> netdevsim and netkit selftests in nl_netdev.py and nk_qlease.py.

[Severity: Low]
Does "leaves the dmabuf mapped" cover the full consequence here? And
should this patch carry Fixes: tags?

Before this patch, when the physical device unregisters first, the
cascaded unlease path is the one that matches virt_rxq:

netif_rxq_cleanup_unlease(phys_rxq, virt_rxq)
  __netif_mp_uninstall_rxq(virt_rxq, &p)
    mp_dmabuf_devmem_uninstall(binding, virt_rxq)

That call empties bound_rxqs and clears binding->dev. It skips the unmap
because virt_rxq->lease is still set:

		if (xa_empty(&binding->bound_rxqs)) {
			if (!rxq->lease)
				net_devmem_dmabuf_binding_unmap(binding);
			ASSERT_EXCLUSIVE_WRITER(binding->dev);
			WRITE_ONCE(binding->dev, NULL);
		}

net_devmem_dev_unregister() does not unmap it either. binding->dev does
not match phys_dev, and the leasee device is skipped.

So the dma_buf attachment stays mapped while the physical dma_dev is
freed. When the netlink socket is closed later, this call chain would run
against the freed device:

__net_devmem_dmabuf_binding_free()->dma_buf_unmap_attachment()

This looks like the same slab-use-after-free in dma_unmap_sg_attrs()
that KASAN caught in commit c4466d2c3e77 ("net: devmem: unmap dma_buf
synchronously on queue uninstall").

Could the commit message describe this as a use-after-free rather than a
mapping leak? Tags like these would also let stable trees that carry the
queue lease support pick it up:

Fixes: 5602ad61ebee ("net: Proxy netif_mp_{open,close}_rxq for leased queues")
Fixes: c4466d2c3e77 ("net: devmem: unmap dma_buf synchronously on queue uninstall")

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204231030.3815575-1-almasrymina%40google.com
Technical Details
Message-ID: <179651566095.3148.8405401259463150987@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.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-378188-linux-kernel-netdev=dewy.ru
References: <20261204231030.3815575-4-almasrymina@google.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.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-378188-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v5 3/6] net: devmem: resolve leased RX queues to
 physical device on bind
Date: Sun, 06 Dec 2026 00:07:40 +0000
Organization: Usenet Network
Message-ID: <179651566095.3148.8405401259463150987@kernel.org>
References: <20261204231030.3815575-4-almasrymina@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3148323"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6YrOs8j1vPXbVQbGPQ3hyHchTds= sha256:B74rqvxOyxd+iyJ89Swz7neHX3um2t4/Q8H26UUjwvM=
	sha1:0ds92Gum1JleZyy15/1yptCtvAc= sha256:ELY+TWwu2QiLL1P2vG0zs1RcJuQjQmaK0h/kRJruaJw=
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 2169F117E93; Sun,  6 Dec 2026 03:08:10 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.54
X-Spam-Status: No, score=-3.54 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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 8iDhRnMdX5ra;
	Sun,  6 Dec 2026 03:08:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-378188-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 24E53117EF5; Sun,  6 Dec 2026 03:07:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id BD0CC32801; Sun,  6 Dec 2026 00:07:48 +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=1796515668;
	b=ym8MMhjTUyGNZRLSE6/G3C9OyAgWolxJTpbt117pXagjGWC+RQQ7UlZjxt7fz2giF0cQ
	 8+jMvA9QbbfnBIRWmYX+TfNkGMREssxYrpsiKnOomHphxe0clqtBDfwOg1gzcSe37DSEv
	 vB9jQGpgd4ENJTQVfcBokLb1OzADwegPC/oOBx0sFFiQ1HIHBnDAMZixy5Hvb3UzjnEIE
	 T4RycCUkV5NbIeC6e0deGplQp4H3lTaXOd3hm5wuB114X6GSwz0uNk4VfX9Ad+Y64vwRC
	 HAzr8ZHVzYNBp3uaj6KHVxh/zgEj3GYcjoU0hzGvR/xco+S/2DtDgXfvvkqYI9naHSA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796515668;
	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=IoULUEIeopIiXjerg/UhmxVN08W2QRQ+GdkyXWisfDM=;
	b=T8/riQZc/czyO6oJHNJz6MzU+iTbPtGmbysS8l3BBpwy0UIzdYjocxNVqApBIJiiSnRd
	 xH+ZyKp54Qzkjvf0NRqKH/nJed0tIvu3etxNsVpNIEwTO40vXSaaJXLxRiqPx2Hy/6J2O
	 luLIPNwgC84TejLVC3jqG5lBUde+kUnjXmxGC/WOWvm8uk9Y3urlmixi8Aw6hdq9th4YN
	 aTjc7CtwFt5IVNvLlYjdyXVUiE30peZuko6+TXIkbmKa+dcso3bYeHtpLpRBS3/BMq/7E
	 91a1VMOLAi1g3z/yV+CkNqoZoMSTrfQhKho1ZyB+L1CEEHZE2Lyg9/PxiODQDmw9kZA==
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=WaamGbfZ;
	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 968C9606A33A;
	Sun,  6 Dec 2026 00:07:48 +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=WaamGbfZ
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=1796515662;
	b=YjCR4ikBXlcjayx53VecbHNtI9egy0sxLqCPDIeX/dxONeLrYY7+qCkUQlaqgpH7Cn1J
	 jsTrm4q0yc02dxoUnK6f3qlnAdmz2Q1KKxkXqG9kjX7LxUJ+Qu6BLmbwhOBMgOsKl5RLz
	 txdZwo1/7b3Wr8khURJEqh6DricjdG+ZvhgTN/LmJkpsjz0WpK8sTLuOCyiF3BEUYYugf
	 YbcpM9nQBvuejp5nBCeB/Nl87lSus7diwvyBnzb140oGVmEd7KQP/Agp7Dth+A7zQPn1n
	 e4JBgMbe7IbWhyZ52TFWofRV6a9WxmHCjjhH7mPdnuWksB+xeLGEDM9UBFt3VqGuZRA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796515662;
	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=IoULUEIeopIiXjerg/UhmxVN08W2QRQ+GdkyXWisfDM=;
	b=uMAXk2PC64Jgkc5JBGxQry70h3AbfNQAxoBm0ZVD7ccE4LfLCc7R5F7qSWMEnQllVM+o
	 x22fTKVlGO7xUqQfg+nPesI51Imp3IdS32GryNm44XYpgMZ8gHMdkqvGEQvSydbjz4gjL
	 8YWVw3zD6ab/RLhLhcnUZ3XICBkQJkeC7CvFCfnBGumHdgVCokJUPQbzT5f+piHkfJLKM
	 7Q60d6DIolH3n2SQAwHFC7CpNnusoLmAg3AOz70kt7l+G3fkANsuaq8nOUYhBWTM3504p
	 kUB8LzAjpVaa4A7iOP421CdFCxq1xPFgivIhLsvkhMJJ6u9c1m417/FZZFQgBjSpW0g==
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=WaamGbfZ;
	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 B63DF606A31F;
	Sun,  6 Dec 2026 00:07:42 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D6DB1F0092B;
	Sun,  6 Dec 2026 00:07:41 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796515662;
	bh=IoULUEIeopIiXjerg/UhmxVN08W2QRQ+GdkyXWisfDM=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=WaamGbfZ3vNlM1Sj1VZ5xwCxoceiFEcEAuEp4MauX7h/IN4cfzRXO3kXBbEIyLhEG
	 j1UWvni2Cl1Q8TVy8RkxqRUmDZi1wjX2P9IzJjhA7Vk9uxPZ1sacb472jkbHTh7FXW
	 g3zcbCdPbCXq9fR0Nkk4qzl6UFeqyKTosFIhtcA3OV2HnPTodMj9h8/PevhdrDt5H5
	 bKjwjnQdXzk6eBiS1so/lxzsBAFgSsZRo6IgDd0gKPR5arMuWD/YOrssUSkNDhYajd
	 Dtx+lzFYpll0svl5vmNIIOTbkxLRM0s6v75C6w7Q793FtEakjyny74Y+SNl0a7OZMP
	 TeF6/kYvALzUw==
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-4-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