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]
Date:   Fri, 28 Apr 2023 08:14:45 +0800
From:   kernel test robot <lkp@...el.com>
To:     Josh Poimboeuf <jpoimboe@...nel.org>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        David Sterba <dsterba@...e.com>
Subject: fs/btrfs/tree-log.c:6211:23: warning: 'last_range_start' may be used
 uninitialized in this function

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d06f5a3f7140921ada47d49574ae6fa4de5e2a89
commit: f372463124df5f980de6ee0cd6000a3e43df0e01 btrfs: mark btrfs_assertfail() __noreturn
date:   10 days ago
config: i386-randconfig-a014 (https://download.01.org/0day-ci/archive/20230428/202304280811.DeQmh7Ky-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build):
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f372463124df5f980de6ee0cd6000a3e43df0e01
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout f372463124df5f980de6ee0cd6000a3e43df0e01
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 olddefconfig
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash fs/btrfs/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304280811.DeQmh7Ky-lkp@intel.com/

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   fs/btrfs/tree-log.c: In function 'log_delayed_deletions_incremental.isra':
>> fs/btrfs/tree-log.c:6211:23: warning: 'last_range_start' may be used uninitialized in this function [-Wmaybe-uninitialized]
    6211 |                 ret = insert_dir_log_key(trans, log, path, key.objectid,
         |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    6212 |                                          first_dir_index, last_dir_index);
         |                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/last_range_start +6211 fs/btrfs/tree-log.c

30b80f3ce0f9d5 Filipe Manana 2022-08-22  6152  
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6153  static int log_delayed_deletions_incremental(struct btrfs_trans_handle *trans,
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6154  					     struct btrfs_inode *inode,
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6155  					     struct btrfs_path *path,
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6156  					     const struct list_head *delayed_del_list,
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6157  					     struct btrfs_log_ctx *ctx)
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6158  {
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6159  	struct btrfs_root *log = inode->root->log_root;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6160  	const struct btrfs_delayed_item *curr;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6161  	u64 last_range_start;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6162  	u64 last_range_end = 0;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6163  	struct btrfs_key key;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6164  
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6165  	key.objectid = btrfs_ino(inode);
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6166  	key.type = BTRFS_DIR_INDEX_KEY;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6167  	curr = list_first_entry(delayed_del_list, struct btrfs_delayed_item,
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6168  				log_list);
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6169  
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6170  	while (!list_entry_is_head(curr, delayed_del_list, log_list)) {
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6171  		const struct btrfs_delayed_item *last = curr;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6172  		u64 first_dir_index = curr->index;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6173  		u64 last_dir_index;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6174  		bool deleted_items = false;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6175  		int ret;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6176  
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6177  		key.offset = curr->index;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6178  		ret = btrfs_search_slot(trans, log, &key, path, -1, 1);
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6179  		if (ret < 0) {
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6180  			return ret;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6181  		} else if (ret == 0) {
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6182  			ret = batch_delete_dir_index_items(trans, inode, path, ctx,
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6183  							   delayed_del_list, curr,
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6184  							   &last);
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6185  			if (ret)
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6186  				return ret;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6187  			deleted_items = true;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6188  		}
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6189  
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6190  		btrfs_release_path(path);
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6191  
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6192  		/*
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6193  		 * If we deleted items from the leaf, it means we have a range
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6194  		 * item logging their range, so no need to add one or update an
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6195  		 * existing one. Otherwise we have to log a dir range item.
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6196  		 */
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6197  		if (deleted_items)
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6198  			goto next_batch;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6199  
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6200  		last_dir_index = last->index;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6201  		ASSERT(last_dir_index >= first_dir_index);
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6202  		/*
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6203  		 * If this range starts right after where the previous one ends,
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6204  		 * then we want to reuse the previous range item and change its
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6205  		 * end offset to the end of this range. This is just to minimize
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6206  		 * leaf space usage, by avoiding adding a new range item.
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6207  		 */
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6208  		if (last_range_end != 0 && first_dir_index == last_range_end + 1)
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6209  			first_dir_index = last_range_start;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6210  
30b80f3ce0f9d5 Filipe Manana 2022-08-22 @6211  		ret = insert_dir_log_key(trans, log, path, key.objectid,
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6212  					 first_dir_index, last_dir_index);
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6213  		if (ret)
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6214  			return ret;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6215  
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6216  		last_range_start = first_dir_index;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6217  		last_range_end = last_dir_index;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6218  next_batch:
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6219  		curr = list_next_entry(last, log_list);
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6220  	}
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6221  
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6222  	return 0;
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6223  }
30b80f3ce0f9d5 Filipe Manana 2022-08-22  6224  

:::::: The code at line 6211 was first introduced by commit
:::::: 30b80f3ce0f9d58ab8a2094922f3d54d2fd4f92e btrfs: use delayed items when logging a directory

:::::: TO: Filipe Manana <fdmanana@...e.com>
:::::: CC: David Sterba <dsterba@...e.com>

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ