Skip to content

Commit 4fa3491

Browse files
bryamzxzPaolo Abeni
authored andcommitted
net/iucv: take a reference on the socket found in afiucv_hs_rcv()
afiucv_hs_rcv() looks up the destination socket under iucv_sk_list.lock, drops the lock, and then passes the socket to the afiucv_hs_callback_*() handlers without holding a reference. AF_IUCV sockets are not RCU-protected and are freed synchronously by iucv_sock_kill() -> sock_put(), so a concurrent close can free the socket in the window between read_unlock() and the handler, which then dereferences freed memory (for example sk->sk_data_ready() in afiucv_hs_callback_syn()). Take a reference with sock_hold() while the socket is still on the list and release it with sock_put() once the handler has run. Fixes: 3881ac4 ("af_iucv: add HiperSockets transport") Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me> Reviewed-by: Hidayath Khan <hidayath@linux.ibm.com> Link: https://patch.msgid.link/20260705-b4-disp-fc79c0dc-v1-1-d2cdcb57afa9@proton.me Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent f2f152e commit 4fa3491

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

net/iucv/af_iucv.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,6 +2089,8 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev,
20892089
}
20902090
}
20912091
}
2092+
if (sk)
2093+
sock_hold(sk);
20922094
read_unlock(&iucv_sk_list.lock);
20932095
if (!iucv)
20942096
sk = NULL;
@@ -2138,6 +2140,8 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev,
21382140
kfree_skb(skb);
21392141
}
21402142

2143+
if (sk)
2144+
sock_put(sk);
21412145
return err;
21422146
}
21432147

0 commit comments

Comments
 (0)