diff options
author | Rémi Denis-Courmont <courmisch@gmail.com> | 2024-02-18 10:12:13 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-03-01 13:26:38 +0100 |
commit | f556a352fdb2489d50f1231f58b6dfbadb4e3756 (patch) | |
tree | 4f21daef4f7b6446a8cccc4803320e992421093c /net | |
parent | 1623161f80a4b8bb284b0cc3118daf3ccd5bf923 (diff) | |
download | linux-f556a352fdb2489d50f1231f58b6dfbadb4e3756.tar.gz |
phonet: take correct lock to peek at the RX queue
[ Upstream commit 3b2d9bc4d4acdf15a876eae2c0d83149250e85ba ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/phonet/datagram.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c index ff5f49ab236ede..39a6c5713d0b21 100644 --- a/net/phonet/datagram.c +++ b/net/phonet/datagram.c @@ -35,10 +35,10 @@ static int pn_ioctl(struct sock *sk, int cmd, unsigned long arg) switch (cmd) { case SIOCINQ: - lock_sock(sk); + spin_lock_bh(&sk->sk_receive_queue.lock); skb = skb_peek(&sk->sk_receive_queue); answ = skb ? skb->len : 0; - release_sock(sk); + spin_unlock_bh(&sk->sk_receive_queue.lock); return put_user(answ, (int __user *)arg); case SIOCPNADDRESOURCE: |