Linux-HyperV List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mina Almasry" <almasrymina@google.com>,
	virtualization@lists.linux.dev, linux-mm@kvack.org,
	bpf@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com,
	imx@lists.linux.dev, linux-rdma@vger.kernel.org,
	linux-hyperv@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Steffen Klassert" <steffen.klassert@secunet.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"Willem de Bruijn" <willemb@google.com>,
	"Stanislav Fomichev" <sdf@fomichev.me>,
	"Pavel Begunkov" <asml.silence@gmail.com>,
	"Bobby Eshleman" <bobbyeshleman@meta.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Jason Wang" <jasowangio@gmail.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"David Hildenbrand" <david@kernel.org>,
	"Lorenzo Stoakes" <ljs@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	"Vlastimil Babka" <vbabka@kernel.org>,
	"Mike Rapoport" <rppt@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Michal Hocko" <mhocko@suse.com>,
	"Jesper Dangaard Brouer" <hawk@kernel.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Sabrina Dubroca" <sd@queasysnail.net>,
	"Johannes Berg" <johannes@sipsolutions.net>,
	"Byungchul Park" <byungchul@sk.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Lorenzo Bianconi" <lorenzo@kernel.org>,
	"Wen Gu" <guwen@linux.alibaba.com>,
	"Philo Lu" <lulie@linux.alibaba.com>,
	"Justin Chen" <justin.chen@broadcom.com>,
	"Florian Fainelli" <florian.fainelli@broadcom.com>,
	"Vikas Gupta" <vikas.gupta@broadcom.com>,
	"Michael Chan" <michael.chan@broadcom.com>,
	"Pavan Chebbi" <pavan.chebbi@broadcom.com>,
	"Doug Berger" <opendmb@gmail.com>,
	"Nicolai Buchwitz" <nb@tipi-net.de>,
	"Satish Kharat" <satishkh@cisco.com>,
	"Wei Fang" <wei.fang@nxp.com>, "Frank Li" <frank.li@nxp.com>,
	"Shenwei Wang" <shenwei.wang@nxp.com>,
	"Joshua Washington" <joshwash@google.com>,
	"Harshitha Ramamurthy" <hramamurthy@google.com>,
	"Jijie Shao" <shaojijie@huawei.com>,
	"Jian Shen" <shenjian15@huawei.com>,
	"Fan Gong" <gongfan1@huawei.com>,
	"Tony Nguyen" <anthony.l.nguyen@intel.com>,
	"Przemek Kitszel" <przemyslaw.kitszel@intel.com>,
	"Marcin Wojtas" <marcin.s.wojtas@gmail.com>,
	"Russell King" <linux@armlinux.org.uk>,
	"Sunil Goutham" <sgoutham@marvell.com>,
	"Geetha sowjanya" <gakula@marvell.com>,
	"Ratheesh Kannoth" <rkannoth@marvell.com>,
	"Subbaraya Sundeep" <sbhatta@marvell.com>,
	"Bharat Bhushan" <bbhushan2@marvell.com>,
	"Felix Fietkau" <nbd@nbd.name>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>,
	"Tariq Toukan" <tariqt@nvidia.com>,
	"Saeed Mahameed" <saeedm@nvidia.com>,
	"Mark Bloch" <mbloch@nvidia.com>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Ido Schimmel" <idosch@nvidia.com>,
	"Petr Machata" <petrm@nvidia.com>,
	"Horatiu Vultur" <horatiu.vultur@microchip.com>,
	UNGLinuxDriver@microchip.com,
	"Daniel Machon" <daniel.machon@microchip.com>,
	"Steen Hegelund" <Steen.Hegelund@microchip.com>,
	"Haiyang Zhang" <haiyangz@microsoft.com>,
	"Wei Liu" <wei.liu@kernel.org>,
	"Dexuan Cui" <decui@microsoft.com>,
	"Yibo Dong" <dong100@mucse.com>,
	"Brett Creeley" <brett.creeley@amd.com>,
	"Justin Lai" <justinlai0215@realtek.com>,
	"Larry Chiu" <larry.chiu@realtek.com>,
	"Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
	"Paul Barker" <paul@pbarker.dev>,
	"Masahisa Kojima" <kojima.masahisa@socionext.com>,
	"Maxime Chevallier" <maxime.chevallier@bootlin.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
	"Siddharth Vadapalli" <s-vadapalli@ti.com>,
	"Roger Quadros" <rogerq@kernel.org>,
	"MD Danish Anwar" <danishanwar@ti.com>,
	"Jiawen Wu" <jiawenwu@trustnetic.com>,
	"Mengyuan Lou" <mengyuanlou@net-swift.com>,
	"Ronak Doshi" <ronak.doshi@broadcom.com>,
	"Ryder Lee" <ryder.lee@mediatek.com>,
	"Shayne Chen" <shayne.chen@mediatek.com>,
	"Sean Wang" <sean.wang@mediatek.com>,
	"Juergen Gross" <jgross@suse.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Oleksandr Tyshchenko" <oleksandr_tyshchenko@epam.com>,
	"Jordan Rhee" <jordanrhee@google.com>,
	"Ankit Garg" <nktgrg@google.com>,
	"Tim Hostetler" <thostet@google.com>,
	"Erni Sri Satya Vennela" <ernis@linux.microsoft.com>,
	"Eric Joyner" <eric.joyner@amd.com>,
	"Mohammad Heib" <mheib@redhat.com>,
	"Prabu Thayalan" <prabu.ponrajthayalan@amd.com>,
	"Chintan Vankar" <c-vankar@ti.com>,
	"Nora Schiffer" <nora.schiffer@ew.tq-group.com>,
	"Alexander Sverdlin" <alex@sverdlin.org>,
	"Kevin Hao" <haokexin@gmail.com>,
	"Karl Mehltretter" <kmehltretter@gmail.com>,
	"Aleksandr Loktionov" <aleksandr.loktionov@intel.com>,
	"Meghana Malladi" <m-malladi@ti.com>,
	"Jacob Keller" <jacob.e.keller@intel.com>,
	"StanleyYP Wang" <StanleyYP.Wang@mediatek.com>,
	Frank.Li@kernel.org, wsa+renesas@sang-engineering.com
Subject: Re: [PATCH net-next v1 2/5] net: skbuff: refcount spliced page_pool frags via skb_pipe_buf_ops
Date: Wed, 04 Nov 2026 21:14:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-198071@kernel.org> (raw)
In-Reply-To: <20261103211424.127627-3-almasrymina@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: skbuff: missing refcount overflow check in skb_pipe_buf_get()
--

commit 9c79ad1ae20fce07ba4bd771a989ba25467dc207
Author: Mina Almasry <almasrymina@google.com>

net: skbuff: refcount spliced page_pool frags via skb_pipe_buf_ops

This commit updates skb_splice_bits() and skb_append_pagefrags() to acquire
and release fragment references via netmem_inc_ref(), netmem_dec_ref(), and
skb_frag_ref() using a new skb_pipe_buf_ops table.

> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 48f6764117243..32a9dcdf2cb22 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -3114,9 +3114,27 @@ EXPORT_SYMBOL(skb_copy_bits);
>   */
>  static void sock_spd_release(struct splice_pipe_desc *spd, unsigned int i)
>  {
> -	put_page(spd->pages[i]);
> +	netmem_dec_ref(page_to_netmem(spd->pages[i]));
>  }
>  
> +static void skb_pipe_buf_release(struct pipe_inode_info *pipe,
> +				 struct pipe_buffer *buf)
> +{
> +	netmem_dec_ref(page_to_netmem(buf->page));
> +}
> +
> +static bool skb_pipe_buf_get(struct pipe_inode_info *pipe,
> +			     struct pipe_buffer *buf)
> +{
> +	netmem_inc_ref(page_to_netmem(buf->page));
> +	return true;
> +}

[Severity: High]
Does replacing nosteal_pipe_buf_ops with skb_pipe_buf_ops in skb_splice_bits()
drop the page reference count overflow check when pipe buffers are duplicated?

Previously, nosteal_pipe_buf_ops used generic_pipe_buf_get(), which calls
try_get_page() and fails when the signed 32-bit page reference count is <= 0:

fs/pipe.c:generic_pipe_buf_get() {
	return try_get_page(buf->page);
}

include/linux/mm.h:try_get_page() {
	page = compound_head(page);
	if (WARN_ON_ONCE(page_ref_count(page) <= 0))
		return false;
	page_ref_inc(page);
	return true;
}

With skb_pipe_buf_get(), duplicating a spliced pipe buffer via tee() ->
link_pipe(), splice() -> splice_pipe_to_pipe(), or fuse_dev_splice_write()
invokes skb_pipe_buf_get() -> netmem_inc_ref() -> get_page() and
unconditionally returns true:

include/net/netmem.h:netmem_inc_ref() {
	if (netmem_is_net_iov(netmem))
		net_iov_inc_ref(netmem_to_net_iov(netmem));
	else
		get_page(netmem_to_page(netmem));
}

For any struct page-backed netmem using standard page refcounting (such as
sk_page_frag() pages from linear_to_page(), non-page_pool RX fragments, user
pages sent over a local socket, or page_pool pages whose pp_ref_count is 0, as
well as all struct pages at this commit prior to commit "net: remove
skb->pp_recycle and consolidate netmem refcounting"), can repeated pipe buffer
duplications push the page reference count past INT_MAX, triggering
VM_BUG_ON_FOLIO(folio_ref_zero_or_close_to_overflow(folio), folio) under
CONFIG_DEBUG_VM or wrapping _refcount to 0 and causing a use-after-free when
CONFIG_DEBUG_VM is disabled?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103211424.127627-1-almasrymina@google.com?part=2

  reply	other threads:[~2026-11-04 21:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03 21:14 [PATCH net-next v1 0/5] net: deprecate skb->pp_recycle and skb_mark_for_recycle() Mina Almasry
2026-11-03 21:14 ` [PATCH net-next v1 1/5] net: skbuff: skip managed zerocopy frags in skb_frag_ref() Mina Almasry
2026-11-03 21:14 ` [PATCH net-next v1 2/5] net: skbuff: refcount spliced page_pool frags via skb_pipe_buf_ops Mina Almasry
2026-11-04 21:14   ` sashiko-bot [this message]
2026-11-03 21:14 ` [PATCH net-next v1 3/5] net: datagram: refcount page_pool frags in zerocopy_fill_skb_from_iter() Mina Almasry
2026-11-03 21:14 ` [PATCH net-next v1 4/5] net: remove skb->pp_recycle and consolidate netmem refcounting Mina Almasry
2026-11-04 21:14   ` sashiko-bot
2026-11-03 21:14 ` [PATCH net-next v1 5/5] net: remove skb_mark_for_recycle() Mina Almasry

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-198071@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=StanleyYP.Wang@mediatek.com \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=akpm@linux-foundation.org \
    --cc=aleksandr.loktionov@intel.com \
    --cc=alex@sverdlin.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=almasrymina@google.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=asml.silence@gmail.com \
    --cc=ast@kernel.org \
    --cc=bbhushan2@marvell.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bobbyeshleman@meta.com \
    --cc=bpf@vger.kernel.org \
    --cc=brett.creeley@amd.com \
    --cc=byungchul@sk.com \
    --cc=c-vankar@ti.com \
    --cc=corbet@lwn.net \
    --cc=daniel.machon@microchip.com \
    --cc=daniel@iogearbox.net \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=david@kernel.org \
    --cc=decui@microsoft.com \
    --cc=dong100@mucse.com \
    --cc=edumazet@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=eric.joyner@amd.com \
    --cc=ernis@linux.microsoft.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=frank.li@nxp.com \
    --cc=fujita.tomonori@gmail.com \
    --cc=gakula@marvell.com \
    --cc=gongfan1@huawei.com \
    --cc=guwen@linux.alibaba.com \
    --cc=haiyangz@microsoft.com \
    --cc=haokexin@gmail.com \
    --cc=hawk@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=horatiu.vultur@microchip.com \
    --cc=horms@kernel.org \
    --cc=hramamurthy@google.com \
    --cc=idosch@nvidia.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=imx@lists.linux.dev \
    --cc=jacob.e.keller@intel.com \
    --cc=jasowangio@gmail.com \
    --cc=jgross@suse.com \
    --cc=jiawenwu@trustnetic.com \
    --cc=johannes@sipsolutions.net \
    --cc=john.fastabend@gmail.com \
    --cc=jordanrhee@google.com \
    --cc=joshwash@google.com \
    --cc=justin.chen@broadcom.com \
    --cc=justinlai0215@realtek.com \
    --cc=kmehltretter@gmail.com \
    --cc=kojima.masahisa@socionext.com \
    --cc=kuba@kernel.org \
    --cc=larry.chiu@realtek.com \
    --cc=leon@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=ljs@kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=lulie@linux.alibaba.com \
    --cc=m-malladi@ti.com \
    --cc=marcin.s.wojtas@gmail.com \
    --cc=matthias.bgg@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mbloch@nvidia.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mengyuanlou@net-swift.com \
    --cc=mheib@redhat.com \
    --cc=mhocko@suse.com \
    --cc=michael.chan@broadcom.com \
    --cc=mst@redhat.com \
    --cc=nb@tipi-net.de \
    --cc=nbd@nbd.name \
    --cc=niklas.soderlund@ragnatech.se \
    --cc=nktgrg@google.com \
    --cc=nora.schiffer@ew.tq-group.com \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=opendmb@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=paul@pbarker.dev \
    --cc=pavan.chebbi@broadcom.com \
    --cc=petrm@nvidia.com \
    --cc=prabu.ponrajthayalan@amd.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rdunlap@infradead.org \
    --cc=rkannoth@marvell.com \
    --cc=rogerq@kernel.org \
    --cc=ronak.doshi@broadcom.com \
    --cc=rppt@kernel.org \
    --cc=ryder.lee@mediatek.com \
    --cc=s-vadapalli@ti.com \
    --cc=saeedm@nvidia.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=satishkh@cisco.com \
    --cc=sbhatta@marvell.com \
    --cc=sd@queasysnail.net \
    --cc=sdf@fomichev.me \
    --cc=sean.wang@mediatek.com \
    --cc=sgoutham@marvell.com \
    --cc=shaojijie@huawei.com \
    --cc=shayne.chen@mediatek.com \
    --cc=shenjian15@huawei.com \
    --cc=shenwei.wang@nxp.com \
    --cc=skhan@linuxfoundation.org \
    --cc=sstabellini@kernel.org \
    --cc=steffen.klassert@secunet.com \
    --cc=surenb@google.com \
    --cc=tariqt@nvidia.com \
    --cc=thostet@google.com \
    --cc=vbabka@kernel.org \
    --cc=vikas.gupta@broadcom.com \
    --cc=virtualization@lists.linux.dev \
    --cc=wei.fang@nxp.com \
    --cc=wei.liu@kernel.org \
    --cc=willemb@google.com \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=xuanzhuo@linux.alibaba.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