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>] [day] [month] [year] [list]
Message-ID: <202207091909.wE5ZdB1d-lkp@intel.com>
Date:   Tue, 12 Jul 2022 13:50:33 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Stefan Roesch <shr@...com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org, Filipe Manana <fdmanana@...e.com>,
        David Sterba <dsterba@...e.com>
Subject: [fdmanana:dio_fixes 3/42] fs/btrfs/sysfs.c:811
 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git dio_fixes
head:   f01450d13f24e9a01436b60f5f2596ef650c790f
commit: fce393f3e59414984ba87693911080747b08ed09 [3/42] btrfs: sysfs: add force_chunk_alloc trigger to force allocation
config: riscv-randconfig-m031-20220709
compiler: riscv32-linux-gcc (GCC) 11.3.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

smatch warnings:
fs/btrfs/sysfs.c:811 btrfs_force_chunk_alloc_store() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +811 fs/btrfs/sysfs.c

fce393f3e59414 Stefan Roesch 2022-02-08  782  static ssize_t btrfs_force_chunk_alloc_store(struct kobject *kobj,
fce393f3e59414 Stefan Roesch 2022-02-08  783  					     struct kobj_attribute *a,
fce393f3e59414 Stefan Roesch 2022-02-08  784  					     const char *buf, size_t len)
fce393f3e59414 Stefan Roesch 2022-02-08  785  {
fce393f3e59414 Stefan Roesch 2022-02-08  786  	struct btrfs_space_info *space_info = to_space_info(kobj);
fce393f3e59414 Stefan Roesch 2022-02-08  787  	struct btrfs_fs_info *fs_info = to_fs_info(get_btrfs_kobj(kobj));
fce393f3e59414 Stefan Roesch 2022-02-08  788  	struct btrfs_trans_handle *trans;
fce393f3e59414 Stefan Roesch 2022-02-08  789  	bool val;
fce393f3e59414 Stefan Roesch 2022-02-08  790  	int ret;
fce393f3e59414 Stefan Roesch 2022-02-08  791  
fce393f3e59414 Stefan Roesch 2022-02-08  792  	if (!capable(CAP_SYS_ADMIN))
fce393f3e59414 Stefan Roesch 2022-02-08  793  		return -EPERM;
fce393f3e59414 Stefan Roesch 2022-02-08  794  
fce393f3e59414 Stefan Roesch 2022-02-08  795  	if (sb_rdonly(fs_info->sb))
fce393f3e59414 Stefan Roesch 2022-02-08  796  		return -EROFS;
fce393f3e59414 Stefan Roesch 2022-02-08  797  
fce393f3e59414 Stefan Roesch 2022-02-08  798  	ret = kstrtobool(buf, &val);
fce393f3e59414 Stefan Roesch 2022-02-08  799  	if (ret)
fce393f3e59414 Stefan Roesch 2022-02-08  800  		return ret;
fce393f3e59414 Stefan Roesch 2022-02-08  801  
fce393f3e59414 Stefan Roesch 2022-02-08  802  	if (!val)
fce393f3e59414 Stefan Roesch 2022-02-08  803  		return -EINVAL;
fce393f3e59414 Stefan Roesch 2022-02-08  804  
fce393f3e59414 Stefan Roesch 2022-02-08  805  	/*
fce393f3e59414 Stefan Roesch 2022-02-08  806  	 * This is unsafe to be called from sysfs context and may cause
fce393f3e59414 Stefan Roesch 2022-02-08  807  	 * unexpected problems.
fce393f3e59414 Stefan Roesch 2022-02-08  808  	 */
fce393f3e59414 Stefan Roesch 2022-02-08  809  	trans = btrfs_start_transaction(fs_info->tree_root, 0);
fce393f3e59414 Stefan Roesch 2022-02-08  810  	if (!trans)
fce393f3e59414 Stefan Roesch 2022-02-08 @811  		return PTR_ERR(trans);

This bug is already fixed upstread.  Need to pull the NULL -> IS_ERR()
patch.

fce393f3e59414 Stefan Roesch 2022-02-08  812  	ret = btrfs_force_chunk_alloc(trans, space_info->flags);
fce393f3e59414 Stefan Roesch 2022-02-08  813  	btrfs_end_transaction(trans);
fce393f3e59414 Stefan Roesch 2022-02-08  814  
fce393f3e59414 Stefan Roesch 2022-02-08  815  	if (ret == 1)
fce393f3e59414 Stefan Roesch 2022-02-08  816  		return len;
fce393f3e59414 Stefan Roesch 2022-02-08  817  
fce393f3e59414 Stefan Roesch 2022-02-08  818  	return -ENOSPC;
fce393f3e59414 Stefan Roesch 2022-02-08  819  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ