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: <20201022095536.GW1042@kadam>
Date:   Thu, 22 Oct 2020 12:55:36 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org,
        Harshad Shirwadkar <harshadshirwadkar@...il.com>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org, linux-ext4@...r.kernel.org,
        "Theodore Ts'o" <tytso@....edu>
Subject: [ext4:dev 41/46] fs/ext4/fast_commit.c:964
 ext4_fc_commit_dentry_updates() error: double locked 'sbi->s_fc_lock' (orig
 line 955)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
head:   1322181170bb01bce3c228b82ae3d5c6b793164f
commit: aa75f4d3daaeb1389b9cce9d6b84401eaf228d4e [41/46] ext4: main fast-commit commit path
config: x86_64-randconfig-m001-20201022 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

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

smatch warnings:
fs/ext4/fast_commit.c:964 ext4_fc_commit_dentry_updates() error: double locked 'sbi->s_fc_lock' (orig line 955)

vim +964 fs/ext4/fast_commit.c

aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  890  static int ext4_fc_commit_dentry_updates(journal_t *journal, u32 *crc)
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  891  {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  892  	struct super_block *sb = (struct super_block *)(journal->j_private);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  893  	struct ext4_sb_info *sbi = EXT4_SB(sb);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  894  	struct ext4_fc_dentry_update *fc_dentry;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  895  	struct inode *inode;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  896  	struct list_head *pos, *n, *fcd_pos, *fcd_n;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  897  	struct ext4_inode_info *ei;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  898  	int ret;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  899  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  900  	if (list_empty(&sbi->s_fc_dentry_q[FC_Q_MAIN]))
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  901  		return 0;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  902  	list_for_each_safe(fcd_pos, fcd_n, &sbi->s_fc_dentry_q[FC_Q_MAIN]) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  903  		fc_dentry = list_entry(fcd_pos, struct ext4_fc_dentry_update,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  904  					fcd_list);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  905  		if (fc_dentry->fcd_op != EXT4_FC_TAG_CREAT) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  906  			spin_unlock(&sbi->s_fc_lock);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  907  			if (!ext4_fc_add_dentry_tlv(
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  908  				sb, fc_dentry->fcd_op,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  909  				fc_dentry->fcd_parent, fc_dentry->fcd_ino,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  910  				fc_dentry->fcd_name.len,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  911  				fc_dentry->fcd_name.name, crc)) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  912  				ret = -ENOSPC;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  913  				goto lock_and_exit;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  914  			}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  915  			spin_lock(&sbi->s_fc_lock);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  916  			continue;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  917  		}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  918  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  919  		inode = NULL;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  920  		list_for_each_safe(pos, n, &sbi->s_fc_q[FC_Q_MAIN]) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  921  			ei = list_entry(pos, struct ext4_inode_info, i_fc_list);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  922  			if (ei->vfs_inode.i_ino == fc_dentry->fcd_ino) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  923  				inode = &ei->vfs_inode;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  924  				break;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  925  			}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  926  		}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  927  		/*
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  928  		 * If we don't find inode in our list, then it was deleted,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  929  		 * in which case, we don't need to record it's create tag.
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  930  		 */
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  931  		if (!inode)
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  932  			continue;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  933  		spin_unlock(&sbi->s_fc_lock);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  934  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  935  		/*
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  936  		 * We first write the inode and then the create dirent. This
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  937  		 * allows the recovery code to create an unnamed inode first
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  938  		 * and then link it to a directory entry. This allows us
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  939  		 * to use namei.c routines almost as is and simplifies
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  940  		 * the recovery code.
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  941  		 */
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  942  		ret = ext4_fc_write_inode(inode, crc);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  943  		if (ret)
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  944  			goto lock_and_exit;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  945  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  946  		ret = ext4_fc_write_inode_data(inode, crc);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  947  		if (ret)
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  948  			goto lock_and_exit;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  949  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  950  		if (!ext4_fc_add_dentry_tlv(
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  951  			sb, fc_dentry->fcd_op,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  952  			fc_dentry->fcd_parent, fc_dentry->fcd_ino,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  953  			fc_dentry->fcd_name.len,
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  954  			fc_dentry->fcd_name.name, crc)) {
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15 @955  			spin_lock(&sbi->s_fc_lock);
                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
Lock.

aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  956  			ret = -ENOSPC;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  957  			goto lock_and_exit;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  958  		}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  959  
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  960  		spin_lock(&sbi->s_fc_lock);
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  961  	}
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  962  	return 0;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  963  lock_and_exit:
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15 @964  	spin_lock(&sbi->s_fc_lock);
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
Second lock.

aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  965  	return ret;
aa75f4d3daaeb13 Harshad Shirwadkar 2020-10-15  966  }

---
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" (35976 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ