From: Norbert Szetei <norbert@doyensec.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Aaron Conole <aconole@redhat.com>,
Eelco Chaudron <echaudro@redhat.com>,
Ilya Maximets <i.maximets@ovn.org>,
Steffen Klassert <steffen.klassert@secunet.com>,
Kuan-Ting Chen <h3xrabbit@gmail.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
linux-kernel@vger.kernel.org, dev@openvswitch.org,
Jongmin Jang <payload.jang@gmail.com>
Subject: [PATCH net v3 0/3] net: don't strip zerocopy frag markers from a forwarded skb
Date: Tue, 18 Aug 2026 10:43:35 +0200 [thread overview]
Message-ID: <F3B9E5BA-0AC1-4AD1-A7D9-F38033304270@doyensec.com> (raw)
queue_userspace_packet() calls skb_tx_error() on the packet skb in its
error path, but it only borrows that skb: on the OVS_ACTION_ATTR_USERSPACE
action path do_execute_actions() ignores output_userspace()'s return value
and keeps forwarding the same skb through the flow's remaining actions.
skb_tx_error() completes the zerocopy uarg and clears SKBFL_ALL_ZEROCOPY,
and with it SKBFL_SHARED_FRAG.
For a MSG_ZEROCOPY skb carrying page-cache frags, SKBFL_SHARED_FRAG is
what makes esp_input() skb_cow_data() instead of taking the in-place AEAD
path. Once it is stripped, a later local ESP delivery decrypts in place
over pages the sender still shares with the page cache.
Patch 1 moves the skb_tx_error() into the one path that does drop the
packet, the "default" arm of ovs_dp_process_packet()'s switch(error).
Patch 2 removes a second such strip, in skb_zerocopy(), which calls
skb_tx_error() on its source when skb_orphan_frags() fails. A copy helper
should not perform a destructive action on its source, and both callers
already report the error on their own drop path. MSG_ZEROCOPY skbs cannot
reach that one -- SKBFL_DONT_ORPHAN makes skb_orphan_frags() return early
-- but producers that do not set that flag, such as vhost-net, can.
Patch 3 is new in v2. It stops skb_tx_error() from touching skb_shinfo()
state that is shared with clones, so patch 1's new call site cannot reach
a live skb either. For a non-last OVS_ACTION_ATTR_RECIRC action
clone_execute() sends a skb_clone() into ovs_dp_process_packet() while
do_execute_actions() keeps forwarding the original, and skb_clone() does
not privatise the frags for these skbs -- skb_orphan_frags() returns early
on SKBFL_DONT_ORPHAN -- so a flow miss on the clone strips
SKBFL_SHARED_FRAG from the packet still in flight. Confirmed on a KASAN
build with a flow matching recirc_id 0 and actions RECIRC(1),OUTPUT(0):
with patches 1 and 2 applied it still reproduces the page-cache write,
with patch 3 on top it no longer does (5/5 runs). A kprobe on
skb_tx_error() shows the datapath drop path is still reached in both
cases, so the difference is the guard and not the reproducer.
As Ilya noted, that makes patch 3 the general fix -- an skb can enter any
skb_tx_error() caller already cloned elsewhere in the stack -- while
patches 1 and 2 keep the callers from acting on an skb they do not own.
Removing skb_tx_error() altogether looks like the right long-term cleanup
and is planned as a net-next follow-up.
v3:
- patch 3: Fixes tag corrected to 25121173f7b1 ("skb: api to report
errors for zero copy skbs"), the commit that added skb_tx_error()
(Ilya Maximets)
- Tested-by from Jongmin Jang picked up on patches 1 and 3
- v2: https://lore.kernel.org/netdev/AD1B7BEE-C04C-4A1B-982C-8385F1908911@doyensec.com/
v2:
- new patch 3: skip the shared skb_shinfo() work in skb_tx_error() when
the skb is cloned, which also covers the OVS_ACTION_ATTR_RECIRC path
that patch 1 alone leaves open (suggested by Ilya Maximets)
- patches 1 and 2 unchanged, Reviewed-by from Ilya Maximets picked up
- v1: https://lore.kernel.org/netdev/8063260C-05C9-4997-B9B6-2135063C4858@doyensec.com/
Norbert Szetei (3):
openvswitch: only skb_tx_error() a packet we are about to drop
net: skbuff: don't skb_tx_error() the source skb in skb_zerocopy()
net: skbuff: don't touch shared zerocopy state in skb_tx_error()
net/core/skbuff.c | 10 ++++++----
net/openvswitch/datapath.c | 3 +--
2 files changed, 7 insertions(+), 6 deletions(-)
--
2.55.0
next reply other threads:[~2026-08-18 8:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 8:43 Norbert Szetei [this message]
2026-08-18 8:45 ` [PATCH net v3 1/3] openvswitch: only skb_tx_error() a packet we are about to drop Norbert Szetei
2026-08-18 8:46 ` [PATCH net v3 2/3] net: skbuff: don't skb_tx_error() the source skb in skb_zerocopy() Norbert Szetei
2026-08-18 8:47 ` [PATCH net v3 3/3] net: skbuff: don't touch shared zerocopy state in skb_tx_error() Norbert Szetei
2026-08-18 15:59 ` Ilya Maximets
2026-08-21 21:45 ` [PATCH net v3 0/3] net: don't strip zerocopy frag markers from a forwarded skb Ilya Maximets
2026-08-22 0:09 ` Jakub Kicinski
2026-08-22 19:26 ` Ilya Maximets
2026-08-22 20:55 ` Willem de Bruijn
2026-08-24 11:38 ` Ilya Maximets
2026-08-24 19:14 ` Willem de Bruijn
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=F3B9E5BA-0AC1-4AD1-A7D9-F38033304270@doyensec.com \
--to=norbert@doyensec.com \
--cc=aconole@redhat.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=echaudro@redhat.com \
--cc=edumazet@google.com \
--cc=h3xrabbit@gmail.com \
--cc=horms@kernel.org \
--cc=i.maximets@ovn.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=payload.jang@gmail.com \
--cc=steffen.klassert@secunet.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