[<prev] [next>] [day] [month] [year] [list]
Message-ID: <b4214bce-eb3c-981f-e8bc-2e6d08a84580@intel.com>
Date: Fri, 29 Oct 2021 15:16:38 +0800
From: kernel test robot <yujie.liu@...el.com>
To: Omar Sandoval <osandov@...com>
CC: <llvm@...ts.linux.dev>, <kbuild-all@...ts.01.org>,
Omar Sandoval <osandov@...ndov.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [osandov:btrfs-send-encoded 9/14] fs/btrfs/ioctl.c:4959:15: warning:
Assigned value is garbage or undefined
[clang-analyzer-core.uninitialized.Assign]
tree: https://github.com/osandov/linux.git btrfs-send-encoded
head: b460af84b8ddd4fd78e02fec6272b70326b87861
commit: 0aea17a6398e5a7ecab69537ff062b00f6b9c20f [9/14] btrfs: add BTRFS_IOC_ENCODED_WRITE
config: x86_64-randconfig-c007-20211027 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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/osandov/linux/commit/0aea17a6398e5a7ecab69537ff062b00f6b9c20f
git remote add osandov https://github.com/osandov/linux.git
git fetch --no-tags osandov btrfs-send-encoded
git checkout 0aea17a6398e5a7ecab69537ff062b00f6b9c20f
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
clang-analyzer warnings: (new ones prefixed by >>)
>> fs/btrfs/ioctl.c:4959:15: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
args.iovcnt = args.iovcnt;
^
vim +4959 fs/btrfs/ioctl.c
d38f9ac9a40338 Omar Sandoval 2019-10-09 4928
0aea17a6398e5a Omar Sandoval 2019-08-13 4929 static int btrfs_ioctl_encoded_write(struct file *file, void __user *argp,
0aea17a6398e5a Omar Sandoval 2019-08-13 4930 bool compat)
0aea17a6398e5a Omar Sandoval 2019-08-13 4931 {
0aea17a6398e5a Omar Sandoval 2019-08-13 4932 struct btrfs_ioctl_encoded_io_args args;
0aea17a6398e5a Omar Sandoval 2019-08-13 4933 struct iovec iovstack[UIO_FASTIOV];
0aea17a6398e5a Omar Sandoval 2019-08-13 4934 struct iovec *iov = iovstack;
0aea17a6398e5a Omar Sandoval 2019-08-13 4935 struct iov_iter iter;
0aea17a6398e5a Omar Sandoval 2019-08-13 4936 loff_t pos;
0aea17a6398e5a Omar Sandoval 2019-08-13 4937 struct kiocb kiocb;
0aea17a6398e5a Omar Sandoval 2019-08-13 4938 ssize_t ret;
0aea17a6398e5a Omar Sandoval 2019-08-13 4939
0aea17a6398e5a Omar Sandoval 2019-08-13 4940 if (!capable(CAP_SYS_ADMIN)) {
0aea17a6398e5a Omar Sandoval 2019-08-13 4941 ret = -EPERM;
0aea17a6398e5a Omar Sandoval 2019-08-13 4942 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4943 }
0aea17a6398e5a Omar Sandoval 2019-08-13 4944
0aea17a6398e5a Omar Sandoval 2019-08-13 4945 if (!(file->f_mode & FMODE_WRITE)) {
0aea17a6398e5a Omar Sandoval 2019-08-13 4946 ret = -EBADF;
0aea17a6398e5a Omar Sandoval 2019-08-13 4947 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4948 }
0aea17a6398e5a Omar Sandoval 2019-08-13 4949
0aea17a6398e5a Omar Sandoval 2019-08-13 4950 if (compat) {
0aea17a6398e5a Omar Sandoval 2019-08-13 4951 #if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
0aea17a6398e5a Omar Sandoval 2019-08-13 4952 struct btrfs_ioctl_encoded_io_args_32 args32;
0aea17a6398e5a Omar Sandoval 2019-08-13 4953
0aea17a6398e5a Omar Sandoval 2019-08-13 4954 if (copy_from_user(&args32, argp, sizeof(args32))) {
0aea17a6398e5a Omar Sandoval 2019-08-13 4955 ret = -EFAULT;
0aea17a6398e5a Omar Sandoval 2019-08-13 4956 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4957 }
0aea17a6398e5a Omar Sandoval 2019-08-13 4958 args.iov = compat_ptr(args32.iov);
0aea17a6398e5a Omar Sandoval 2019-08-13 @4959 args.iovcnt = args.iovcnt;
0aea17a6398e5a Omar Sandoval 2019-08-13 4960 memcpy(&args.offset, &args32.offset,
0aea17a6398e5a Omar Sandoval 2019-08-13 4961 sizeof(args) -
0aea17a6398e5a Omar Sandoval 2019-08-13 4962 offsetof(struct btrfs_ioctl_encoded_io_args, offset));
0aea17a6398e5a Omar Sandoval 2019-08-13 4963 #else
0aea17a6398e5a Omar Sandoval 2019-08-13 4964 return -ENOTTY;
0aea17a6398e5a Omar Sandoval 2019-08-13 4965 #endif
0aea17a6398e5a Omar Sandoval 2019-08-13 4966 } else {
0aea17a6398e5a Omar Sandoval 2019-08-13 4967 if (copy_from_user(&args, argp, sizeof(args))) {
0aea17a6398e5a Omar Sandoval 2019-08-13 4968 ret = -EFAULT;
0aea17a6398e5a Omar Sandoval 2019-08-13 4969 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4970 }
0aea17a6398e5a Omar Sandoval 2019-08-13 4971 }
0aea17a6398e5a Omar Sandoval 2019-08-13 4972
0aea17a6398e5a Omar Sandoval 2019-08-13 4973 ret = -EINVAL;
0aea17a6398e5a Omar Sandoval 2019-08-13 4974 if (args.flags != 0)
0aea17a6398e5a Omar Sandoval 2019-08-13 4975 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4976 if (memchr_inv(args.reserved, 0, sizeof(args.reserved)))
0aea17a6398e5a Omar Sandoval 2019-08-13 4977 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4978 if (args.compression == BTRFS_ENCODED_IO_COMPRESSION_NONE &&
0aea17a6398e5a Omar Sandoval 2019-08-13 4979 args.encryption == BTRFS_ENCODED_IO_ENCRYPTION_NONE)
0aea17a6398e5a Omar Sandoval 2019-08-13 4980 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4981 if (args.compression >= BTRFS_ENCODED_IO_COMPRESSION_TYPES ||
0aea17a6398e5a Omar Sandoval 2019-08-13 4982 args.encryption >= BTRFS_ENCODED_IO_ENCRYPTION_TYPES)
0aea17a6398e5a Omar Sandoval 2019-08-13 4983 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4984 if (args.unencoded_offset > args.unencoded_len)
0aea17a6398e5a Omar Sandoval 2019-08-13 4985 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4986 if (args.len > args.unencoded_len - args.unencoded_offset)
0aea17a6398e5a Omar Sandoval 2019-08-13 4987 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4988
0aea17a6398e5a Omar Sandoval 2019-08-13 4989 ret = import_iovec(WRITE, args.iov, args.iovcnt, ARRAY_SIZE(iovstack),
0aea17a6398e5a Omar Sandoval 2019-08-13 4990 &iov, &iter);
0aea17a6398e5a Omar Sandoval 2019-08-13 4991 if (ret < 0)
0aea17a6398e5a Omar Sandoval 2019-08-13 4992 goto out_acct;
0aea17a6398e5a Omar Sandoval 2019-08-13 4993
0aea17a6398e5a Omar Sandoval 2019-08-13 4994 file_start_write(file);
0aea17a6398e5a Omar Sandoval 2019-08-13 4995
0aea17a6398e5a Omar Sandoval 2019-08-13 4996 if (iov_iter_count(&iter) == 0) {
0aea17a6398e5a Omar Sandoval 2019-08-13 4997 ret = 0;
0aea17a6398e5a Omar Sandoval 2019-08-13 4998 goto out_end_write;
0aea17a6398e5a Omar Sandoval 2019-08-13 4999 }
0aea17a6398e5a Omar Sandoval 2019-08-13 5000 pos = args.offset;
0aea17a6398e5a Omar Sandoval 2019-08-13 5001 ret = rw_verify_area(WRITE, file, &pos, args.len);
0aea17a6398e5a Omar Sandoval 2019-08-13 5002 if (ret < 0)
0aea17a6398e5a Omar Sandoval 2019-08-13 5003 goto out_end_write;
0aea17a6398e5a Omar Sandoval 2019-08-13 5004
0aea17a6398e5a Omar Sandoval 2019-08-13 5005 init_sync_kiocb(&kiocb, file);
0aea17a6398e5a Omar Sandoval 2019-08-13 5006 ret = kiocb_set_rw_flags(&kiocb, 0);
0aea17a6398e5a Omar Sandoval 2019-08-13 5007 if (ret)
0aea17a6398e5a Omar Sandoval 2019-08-13 5008 goto out_end_write;
0aea17a6398e5a Omar Sandoval 2019-08-13 5009 kiocb.ki_pos = pos;
0aea17a6398e5a Omar Sandoval 2019-08-13 5010
0aea17a6398e5a Omar Sandoval 2019-08-13 5011 ret = btrfs_do_write_iter(&kiocb, &iter, &args);
0aea17a6398e5a Omar Sandoval 2019-08-13 5012 if (ret > 0)
0aea17a6398e5a Omar Sandoval 2019-08-13 5013 fsnotify_modify(file);
0aea17a6398e5a Omar Sandoval 2019-08-13 5014
0aea17a6398e5a Omar Sandoval 2019-08-13 5015 out_end_write:
0aea17a6398e5a Omar Sandoval 2019-08-13 5016 file_end_write(file);
0aea17a6398e5a Omar Sandoval 2019-08-13 5017 kfree(iov);
0aea17a6398e5a Omar Sandoval 2019-08-13 5018 out_acct:
0aea17a6398e5a Omar Sandoval 2019-08-13 5019 if (ret > 0)
0aea17a6398e5a Omar Sandoval 2019-08-13 5020 add_wchar(current, ret);
0aea17a6398e5a Omar Sandoval 2019-08-13 5021 inc_syscw(current);
0aea17a6398e5a Omar Sandoval 2019-08-13 5022 return ret;
0aea17a6398e5a Omar Sandoval 2019-08-13 5023 }
0aea17a6398e5a Omar Sandoval 2019-08-13 5024
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (39328 bytes)
Powered by blists - more mailing lists