]> git.dujemihanovic.xyz Git - linux.git/commitdiff
phonet: take correct lock to peek at the RX queue
authorRémi Denis-Courmont <courmisch@gmail.com>
Sun, 18 Feb 2024 08:12:13 +0000 (10:12 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 22 Feb 2024 08:05:50 +0000 (09:05 +0100)
The receive queue is protected by its embedded spin-lock, not the
socket lock, so we need the former lock here (and only that one).

Fixes: 107d0d9b8d9a ("Phonet: Phonet datagram transport protocol")
Reported-by: Luosili <rootlab@huawei.com>
Signed-off-by: Rémi Denis-Courmont <courmisch@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20240218081214.4806-1-remi@remlab.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/phonet/datagram.c

index 3aa50dc7535b7761c77652d2f38826419b57c26a..976fe250b50955ec51b0c5d73f2dfa132990b60b 100644 (file)
@@ -34,10 +34,10 @@ static int pn_ioctl(struct sock *sk, int cmd, int *karg)
 
        switch (cmd) {
        case SIOCINQ:
-               lock_sock(sk);
+               spin_lock_bh(&sk->sk_receive_queue.lock);
                skb = skb_peek(&sk->sk_receive_queue);
                *karg = skb ? skb->len : 0;
-               release_sock(sk);
+               spin_unlock_bh(&sk->sk_receive_queue.lock);
                return 0;
 
        case SIOCPNADDRESOURCE: