Skip to content

Commit 73f8c43

Browse files
V4bel-theoriNipaLocal
authored andcommitted
appletalk: Fix Use-After-Free in atalk_ioctl
Because atalk_ioctl() accesses sk->sk_receive_queue without holding a sk->sk_receive_queue.lock, it can cause a race with atalk_recvmsg(). A use-after-free for skb occurs with the following flow. ``` atalk_ioctl() -> skb_peek() atalk_recvmsg() -> skb_recv_datagram() -> skb_free_datagram() ``` Add sk->sk_receive_queue.lock to atalk_ioctl() to fix this issue. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Hyunwoo Kim <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 10b074f commit 73f8c43

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

net/appletalk/ddp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,15 +1775,17 @@ static int atalk_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
17751775
break;
17761776
}
17771777
case TIOCINQ: {
1778+
long amount = 0;
1779+
struct sk_buff *skb;
17781780
/*
17791781
* These two are safe on a single CPU system as only
17801782
* user tasks fiddle here
17811783
*/
1782-
struct sk_buff *skb = skb_peek(&sk->sk_receive_queue);
1783-
long amount = 0;
1784-
1784+
spin_lock_irq(&sk->sk_receive_queue.lock);
1785+
skb = skb_peek(&sk->sk_receive_queue);
17851786
if (skb)
17861787
amount = skb->len - sizeof(struct ddpehdr);
1788+
spin_unlock_irq(&sk->sk_receive_queue.lock);
17871789
rc = put_user(amount, (int __user *)argp);
17881790
break;
17891791
}

0 commit comments

Comments
 (0)