llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Chuck Lever <chuck.lever@oracle.com>
Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org
Subject: [cel:topic-rpc-with-tls-upcall 5/21] net/tls/af_tlsh.c:635:6: warning: variable 'outlen' is used uninitialized whenever 'if' condition is true
Date: Thu, 14 Apr 2022 19:59:56 +0800	[thread overview]
Message-ID: <202204141943.5IfaboCX-lkp@intel.com> (raw)

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux topic-rpc-with-tls-upcall
head:   77d1002f5a5209bebd901cf895b52730199c0ba4
commit: 10e1271d05810b1163c4e79bc9597c0177e2aaeb [5/21] net/tls: Add support for PF_TLSH (a TLS handshake listener)
config: x86_64-randconfig-a005 (https://download.01.org/0day-ci/archive/20220414/202204141943.5IfaboCX-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 6b7e6ea489f6dd45a9b0da9ac20871560917b9b0)
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://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/commit/?id=10e1271d05810b1163c4e79bc9597c0177e2aaeb
        git remote add cel git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
        git fetch --no-tags cel topic-rpc-with-tls-upcall
        git checkout 10e1271d05810b1163c4e79bc9597c0177e2aaeb
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash net/tls/

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

All warnings (new ones prefixed by >>):

>> net/tls/af_tlsh.c:635:6: warning: variable 'outlen' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (val) {
               ^~~
   net/tls/af_tlsh.c:647:15: note: uninitialized use occurs here
           if (put_user(outlen, optlen))
                        ^~~~~~
   arch/x86/include/asm/uaccess.h:225:70: note: expanded from macro 'put_user'
   #define put_user(x, ptr) ({ might_fault(); do_put_user_call(put_user,x,ptr); })
                                                                        ^
   arch/x86/include/asm/uaccess.h:197:14: note: expanded from macro 'do_put_user_call'
           __val_pu = (x);                                                 \
                       ^
   net/tls/af_tlsh.c:635:2: note: remove the 'if' if its condition is always false
           if (val) {
           ^~~~~~~~~~
   net/tls/af_tlsh.c:611:12: note: initialize the variable 'outlen' to silence this warning
           int outlen, len, ret;
                     ^
                      = 0
   1 warning generated.


vim +635 net/tls/af_tlsh.c

   606	
   607	static int tlsh_getsockopt_priorities(struct sock *sk, char __user *optval,
   608					      int __user *optlen)
   609	{
   610		struct tlsh_sock_info *info;
   611		int outlen, len, ret;
   612		const char *val;
   613	
   614		if (get_user(len, optlen))
   615			return -EFAULT;
   616		if (!optval)
   617			return -EINVAL;
   618	
   619		ret = 0;
   620	
   621		sock_hold(sk);
   622		write_lock_bh(&sk->sk_callback_lock);
   623	
   624		info = sk->sk_tlsh_priv;
   625		if (info) {
   626			val = info->tsi_tls_priorities;
   627		} else {
   628			write_unlock_bh(&sk->sk_callback_lock);
   629			ret = -EBUSY;
   630			goto out_put;
   631		}
   632	
   633		write_unlock_bh(&sk->sk_callback_lock);
   634	
 > 635		if (val) {
   636			int outlen = strlen(val);
   637	
   638			if (len < outlen)
   639				ret = -EINVAL;
   640			else if (copy_to_user(optval, val, outlen))
   641				ret = -EFAULT;
   642		} else {
   643			outlen = 0;
   644		}
   645	
   646	
   647		if (put_user(outlen, optlen))
   648			ret = -EFAULT;
   649	
   650	out_put:
   651		sock_put(sk);
   652		return ret;
   653	}
   654	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

                 reply	other threads:[~2022-04-14 12:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202204141943.5IfaboCX-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=chuck.lever@oracle.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).