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:   Thu, 2 Jun 2022 18:35:54 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, "Darrick J. Wong" <djwong@...nel.org>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        "Darrick J. Wong" <darrick.wong@...cle.com>,
        linux-kernel@...r.kernel.org
Subject: [djwong-xfs:vectorized-scrub 150/401]
 fs/xfs/scrub/nlinks_repair.c:80 xrep_nlinks_repair_inode() warn: missing
 error code 'error'

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux.git vectorized-scrub
head:   1fcd9cea011a657d62ee332d161966c1ec92ffd5
commit: 75be7c3d8d488788289ec6e343e138db5a2b2440 [150/401] xfs: teach repair to fix file nlinks
config: microblaze-randconfig-m031-20220601 (https://download.01.org/0day-ci/archive/20220602/202206022146.2RgP2bEQ-lkp@intel.com/config)
compiler: microblaze-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>

New smatch warnings:
fs/xfs/scrub/nlinks_repair.c:80 xrep_nlinks_repair_inode() warn: missing error code 'error'

vim +/error +80 fs/xfs/scrub/nlinks_repair.c

75be7c3d8d4887 Darrick J. Wong 2022-01-06   42  STATIC int
75be7c3d8d4887 Darrick J. Wong 2022-01-06   43  xrep_nlinks_repair_inode(
75be7c3d8d4887 Darrick J. Wong 2022-01-06   44  	struct xchk_nlink_ctrs	*xnc)
75be7c3d8d4887 Darrick J. Wong 2022-01-06   45  {
75be7c3d8d4887 Darrick J. Wong 2022-01-06   46  	struct xchk_nlink	obs;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   47  	struct xfs_scrub	*sc = xnc->sc;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   48  	struct xfs_mount	*mp = sc->mp;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   49  	struct xfs_inode	*ip = sc->ip;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   50  	uint64_t		total_links;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   51  	unsigned int		actual_nlink;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   52  	int			error;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   53  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   54  	xfs_ilock(ip, XFS_IOLOCK_EXCL);
75be7c3d8d4887 Darrick J. Wong 2022-01-06   55  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   56  	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_link, 0, 0, 0, &sc->tp);
75be7c3d8d4887 Darrick J. Wong 2022-01-06   57  	if (error)
75be7c3d8d4887 Darrick J. Wong 2022-01-06   58  		goto out_iolock;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   59  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   60  	xfs_ilock(ip, XFS_ILOCK_EXCL);
75be7c3d8d4887 Darrick J. Wong 2022-01-06   61  	xfs_trans_ijoin(sc->tp, ip, 0);
75be7c3d8d4887 Darrick J. Wong 2022-01-06   62  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   63  	mutex_lock(&xnc->lock);
75be7c3d8d4887 Darrick J. Wong 2022-01-06   64  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   65  	if (xchk_iscan_aborted(&xnc->collect_iscan)) {
75be7c3d8d4887 Darrick J. Wong 2022-01-06   66  		error = -ECANCELED;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   67  		goto out_scanlock;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   68  	}
75be7c3d8d4887 Darrick J. Wong 2022-01-06   69  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   70  	error = xfarray_load_sparse(xnc->nlinks, ip->i_ino, &obs);
75be7c3d8d4887 Darrick J. Wong 2022-01-06   71  	if (error)
75be7c3d8d4887 Darrick J. Wong 2022-01-06   72  		goto out_scanlock;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   73  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   74  	total_links = xchk_nlink_total(&obs);
75be7c3d8d4887 Darrick J. Wong 2022-01-06   75  	actual_nlink = VFS_I(ip)->i_nlink;
75be7c3d8d4887 Darrick J. Wong 2022-01-06   76  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   77  	/* Cannot set more than the maxiumum possible link count. */
75be7c3d8d4887 Darrick J. Wong 2022-01-06   78  	if (total_links > U32_MAX) {
75be7c3d8d4887 Darrick J. Wong 2022-01-06   79  		trace_xrep_nlinks_unfixable_inode(mp, ip, &obs);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  @80  		goto out_scanlock;

Needs error code

75be7c3d8d4887 Darrick J. Wong 2022-01-06   81  	}
75be7c3d8d4887 Darrick J. Wong 2022-01-06   82  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   83  	/*
75be7c3d8d4887 Darrick J. Wong 2022-01-06   84  	 * Linked directories should have at least one "child" (the dot entry)
75be7c3d8d4887 Darrick J. Wong 2022-01-06   85  	 * pointing up to them.
75be7c3d8d4887 Darrick J. Wong 2022-01-06   86  	 */
75be7c3d8d4887 Darrick J. Wong 2022-01-06   87  	if (S_ISDIR(VFS_I(ip)->i_mode) && actual_nlink > 0 &&
75be7c3d8d4887 Darrick J. Wong 2022-01-06   88  					  obs.children == 0) {
75be7c3d8d4887 Darrick J. Wong 2022-01-06   89  		trace_xrep_nlinks_unfixable_inode(mp, ip, &obs);
75be7c3d8d4887 Darrick J. Wong 2022-01-06   90  		goto out_scanlock;

Here too

75be7c3d8d4887 Darrick J. Wong 2022-01-06   91  	}
75be7c3d8d4887 Darrick J. Wong 2022-01-06   92  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   93  	/* Non-directories cannot have directories pointing up to them. */
75be7c3d8d4887 Darrick J. Wong 2022-01-06   94  	if (!S_ISDIR(VFS_I(ip)->i_mode) && obs.children != 0) {
75be7c3d8d4887 Darrick J. Wong 2022-01-06   95  		trace_xrep_nlinks_unfixable_inode(mp, ip, &obs);
75be7c3d8d4887 Darrick J. Wong 2022-01-06   96  		goto out_scanlock;

Here

75be7c3d8d4887 Darrick J. Wong 2022-01-06   97  	}
75be7c3d8d4887 Darrick J. Wong 2022-01-06   98  
75be7c3d8d4887 Darrick J. Wong 2022-01-06   99  	/*
75be7c3d8d4887 Darrick J. Wong 2022-01-06  100  	 * We did not find any links to this inode.  If the inode agrees, we
75be7c3d8d4887 Darrick J. Wong 2022-01-06  101  	 * have nothing further to do.  If not, the inode has a nonzero link
75be7c3d8d4887 Darrick J. Wong 2022-01-06  102  	 * count and we don't have anywhere to graft the child onto.  Dropping
75be7c3d8d4887 Darrick J. Wong 2022-01-06  103  	 * a live inode's link count to zero can cause unexpected shutdowns in
75be7c3d8d4887 Darrick J. Wong 2022-01-06  104  	 * inactivation, so leave it alone.
75be7c3d8d4887 Darrick J. Wong 2022-01-06  105  	 */
75be7c3d8d4887 Darrick J. Wong 2022-01-06  106  	if (total_links == 0) {
75be7c3d8d4887 Darrick J. Wong 2022-01-06  107  		if (actual_nlink != 0)
75be7c3d8d4887 Darrick J. Wong 2022-01-06  108  			trace_xrep_nlinks_unfixable_inode(mp, ip, &obs);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  109  		goto out_scanlock;

These looks like a success path

75be7c3d8d4887 Darrick J. Wong 2022-01-06  110  	}
75be7c3d8d4887 Darrick J. Wong 2022-01-06  111  
75be7c3d8d4887 Darrick J. Wong 2022-01-06  112  	/* Perfect match means we're done. */
75be7c3d8d4887 Darrick J. Wong 2022-01-06  113  	if (total_links == actual_nlink)
75be7c3d8d4887 Darrick J. Wong 2022-01-06  114  		goto out_scanlock;

Success path

75be7c3d8d4887 Darrick J. Wong 2022-01-06  115  	mutex_unlock(&xnc->lock);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  116  
75be7c3d8d4887 Darrick J. Wong 2022-01-06  117  	/* Commit the new link count. */
75be7c3d8d4887 Darrick J. Wong 2022-01-06  118  	trace_xrep_nlinks_update_inode(mp, ip, &obs);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  119  
75be7c3d8d4887 Darrick J. Wong 2022-01-06  120  	set_nlink(VFS_I(ip), total_links);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  121  	xfs_trans_log_inode(sc->tp, ip, XFS_ILOG_CORE);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  122  	error = xfs_trans_commit(sc->tp);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  123  	sc->tp = NULL;
75be7c3d8d4887 Darrick J. Wong 2022-01-06  124  	if (error)
75be7c3d8d4887 Darrick J. Wong 2022-01-06  125  		goto out_ilock;
75be7c3d8d4887 Darrick J. Wong 2022-01-06  126  
75be7c3d8d4887 Darrick J. Wong 2022-01-06  127  	xfs_iunlock(ip, XFS_ILOCK_EXCL);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  128  	xfs_iunlock(ip, XFS_IOLOCK_EXCL);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  129  	return 0;
75be7c3d8d4887 Darrick J. Wong 2022-01-06  130  
75be7c3d8d4887 Darrick J. Wong 2022-01-06  131  out_scanlock:
75be7c3d8d4887 Darrick J. Wong 2022-01-06  132  	mutex_unlock(&xnc->lock);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  133  	xchk_trans_cancel(sc);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  134  out_ilock:
75be7c3d8d4887 Darrick J. Wong 2022-01-06  135  	xfs_iunlock(ip, XFS_ILOCK_EXCL);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  136  out_iolock:
75be7c3d8d4887 Darrick J. Wong 2022-01-06  137  	xfs_iunlock(ip, XFS_IOLOCK_EXCL);
75be7c3d8d4887 Darrick J. Wong 2022-01-06  138  	return error;
75be7c3d8d4887 Darrick J. Wong 2022-01-06  139  }

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ