lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Sat, 14 Jan 2023 12:30:22 +0300
From:   Kirill Tkhai <tkhai@...ru>
To:     kernel test robot <lkp@...el.com>, davem@...emloft.net,
        edumazet@...gle.com, kuba@...nel.org, pabeni@...hat.com,
        kuniyu@...zon.com, netdev@...r.kernel.org
Cc:     llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev
Subject: Re: [PATCH net-next] unix: Improve locking scheme in
 unix_show_fdinfo()

On 14.01.2023 08:30, kernel test robot wrote:
> Hi Kirill,
> 
> Thank you for the patch! Perhaps something to improve:
> 
> [auto build test WARNING on net-next/master]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Kirill-Tkhai/unix-Improve-locking-scheme-in-unix_show_fdinfo/20230114-082118
> patch link:    https://lore.kernel.org/r/9d951e81-2051-5b67-a394-2cb819e5bf57%40ya.ru
> patch subject: [PATCH net-next] unix: Improve locking scheme in unix_show_fdinfo()
> config: x86_64-rhel-8.3-rust
> compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # https://github.com/intel-lab-lkp/linux/commit/1c3b5ffa3da1bc362d28489fc860432b09e8a451
>         git remote add linux-review https://github.com/intel-lab-lkp/linux
>         git fetch --no-tags linux-review Kirill-Tkhai/unix-Improve-locking-scheme-in-unix_show_fdinfo/20230114-082118
>         git checkout 1c3b5ffa3da1bc362d28489fc860432b09e8a451
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash net/unix/
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@...el.com>
> 
> All warnings (new ones prefixed by >>):
> 
>>> net/unix/af_unix.c:824:12: warning: variable 'nr_fds' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
>                    else if (s_state == TCP_LISTEN)
>                             ^~~~~~~~~~~~~~~~~~~~~
>    net/unix/af_unix.c:827:34: note: uninitialized use occurs here
>                    seq_printf(m, "scm_fds: %u\n", nr_fds);
>                                                   ^~~~~~
>    net/unix/af_unix.c:824:8: note: remove the 'if' if its condition is always true
>                    else if (s_state == TCP_LISTEN)
>                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
>    net/unix/af_unix.c:812:12: note: initialize the variable 'nr_fds' to silence this warning
>            int nr_fds;
>                      ^
>                       = 0

Strange, my gcc didn't warn me... I will send v2.

>    1 warning generated.
> 
> 
> vim +824 net/unix/af_unix.c
> 
>    806	
>    807	static void unix_show_fdinfo(struct seq_file *m, struct socket *sock)
>    808	{
>    809		struct sock *sk = sock->sk;
>    810		unsigned char s_state;
>    811		struct unix_sock *u;
>    812		int nr_fds;
>    813	
>    814		if (sk) {
>    815			s_state = READ_ONCE(sk->sk_state);
>    816			u = unix_sk(sk);
>    817	
>    818			/* SOCK_STREAM and SOCK_SEQPACKET sockets never change their
>    819			 * sk_state after switching to TCP_ESTABLISHED or TCP_LISTEN.
>    820			 * SOCK_DGRAM is ordinary. So, no lock is needed.
>    821			 */
>    822			if (sock->type == SOCK_DGRAM || s_state == TCP_ESTABLISHED)
>    823				nr_fds = atomic_read(&u->scm_stat.nr_fds);
>  > 824			else if (s_state == TCP_LISTEN)
>    825				nr_fds = unix_count_nr_fds(sk);
>    826	
>    827			seq_printf(m, "scm_fds: %u\n", nr_fds);
>    828		}
>    829	}
>    830	#else
>    831	#define unix_show_fdinfo NULL
>    832	#endif
>    833	
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ