net/iucv: take a private, writable frame before rewriting it in place
Subsystems (4)
PATCH v3 1/1 net/iucv: take a private, writable frame before rewriting it in place
afiucv_hs_rcv() rewrites the frame in place -- EBCASC() on four name fields, then afiucv_swap_src_dest() swaps them and pushes an Ethernet header -- and can hand the same skb to dev_queue_xmit(), without making it private first, so a packet socket that also gets the frame reads the rewritten names. An ETH_P_ALL tap runs first and leaves af_iucv a cloned skb; a socket opened for ETH_P_AF_IUCV sits on a ptype_specific list, walked after ptype_base[], so deliver_skb() takes a reference and af_iucv runs on an skb that is shared but not cloned.
Unshare, then cow, in that order: skb_cow() can reach pskb_expand_head(), which has BUG_ON(skb_shared()). skb_cow() tests skb_cloned(), which is what a rewrite of the data needs; skb_cow_head() tests only the header. Asking for ETH_HLEN also covers the unchecked push in afiucv_swap_src_dest(); on the ordinary path eth_type_trans() has already pulled that much, so it only compares.
---
v3: skb_cow() instead of skb_cow_head(), as Paolo and the netdev AI
review asked: the rewrite is in the data, and skb_cow_head()'s skb_header_cloned() test would leave it shared with a nohdr holder (none reaches af_iucv today; still the wrong contract). One-word change, rebased on net. v2 carried Alexandra's Reviewed-by; v3 changes the helper on Paolo's point, so it is not carried. Same s390x QEMU A/B as v2, re-run on v3: same eight boots, same table. Unpatched, the tap and the ETH_P_AF_IUCV socket both read the 48 name bytes in ASCII and a SYN with no listener never reaches the socket; with this version every frame arrives as sent. Drop skb_share_check() and the socket is broken again; drop skb_cow() and both are.
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
--- net/iucv/af_iucv.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/iucv/af_iucv.c +9 -0
@@ -2080,11 +2080,20 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev,int err =NET_RX_SUCCESS ;char nullstring[8 ]; + skb =skb_share_check (skb,GFP_ATOMIC ); +if (!skb) +return NET_RX_SUCCESS ; +if (!pskb_may_pull (skb,sizeof (*trans_hdr))) {kfree_skb (skb);return NET_RX_SUCCESS ; } +if (skb_cow (skb,ETH_HLEN )) { +kfree_skb (skb); +return NET_RX_SUCCESS ; + } + trans_hdr =iucv_trans_hdr (skb);EBCASC (trans_hdr->destAppName,sizeof (trans_hdr->destAppName));EBCASC (trans_hdr->destUserID,sizeof (trans_hdr->destUserID));
---
base-commit: fcc00b15cb21a6de76826e5012b2c758505f5e65
change-id: 20261028-b4-disp-1edbbc34-48ad75db36c9
Best regards,
Signature · 1 line
bryamzxz <[email protected]>
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 18 lines
From: Bryam Vargas <[email protected]>
afiucv_hs_rcv()rewrites the frame in place --EBCASC()on four name fields, thenafiucv_swap_src_dest()swaps them and pushes an Ethernet header -- and can hand the same skb todev_queue_xmit(), without making it private first, so a packet socket that also gets the frame reads the rewritten names. AnETH_P_ALLtap runs first and leavesaf_iucva cloned skb; a socket opened forETH_P_AF_IUCVsits on aptype_specificlist, walked after ptype_base[], sodeliver_skb()takes a reference andaf_iucvruns on an skb that is shared but not cloned.Unshare, then cow, in that order:
skb_cow()can reachpskb_expand_head(), which has BUG_ON(skb_shared()).skb_cow()testsskb_cloned(), which is what a rewrite of the data needs;skb_cow_head()tests only the header. Asking forETH_HLENalso covers the unchecked push inafiucv_swap_src_dest(); on the ordinary patheth_type_trans()has already pulled that much, so it only compares.
Quoted 3 lines
Fixes 3881ac441f64 ("af_iucv: add HiperSockets transport")Signed-off-by Bryam Vargas <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 33 lines · Bryam Vargas
afiucv_hs_rcv()rewrites the frame in place --EBCASC()on four name fields, thenafiucv_swap_src_dest()swaps them and pushes an Ethernet header -- and can hand the same skb todev_queue_xmit(), without making it private first, so a packet socket that also gets the frame reads the rewritten names. AnETH_P_ALLtap runs first and leavesaf_iucva cloned skb; a socket opened forETH_P_AF_IUCVsits on aptype_specificlist, walked after ptype_base[], sodeliver_skb()takes a reference andaf_iucvruns on an skb that is shared but not cloned.Unshare, then cow, in that order:
skb_cow()can reachpskb_expand_head(), which has BUG_ON(skb_shared()).skb_cow()testsskb_cloned(), which is what a rewrite of the data needs;skb_cow_head()tests only the header. Asking forETH_HLENalso covers the unchecked push inafiucv_swap_src_dest(); on the ordinary patheth_type_trans()has already pulled that much, so it only compares.Fixes 3881ac441f64 ("af_iucv: add HiperSockets transport")Signed-off-by Bryam Vargas <[email protected]>---
v3:skb_cow()instead ofskb_cow_head(), as Paolo and the netdev AI
review asked: the rewrite is in the data, and skb_cow_head()'sskb_header_cloned()test would leave it shared with a nohdr holder (none reachesaf_iucvtoday; still the wrong contract). One-word change, rebased on net. v2 carried Alexandra's Reviewed-by; v3 changes the helper on Paolo's point, so it is not carried. Same s390x QEMU A/B as v2, re-run on v3: same eight boots, same table. Unpatched, the tap and theETH_P_AF_IUCVsocket both read the 48 name bytes in ASCII and a SYN with no listener never reaches the socket; with this version every frame arrives as sent. Dropskb_share_check()and the socket is broken again; dropskb_cow()and both are.
Quoted 2 lines
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 11 lines · On Wed, 28 Oct 2026 23:47:13 -0500 you wrote:
From: Bryam Vargas <[email protected]>
afiucv_hs_rcv()rewrites the frame in place --EBCASC()on four name fields, thenafiucv_swap_src_dest()swaps them and pushes an Ethernet header -- and can hand the same skb todev_queue_xmit(), without making it private first, so a packet socket that also gets the frame reads the rewritten names. AnETH_P_ALLtap runs first and leavesaf_iucva cloned skb; a socket opened forETH_P_AF_IUCVsits on aptype_specificlist, walked after ptype_base[], sodeliver_skb()takes a reference andaf_iucvruns on an skb that is shared but not cloned.
Quoted 1 line
[...]
Here is the summary with links:
- [net,v3] net/iucv: take a private, writable frame before rewriting it in place
https://git.kernel.org/netdev/net/c/f38bce9af9e2
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html