2024-02-18 08:18:51

by Rémi Denis-Courmont

[permalink] [raw]
Subject: [PATCHv2 1/2] phonet: take correct lock to peek at the RX queue

From: Rémi Denis-Courmont <[email protected]>

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 <[email protected]>
Signed-off-by: Rémi Denis-Courmont <[email protected]>
Reviewed-by: Eric Dumazet <[email protected]>
---
net/phonet/datagram.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/phonet/datagram.c b/net/phonet/datagram.c
index 3aa50dc7535b..976fe250b509 100644
--- a/net/phonet/datagram.c
+++ b/net/phonet/datagram.c
@@ -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:
--
2.43.0



2024-02-22 08:30:52

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCHv2 1/2] phonet: take correct lock to peek at the RX queue

Hello:

This series was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

On Sun, 18 Feb 2024 10:12:13 +0200 you wrote:
> From: Rémi Denis-Courmont <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Rémi Denis-Courmont <[email protected]>
> Reviewed-by: Eric Dumazet <[email protected]>
>
> [...]

Here is the summary with links:
- [PATCHv2,1/2] phonet: take correct lock to peek at the RX queue
https://git.kernel.org/netdev/net/c/3b2d9bc4d4ac
- [PATCHv2,2/2] phonet/pep: fix racy skb_queue_empty() use
https://git.kernel.org/netdev/net/c/7d2a894d7f48

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html