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]
Message-ID: <202501101459.tVj2wd8p-lkp@intel.com>
Date: Fri, 10 Jan 2025 14:24:02 +0800
From: kernel test robot <lkp@...el.com>
To: Lizhi Xu <lizhi.xu@...driver.com>,
	syzbot+80e60df48923e1b7691d@...kaller.appspotmail.com
Cc: llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
	aivazian.tigran@...il.com, linux-kernel@...r.kernel.org,
	syzkaller-bugs@...glegroups.com
Subject: Re: [PATCH] bfs: put a inode if link count is 0

Hi Lizhi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on brauner-vfs/vfs.all]
[also build test WARNING on linus/master v6.13-rc6 next-20250109]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lizhi-Xu/bfs-put-a-inode-if-link-count-is-0/20250109-123423
base:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link:    https://lore.kernel.org/r/20250109034946.1386748-1-lizhi.xu%40windriver.com
patch subject: [PATCH] bfs: put a inode if link count is 0
config: x86_64-buildonly-randconfig-005-20250110 (https://download.01.org/0day-ci/archive/20250110/202501101459.tVj2wd8p-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250110/202501101459.tVj2wd8p-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501101459.tVj2wd8p-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from fs/bfs/dir.c:12:
   In file included from include/linux/buffer_head.h:12:
   In file included from include/linux/blk_types.h:10:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:8:
   In file included from include/linux/cacheflush.h:5:
   In file included from arch/x86/include/asm/cacheflush.h:5:
   In file included from include/linux/mm.h:2223:
   include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     504 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     505 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     511 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     512 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     524 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     525 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> fs/bfs/dir.c:225:6: warning: variable 'new_inode' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
     225 |         if (!old_bh || (le16_to_cpu(old_de->ino) != old_inode->i_ino))
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/bfs/dir.c:254:6: note: uninitialized use occurs here
     254 |         if (new_inode && !new_inode->i_nlink)
         |             ^~~~~~~~~
   fs/bfs/dir.c:225:2: note: remove the 'if' if its condition is always false
     225 |         if (!old_bh || (le16_to_cpu(old_de->ino) != old_inode->i_ino))
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     226 |                 goto end_rename;
         |                 ~~~~~~~~~~~~~~~
>> fs/bfs/dir.c:225:6: warning: variable 'new_inode' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
     225 |         if (!old_bh || (le16_to_cpu(old_de->ino) != old_inode->i_ino))
         |             ^~~~~~~
   fs/bfs/dir.c:254:6: note: uninitialized use occurs here
     254 |         if (new_inode && !new_inode->i_nlink)
         |             ^~~~~~~~~
   fs/bfs/dir.c:225:6: note: remove the '||' if its condition is always false
     225 |         if (!old_bh || (le16_to_cpu(old_de->ino) != old_inode->i_ino))
         |             ^~~~~~~~~~
   fs/bfs/dir.c:206:37: note: initialize the variable 'new_inode' to silence this warning
     206 |         struct inode *old_inode, *new_inode;
         |                                            ^
         |                                             = NULL
   6 warnings generated.


vim +225 fs/bfs/dir.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  201  
e18275ae55e07a Christian Brauner 2023-01-13  202  static int bfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
549c7297717c32 Christian Brauner 2021-01-21  203  		      struct dentry *old_dentry, struct inode *new_dir,
549c7297717c32 Christian Brauner 2021-01-21  204  		      struct dentry *new_dentry, unsigned int flags)
^1da177e4c3f41 Linus Torvalds    2005-04-16  205  {
^1da177e4c3f41 Linus Torvalds    2005-04-16  206  	struct inode *old_inode, *new_inode;
^1da177e4c3f41 Linus Torvalds    2005-04-16  207  	struct buffer_head *old_bh, *new_bh;
^1da177e4c3f41 Linus Torvalds    2005-04-16  208  	struct bfs_dirent *old_de, *new_de;
3f165e4cf2af04 Dmitri Vorobiev   2008-07-25  209  	struct bfs_sb_info *info;
^1da177e4c3f41 Linus Torvalds    2005-04-16  210  	int error = -ENOENT;
^1da177e4c3f41 Linus Torvalds    2005-04-16  211  
f03b8ad8d38634 Miklos Szeredi    2016-09-27  212  	if (flags & ~RENAME_NOREPLACE)
f03b8ad8d38634 Miklos Szeredi    2016-09-27  213  		return -EINVAL;
f03b8ad8d38634 Miklos Szeredi    2016-09-27  214  
^1da177e4c3f41 Linus Torvalds    2005-04-16  215  	old_bh = new_bh = NULL;
2b0143b5c986be David Howells     2015-03-17  216  	old_inode = d_inode(old_dentry);
^1da177e4c3f41 Linus Torvalds    2005-04-16  217  	if (S_ISDIR(old_inode->i_mode))
^1da177e4c3f41 Linus Torvalds    2005-04-16  218  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds    2005-04-16  219  
3f165e4cf2af04 Dmitri Vorobiev   2008-07-25  220  	info = BFS_SB(old_inode->i_sb);
3f165e4cf2af04 Dmitri Vorobiev   2008-07-25  221  
3f165e4cf2af04 Dmitri Vorobiev   2008-07-25  222  	mutex_lock(&info->bfs_lock);
33ebdebece6d5d Al Viro           2018-04-30  223  	old_bh = bfs_find_entry(old_dir, &old_dentry->d_name, &old_de);
^1da177e4c3f41 Linus Torvalds    2005-04-16  224  
f433dc56344cb7 Dmitri Vorobiev   2007-11-14 @225  	if (!old_bh || (le16_to_cpu(old_de->ino) != old_inode->i_ino))
^1da177e4c3f41 Linus Torvalds    2005-04-16  226  		goto end_rename;
^1da177e4c3f41 Linus Torvalds    2005-04-16  227  
^1da177e4c3f41 Linus Torvalds    2005-04-16  228  	error = -EPERM;
2b0143b5c986be David Howells     2015-03-17  229  	new_inode = d_inode(new_dentry);
33ebdebece6d5d Al Viro           2018-04-30  230  	new_bh = bfs_find_entry(new_dir, &new_dentry->d_name, &new_de);
^1da177e4c3f41 Linus Torvalds    2005-04-16  231  
^1da177e4c3f41 Linus Torvalds    2005-04-16  232  	if (new_bh && !new_inode) {
^1da177e4c3f41 Linus Torvalds    2005-04-16  233  		brelse(new_bh);
^1da177e4c3f41 Linus Torvalds    2005-04-16  234  		new_bh = NULL;
^1da177e4c3f41 Linus Torvalds    2005-04-16  235  	}
^1da177e4c3f41 Linus Torvalds    2005-04-16  236  	if (!new_bh) {
b455ecd4bb4db1 Al Viro           2018-04-30  237  		error = bfs_add_entry(new_dir, &new_dentry->d_name,
f433dc56344cb7 Dmitri Vorobiev   2007-11-14  238  					old_inode->i_ino);
^1da177e4c3f41 Linus Torvalds    2005-04-16  239  		if (error)
^1da177e4c3f41 Linus Torvalds    2005-04-16  240  			goto end_rename;
^1da177e4c3f41 Linus Torvalds    2005-04-16  241  	}
^1da177e4c3f41 Linus Torvalds    2005-04-16  242  	old_de->ino = 0;
ce17a80c388cd1 Jeff Layton       2023-10-04  243  	inode_set_mtime_to_ts(old_dir, inode_set_ctime_current(old_dir));
^1da177e4c3f41 Linus Torvalds    2005-04-16  244  	mark_inode_dirty(old_dir);
^1da177e4c3f41 Linus Torvalds    2005-04-16  245  	if (new_inode) {
73d9b9d028176b Jeff Layton       2023-07-05  246  		inode_set_ctime_current(new_inode);
9a53c3a783c2fa Dave Hansen       2006-09-30  247  		inode_dec_link_count(new_inode);
^1da177e4c3f41 Linus Torvalds    2005-04-16  248  	}
4427f0c36e22e2 Al Viro           2009-06-08  249  	mark_buffer_dirty_inode(old_bh, old_dir);
^1da177e4c3f41 Linus Torvalds    2005-04-16  250  	error = 0;
^1da177e4c3f41 Linus Torvalds    2005-04-16  251  
^1da177e4c3f41 Linus Torvalds    2005-04-16  252  end_rename:
3f165e4cf2af04 Dmitri Vorobiev   2008-07-25  253  	mutex_unlock(&info->bfs_lock);
56423717549f8d Lizhi Xu          2025-01-09 @254  	if (new_inode && !new_inode->i_nlink)
56423717549f8d Lizhi Xu          2025-01-09  255  		iput(new_inode);
^1da177e4c3f41 Linus Torvalds    2005-04-16  256  	brelse(old_bh);
^1da177e4c3f41 Linus Torvalds    2005-04-16  257  	brelse(new_bh);
^1da177e4c3f41 Linus Torvalds    2005-04-16  258  	return error;
^1da177e4c3f41 Linus Torvalds    2005-04-16  259  }
^1da177e4c3f41 Linus Torvalds    2005-04-16  260  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ