diff mbox series

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

Message ID 20240218081214.4806-1-remi@remlab.net (mailing list archive)
State Accepted
Commit 3b2d9bc4d4acdf15a876eae2c0d83149250e85ba
Delegated to: Netdev Maintainers
Headers show
Series [PATCHv2,1/2] phonet: take correct lock to peek at the RX queue | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 940 this patch: 940
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 957 this patch: 957
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 957 this patch: 957
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-22--00-00 (tests: 1455)

Commit Message

Rémi Denis-Courmont Feb. 18, 2024, 8:12 a.m. UTC
From: Rémi Denis-Courmont <courmisch@gmail.com>

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>
---
 net/phonet/datagram.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Feb. 22, 2024, 8:30 a.m. UTC | #1
Hello:

This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Sun, 18 Feb 2024 10:12:13 +0200 you wrote:
> From: Rémi Denis-Courmont <courmisch@gmail.com>
> 
> 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>
> 
> [...]

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!
diff mbox series

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: