All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] inet: missing lock releases in udp.c
@ 2022-01-21  3:15 ycaibb
  2022-01-21  6:26   ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: ycaibb @ 2022-01-21  3:15 UTC (permalink / raw)
  To: davem, yoshfuji, dsahern, kuba, ast, daniel, andrii, kafai,
	songliubraving, yhs, john.fastabend, kpsingh
  Cc: netdev, ycaibb, linux-kernel, bpf

From: Ryan Cai <ycaibb@gmail.com>

In method udp_get_first, the lock hslot->lock is not released when afinfo->family == AF_UNSPEC || sk->sk_family == afinfo->family is true. This patch fixes the problem by adding the unlock statement.

Signed-off-by: Ryan Cai <ycaibb@gmail.com>
---
 net/ipv4/udp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 23b05e28490b..f7d573ecaafb 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2967,6 +2967,7 @@ static struct sock *udp_get_first(struct seq_file *seq, int start)
 				continue;
 			if (afinfo->family == AF_UNSPEC ||
 			    sk->sk_family == afinfo->family)
+				spin_unlock_bh(&hslot->lock);
 				goto found;
 		}
 		spin_unlock_bh(&hslot->lock);
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* Re: [PATCH] inet: missing lock releases in udp.c
@ 2022-01-21 21:13 kernel test robot
  0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-01-21 21:13 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4837 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20220121031553.5342-1-ycaibb@gmail.com>
References: <20220121031553.5342-1-ycaibb@gmail.com>
TO: ycaibb <ycaibb@gmail.com>
TO: davem(a)davemloft.net
TO: yoshfuji(a)linux-ipv6.org
TO: dsahern(a)kernel.org
TO: kuba(a)kernel.org
TO: ast(a)kernel.org
TO: daniel(a)iogearbox.net
TO: andrii(a)kernel.org
TO: kafai(a)fb.com
TO: songliubraving(a)fb.com
TO: yhs(a)fb.com

Hi ycaibb,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on net/master horms-ipvs/master linus/master v5.16 next-20220121]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/ycaibb/inet-missing-lock-releases-in-udp-c/20220121-111922
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 8aaaf2f3af2ae212428f4db1af34214225f5cec3
:::::: branch date: 18 hours ago
:::::: commit date: 18 hours ago
config: x86_64-randconfig-m001-20220117 (https://download.01.org/0day-ci/archive/20220122/202201220528.juyE42K0-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
net/ipv4/udp.c:2979 udp_get_first() warn: curly braces intended?

Old smatch warnings:
net/ipv4/udp.c:496 __udp4_lib_lookup() warn: potential spectre issue 'udptable->hash2' [r]
net/ipv4/udp.c:2288 __udp4_lib_mcast_deliver() warn: potential spectre issue 'udptable->hash2' [r]
net/ipv4/udp.c:2520 __udp4_lib_mcast_demux_lookup() warn: potential spectre issue 'udp_table.hash' [r]
net/ipv4/udp.c:2551 __udp4_lib_demux_lookup() warn: potential spectre issue 'udp_table.hash2' [r]

vim +2979 net/ipv4/udp.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  2952  
645ca708f936b2 Eric Dumazet      2008-10-29  2953  static struct sock *udp_get_first(struct seq_file *seq, int start)
^1da177e4c3f41 Linus Torvalds    2005-04-16  2954  {
^1da177e4c3f41 Linus Torvalds    2005-04-16  2955  	struct sock *sk;
9e8ca27afab6c9 Yonghong Song     2020-06-23  2956  	struct udp_seq_afinfo *afinfo;
^1da177e4c3f41 Linus Torvalds    2005-04-16  2957  	struct udp_iter_state *state = seq->private;
6f191efe48af62 Denis V. Lunev    2008-03-28  2958  	struct net *net = seq_file_net(seq);
^1da177e4c3f41 Linus Torvalds    2005-04-16  2959  
9e8ca27afab6c9 Yonghong Song     2020-06-23  2960  	if (state->bpf_seq_afinfo)
9e8ca27afab6c9 Yonghong Song     2020-06-23  2961  		afinfo = state->bpf_seq_afinfo;
9e8ca27afab6c9 Yonghong Song     2020-06-23  2962  	else
9e8ca27afab6c9 Yonghong Song     2020-06-23  2963  		afinfo = PDE_DATA(file_inode(seq->file));
9e8ca27afab6c9 Yonghong Song     2020-06-23  2964  
a3d2599b24462c Christoph Hellwig 2018-04-10  2965  	for (state->bucket = start; state->bucket <= afinfo->udp_table->mask;
f86dcc5aa8c790 Eric Dumazet      2009-10-07  2966  	     ++state->bucket) {
a3d2599b24462c Christoph Hellwig 2018-04-10  2967  		struct udp_hslot *hslot = &afinfo->udp_table->hash[state->bucket];
f86dcc5aa8c790 Eric Dumazet      2009-10-07  2968  
ca065d0cf80fa5 Eric Dumazet      2016-04-01  2969  		if (hlist_empty(&hslot->head))
f86dcc5aa8c790 Eric Dumazet      2009-10-07  2970  			continue;
f86dcc5aa8c790 Eric Dumazet      2009-10-07  2971  
645ca708f936b2 Eric Dumazet      2008-10-29  2972  		spin_lock_bh(&hslot->lock);
ca065d0cf80fa5 Eric Dumazet      2016-04-01  2973  		sk_for_each(sk, &hslot->head) {
878628fbf2589e YOSHIFUJI Hideaki 2008-03-26  2974  			if (!net_eq(sock_net(sk), net))
a91275eff43a52 Daniel Lezcano    2008-03-21  2975  				continue;
9e8ca27afab6c9 Yonghong Song     2020-06-23  2976  			if (afinfo->family == AF_UNSPEC ||
9e8ca27afab6c9 Yonghong Song     2020-06-23  2977  			    sk->sk_family == afinfo->family)
1b84613d303e14 Ryan Cai          2022-01-21  2978  				spin_unlock_bh(&hslot->lock);
^1da177e4c3f41 Linus Torvalds    2005-04-16 @2979  				goto found;
^1da177e4c3f41 Linus Torvalds    2005-04-16  2980  		}
645ca708f936b2 Eric Dumazet      2008-10-29  2981  		spin_unlock_bh(&hslot->lock);
^1da177e4c3f41 Linus Torvalds    2005-04-16  2982  	}
^1da177e4c3f41 Linus Torvalds    2005-04-16  2983  	sk = NULL;
^1da177e4c3f41 Linus Torvalds    2005-04-16  2984  found:
^1da177e4c3f41 Linus Torvalds    2005-04-16  2985  	return sk;
^1da177e4c3f41 Linus Torvalds    2005-04-16  2986  }
^1da177e4c3f41 Linus Torvalds    2005-04-16  2987  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-23 19:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21  3:15 [PATCH] inet: missing lock releases in udp.c ycaibb
2022-01-21  6:26 ` kernel test robot
2022-01-21  6:26   ` kernel test robot
2022-01-23  7:11 ` [inet] 1b84613d30: WARNING:at_kernel/softirq.c:#__local_bh_enable_ip kernel test robot
2022-01-23  7:11   ` kernel test robot
2022-01-23 19:57 ` [PATCH] inet: missing lock releases in udp.c Cong Wang
2022-01-21 21:13 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.