Skip to content

Commit 24e90b9

Browse files
V4bel-theoriPaolo Abeni
authored andcommitted
atm: Fix Use-After-Free in do_vcc_ioctl
Because do_vcc_ioctl() accesses sk->sk_receive_queue without holding a sk->sk_receive_queue.lock, it can cause a race with vcc_recvmsg(). A use-after-free for skb occurs with the following flow. ``` do_vcc_ioctl() -> skb_peek() vcc_recvmsg() -> skb_recv_datagram() -> skb_free_datagram() ``` Add sk->sk_receive_queue.lock to do_vcc_ioctl() to fix this issue. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Hyunwoo Kim <[email protected]> Link: https://lore.kernel.org/r/20231209094210.GA403126@v4bel-B760M-AORUS-ELITE-AX Signed-off-by: Paolo Abeni <[email protected]>
1 parent e307b5a commit 24e90b9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/atm/ioctl.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,17 @@ static int do_vcc_ioctl(struct socket *sock, unsigned int cmd,
7373
case SIOCINQ:
7474
{
7575
struct sk_buff *skb;
76+
int amount;
7677

7778
if (sock->state != SS_CONNECTED) {
7879
error = -EINVAL;
7980
goto done;
8081
}
82+
spin_lock_irq(&sk->sk_receive_queue.lock);
8183
skb = skb_peek(&sk->sk_receive_queue);
82-
error = put_user(skb ? skb->len : 0,
83-
(int __user *)argp) ? -EFAULT : 0;
84+
amount = skb ? skb->len : 0;
85+
spin_unlock_irq(&sk->sk_receive_queue.lock);
86+
error = put_user(amount, (int __user *)argp) ? -EFAULT : 0;
8487
goto done;
8588
}
8689
case ATM_SETSC:

0 commit comments

Comments
 (0)