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

Message ID 20240210125054.71391-1-remi@remlab.net
State New
Headers
Series [1/2] phonet: take correct lock to peek at the RX queue |

Commit Message

Rémi Denis-Courmont Feb. 10, 2024, 12:50 p.m. UTC
  From: Rémi Denis-Courmont <courmisch@gmail.com>

Reported-by: Luosili <rootlab@huawei.com>
Signed-off-by: Rémi Denis-Courmont <courmisch@gmail.com>
---
 net/phonet/datagram.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Eric Dumazet Feb. 12, 2024, 9:34 a.m. UTC | #1
On Sat, Feb 10, 2024 at 1:50 PM Rémi Denis-Courmont <remi@remlab.net> wrote:
>
> From: Rémi Denis-Courmont <courmisch@gmail.com>
>
> Reported-by: Luosili <rootlab@huawei.com>
> Signed-off-by: Rémi Denis-Courmont <courmisch@gmail.com>
> ---
>  net/phonet/datagram.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

Fixes: 107d0d9b8d9a ("Phonet: Phonet datagram transport protocol")
Reviewed-by: Eric Dumazet <edumazet@google.com>

Thanks.
  
Paolo Abeni Feb. 13, 2024, 12:12 p.m. UTC | #2
On Sat, 2024-02-10 at 14:50 +0200, Rémi Denis-Courmont wrote:
> From: Rémi Denis-Courmont <courmisch@gmail.com>
> 
> Reported-by: Luosili <rootlab@huawei.com>
> Signed-off-by: Rémi Denis-Courmont <courmisch@gmail.com>

Looks good, but you need to add a non empty commit message. Even
something quite similar to the one included in patch 2/2.

you can retain Eric's ack when post v2.

Pleas also include the correct fixes tag.

Thanks

Paolo
  

Patch

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: