mirror of
https://github.com/torvalds/linux.git
synced 2026-11-20 13:03:48 +00:00
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.
Fixes: 3881ac441f ("af_iucv: add HiperSockets transport")
Closes: https://sashiko.dev/#/patchset/[email protected]?part=1
Signed-off-by: Bryam Vargas <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
This commit is contained in:
committed by
Paolo Abeni
parent
873363ac59
commit
f38bce9af9
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user