All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [gfs2:for-next.bob7f 4/13] fs/gfs2/super.c:1477 gfs2_evict_inode() error: we previously assumed 'ip->i_gl' could be null (see line 1444)
Date: Thu, 10 Sep 2020 12:41:56 +0300	[thread overview]
Message-ID: <20200910094156.GC12635@kadam> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git for-next.bob7f
head:   9b2e9f0e3902b232aa1f42465798b9afe2b18456
commit: 63bfc8f5b775576dd4c2efe0213bb83c614b673a [4/13] gfs2: truncate glock address space pages during evict
config: x86_64-randconfig-m001-20200909 (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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
fs/gfs2/super.c:1477 gfs2_evict_inode() error: we previously assumed 'ip->i_gl' could be null (see line 1444)

# https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/?id=63bfc8f5b775576dd4c2efe0213bb83c614b673a
git remote add gfs2 https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git
git fetch --no-tags gfs2 for-next.bob7f
git checkout 63bfc8f5b775576dd4c2efe0213bb83c614b673a
vim +1477 fs/gfs2/super.c

b76b6cdf7aa4710 Bob Peterson        2020-09-01  1430  static void gfs2_evict_inode(struct inode *inode)
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1431  {
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1432  	struct super_block *sb = inode->i_sb;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1433  	struct gfs2_sbd *sdp = sb->s_fs_info;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1434  	struct gfs2_inode *ip = GFS2_I(inode);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1435  	struct gfs2_holder gh;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1436  	struct address_space *metamapping;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1437  	int error;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1438  
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1439  	if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1440  		clear_inode(inode);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1441  		return;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1442  	}
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1443  
63bfc8f5b775576 Bob Peterson        2020-09-01 @1444  	metamapping = ip->i_gl ? gfs2_glock2aspace(ip->i_gl) : NULL;
                                                                      ^^^^^^^^
NULL check

b76b6cdf7aa4710 Bob Peterson        2020-09-01  1445  	if (inode->i_nlink || sb_rdonly(sb))
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1446  		goto out;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1447  
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1448  	gfs2_holder_mark_uninitialized(&gh);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1449  	error = evict_unlinked(inode, &gh);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1450  	if (error == -EEXIST) /* this gets ignored */
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1451  		goto out;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1452  	if (error)
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1453  		goto out_unlock;
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1454  
805c090750a315c Bob Peterson        2018-01-08  1455  	gfs2_log_flush(sdp, ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
805c090750a315c Bob Peterson        2018-01-08  1456  		       GFS2_LFC_EVICT_INODE);
2216db70c95a961 Benjamin Marzinski  2012-09-20  1457  	if (test_bit(GLF_DIRTY, &ip->i_gl->gl_flags)) {
2216db70c95a961 Benjamin Marzinski  2012-09-20  1458  		filemap_fdatawrite(metamapping);
2216db70c95a961 Benjamin Marzinski  2012-09-20  1459  		filemap_fdatawait(metamapping);
2216db70c95a961 Benjamin Marzinski  2012-09-20  1460  	}
40ac218f52aa5ca Steven Whitehouse   2011-08-02  1461  	write_inode_now(inode, 1);
b5b24d7aeb96089 Steven Whitehouse   2011-09-07  1462  	gfs2_ail_flush(ip->i_gl, 0);
40ac218f52aa5ca Steven Whitehouse   2011-08-02  1463  
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1464  	error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1465  	if (error)
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1466  		goto out_unlock;
380f7c65a7eb328 Steven Whitehouse   2011-07-14  1467  	/* Needs to be done before glock release & also in a transaction */
380f7c65a7eb328 Steven Whitehouse   2011-07-14  1468  	truncate_inode_pages(&inode->i_data, 0);
ee530beafeca982 Bob Peterson        2015-12-07  1469  	truncate_inode_pages(metamapping, 0);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1470  	gfs2_trans_end(sdp);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1471  
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1472  out_unlock:
a097dc7e24cba79 Bob Peterson        2015-07-16  1473  	if (gfs2_rs_active(&ip->i_res))
a097dc7e24cba79 Bob Peterson        2015-07-16  1474  		gfs2_rs_deltree(&ip->i_res);
8e2e00473598dd5 Bob Peterson        2012-07-19  1475  
240c6235dfe4fe4 Bob Peterson        2017-07-18  1476  	if (gfs2_holder_initialized(&gh)) {
240c6235dfe4fe4 Bob Peterson        2017-07-18 @1477  		glock_clear_object(ip->i_gl, ip);
                                                                                    ^^^^^^^
Unchecked dereference inside function.

9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1478  		gfs2_glock_dq_uninit(&gh);
240c6235dfe4fe4 Bob Peterson        2017-07-18  1479  	}
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1480  	if (error && error != GLR_TRYFAILED && error != -EROFS)
d5c1515cf374951 Al Viro             2010-06-07  1481  		fs_warn(sdp, "gfs2_evict_inode: %d\n", error);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1482  out:
63bfc8f5b775576 Bob Peterson        2020-09-01  1483  	/* The following calls to truncate_inode_pages_final are not within
63bfc8f5b775576 Bob Peterson        2020-09-01  1484  	 * a transaction, so it's a bug if the inode still has dirty pages. */
63bfc8f5b775576 Bob Peterson        2020-09-01  1485  	BUG_ON(!gfs2_withdrawn(sdp) && inode->i_state & I_DIRTY);
91b0abe36a7b2b3 Johannes Weiner     2014-04-03  1486  	truncate_inode_pages_final(&inode->i_data);
63bfc8f5b775576 Bob Peterson        2020-09-01  1487  	if (metamapping)
63bfc8f5b775576 Bob Peterson        2020-09-01  1488  		truncate_inode_pages_final(metamapping);
2fba46a04c383f9 Bob Peterson        2020-02-27  1489  	if (ip->i_qadata)
2fba46a04c383f9 Bob Peterson        2020-02-27  1490  		gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1595548fe72ca83 Andreas Gruenbacher 2020-03-06  1491  	gfs2_rs_delete(ip, NULL);
4513899092b3254 Steven Whitehouse   2013-01-28  1492  	gfs2_ordered_del_inode(ip);
dbd5768f87ff6fb Jan Kara            2012-05-03  1493  	clear_inode(inode);
17d539f0499fa2c Steven Whitehouse   2011-06-15  1494  	gfs2_dir_hash_inval(ip);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1495  	if (ip->i_gl) {
df3d87bde121213 Bob Peterson        2017-07-18  1496  		glock_clear_object(ip->i_gl, ip);
4fd1a5795214bc6 Andreas Gruenbacher 2017-06-30  1497  		wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
29687a2ac8dfcd5 Steven Whitehouse   2011-03-30  1498  		gfs2_glock_add_to_lru(ip->i_gl);
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1499  		gfs2_glock_put_eventually(ip->i_gl);
d5c1515cf374951 Al Viro             2010-06-07  1500  		ip->i_gl = NULL;
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1501  	}
6df9f9a253c7dc9 Andreas Gruenbacher 2016-06-17  1502  	if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1503  		struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1504  
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1505  		glock_clear_object(gl, ip);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1506  		if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
a6a4d98b0124b5d Bob Peterson        2013-05-29  1507  			ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1508  			gfs2_glock_dq(&ip->i_iopen_gh);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1509  		}
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1510  		gfs2_glock_hold(gl);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1511  		gfs2_holder_uninit(&ip->i_iopen_gh);
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1512  		gfs2_glock_put_eventually(gl);
d5c1515cf374951 Al Viro             2010-06-07  1513  	}
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1514  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all at lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 50057 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20200910/4d1acfec/attachment.gz>

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [gfs2:for-next.bob7f 4/13] fs/gfs2/super.c:1477 gfs2_evict_inode() error: we previously assumed 'ip->i_gl' could be null (see line 1444)
Date: Thu, 10 Sep 2020 12:41:56 +0300	[thread overview]
Message-ID: <20200910094156.GC12635@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 8525 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git for-next.bob7f
head:   9b2e9f0e3902b232aa1f42465798b9afe2b18456
commit: 63bfc8f5b775576dd4c2efe0213bb83c614b673a [4/13] gfs2: truncate glock address space pages during evict
config: x86_64-randconfig-m001-20200909 (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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
fs/gfs2/super.c:1477 gfs2_evict_inode() error: we previously assumed 'ip->i_gl' could be null (see line 1444)

# https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/?id=63bfc8f5b775576dd4c2efe0213bb83c614b673a
git remote add gfs2 https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git
git fetch --no-tags gfs2 for-next.bob7f
git checkout 63bfc8f5b775576dd4c2efe0213bb83c614b673a
vim +1477 fs/gfs2/super.c

b76b6cdf7aa4710 Bob Peterson        2020-09-01  1430  static void gfs2_evict_inode(struct inode *inode)
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1431  {
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1432  	struct super_block *sb = inode->i_sb;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1433  	struct gfs2_sbd *sdp = sb->s_fs_info;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1434  	struct gfs2_inode *ip = GFS2_I(inode);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1435  	struct gfs2_holder gh;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1436  	struct address_space *metamapping;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1437  	int error;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1438  
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1439  	if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1440  		clear_inode(inode);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1441  		return;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1442  	}
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1443  
63bfc8f5b775576 Bob Peterson        2020-09-01 @1444  	metamapping = ip->i_gl ? gfs2_glock2aspace(ip->i_gl) : NULL;
                                                                      ^^^^^^^^
NULL check

b76b6cdf7aa4710 Bob Peterson        2020-09-01  1445  	if (inode->i_nlink || sb_rdonly(sb))
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1446  		goto out;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1447  
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1448  	gfs2_holder_mark_uninitialized(&gh);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1449  	error = evict_unlinked(inode, &gh);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1450  	if (error == -EEXIST) /* this gets ignored */
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1451  		goto out;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1452  	if (error)
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1453  		goto out_unlock;
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1454  
805c090750a315c Bob Peterson        2018-01-08  1455  	gfs2_log_flush(sdp, ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
805c090750a315c Bob Peterson        2018-01-08  1456  		       GFS2_LFC_EVICT_INODE);
2216db70c95a961 Benjamin Marzinski  2012-09-20  1457  	if (test_bit(GLF_DIRTY, &ip->i_gl->gl_flags)) {
2216db70c95a961 Benjamin Marzinski  2012-09-20  1458  		filemap_fdatawrite(metamapping);
2216db70c95a961 Benjamin Marzinski  2012-09-20  1459  		filemap_fdatawait(metamapping);
2216db70c95a961 Benjamin Marzinski  2012-09-20  1460  	}
40ac218f52aa5ca Steven Whitehouse   2011-08-02  1461  	write_inode_now(inode, 1);
b5b24d7aeb96089 Steven Whitehouse   2011-09-07  1462  	gfs2_ail_flush(ip->i_gl, 0);
40ac218f52aa5ca Steven Whitehouse   2011-08-02  1463  
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1464  	error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1465  	if (error)
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1466  		goto out_unlock;
380f7c65a7eb328 Steven Whitehouse   2011-07-14  1467  	/* Needs to be done before glock release & also in a transaction */
380f7c65a7eb328 Steven Whitehouse   2011-07-14  1468  	truncate_inode_pages(&inode->i_data, 0);
ee530beafeca982 Bob Peterson        2015-12-07  1469  	truncate_inode_pages(metamapping, 0);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1470  	gfs2_trans_end(sdp);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1471  
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1472  out_unlock:
a097dc7e24cba79 Bob Peterson        2015-07-16  1473  	if (gfs2_rs_active(&ip->i_res))
a097dc7e24cba79 Bob Peterson        2015-07-16  1474  		gfs2_rs_deltree(&ip->i_res);
8e2e00473598dd5 Bob Peterson        2012-07-19  1475  
240c6235dfe4fe4 Bob Peterson        2017-07-18  1476  	if (gfs2_holder_initialized(&gh)) {
240c6235dfe4fe4 Bob Peterson        2017-07-18 @1477  		glock_clear_object(ip->i_gl, ip);
                                                                                    ^^^^^^^
Unchecked dereference inside function.

9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1478  		gfs2_glock_dq_uninit(&gh);
240c6235dfe4fe4 Bob Peterson        2017-07-18  1479  	}
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1480  	if (error && error != GLR_TRYFAILED && error != -EROFS)
d5c1515cf374951 Al Viro             2010-06-07  1481  		fs_warn(sdp, "gfs2_evict_inode: %d\n", error);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1482  out:
63bfc8f5b775576 Bob Peterson        2020-09-01  1483  	/* The following calls to truncate_inode_pages_final are not within
63bfc8f5b775576 Bob Peterson        2020-09-01  1484  	 * a transaction, so it's a bug if the inode still has dirty pages. */
63bfc8f5b775576 Bob Peterson        2020-09-01  1485  	BUG_ON(!gfs2_withdrawn(sdp) && inode->i_state & I_DIRTY);
91b0abe36a7b2b3 Johannes Weiner     2014-04-03  1486  	truncate_inode_pages_final(&inode->i_data);
63bfc8f5b775576 Bob Peterson        2020-09-01  1487  	if (metamapping)
63bfc8f5b775576 Bob Peterson        2020-09-01  1488  		truncate_inode_pages_final(metamapping);
2fba46a04c383f9 Bob Peterson        2020-02-27  1489  	if (ip->i_qadata)
2fba46a04c383f9 Bob Peterson        2020-02-27  1490  		gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1595548fe72ca83 Andreas Gruenbacher 2020-03-06  1491  	gfs2_rs_delete(ip, NULL);
4513899092b3254 Steven Whitehouse   2013-01-28  1492  	gfs2_ordered_del_inode(ip);
dbd5768f87ff6fb Jan Kara            2012-05-03  1493  	clear_inode(inode);
17d539f0499fa2c Steven Whitehouse   2011-06-15  1494  	gfs2_dir_hash_inval(ip);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1495  	if (ip->i_gl) {
df3d87bde121213 Bob Peterson        2017-07-18  1496  		glock_clear_object(ip->i_gl, ip);
4fd1a5795214bc6 Andreas Gruenbacher 2017-06-30  1497  		wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
29687a2ac8dfcd5 Steven Whitehouse   2011-03-30  1498  		gfs2_glock_add_to_lru(ip->i_gl);
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1499  		gfs2_glock_put_eventually(ip->i_gl);
d5c1515cf374951 Al Viro             2010-06-07  1500  		ip->i_gl = NULL;
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1501  	}
6df9f9a253c7dc9 Andreas Gruenbacher 2016-06-17  1502  	if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1503  		struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1504  
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1505  		glock_clear_object(gl, ip);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1506  		if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
a6a4d98b0124b5d Bob Peterson        2013-05-29  1507  			ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1508  			gfs2_glock_dq(&ip->i_iopen_gh);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1509  		}
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1510  		gfs2_glock_hold(gl);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1511  		gfs2_holder_uninit(&ip->i_iopen_gh);
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1512  		gfs2_glock_put_eventually(gl);
d5c1515cf374951 Al Viro             2010-06-07  1513  	}
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1514  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 50057 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [gfs2:for-next.bob7f 4/13] fs/gfs2/super.c:1477 gfs2_evict_inode() error: we previously assumed 'ip->i_gl' could be null (see line 1444)
Date: Thu, 10 Sep 2020 12:41:56 +0300	[thread overview]
Message-ID: <20200910094156.GC12635@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 8525 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git for-next.bob7f
head:   9b2e9f0e3902b232aa1f42465798b9afe2b18456
commit: 63bfc8f5b775576dd4c2efe0213bb83c614b673a [4/13] gfs2: truncate glock address space pages during evict
config: x86_64-randconfig-m001-20200909 (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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
fs/gfs2/super.c:1477 gfs2_evict_inode() error: we previously assumed 'ip->i_gl' could be null (see line 1444)

# https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/?id=63bfc8f5b775576dd4c2efe0213bb83c614b673a
git remote add gfs2 https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git
git fetch --no-tags gfs2 for-next.bob7f
git checkout 63bfc8f5b775576dd4c2efe0213bb83c614b673a
vim +1477 fs/gfs2/super.c

b76b6cdf7aa4710 Bob Peterson        2020-09-01  1430  static void gfs2_evict_inode(struct inode *inode)
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1431  {
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1432  	struct super_block *sb = inode->i_sb;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1433  	struct gfs2_sbd *sdp = sb->s_fs_info;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1434  	struct gfs2_inode *ip = GFS2_I(inode);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1435  	struct gfs2_holder gh;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1436  	struct address_space *metamapping;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1437  	int error;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1438  
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1439  	if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1440  		clear_inode(inode);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1441  		return;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1442  	}
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1443  
63bfc8f5b775576 Bob Peterson        2020-09-01 @1444  	metamapping = ip->i_gl ? gfs2_glock2aspace(ip->i_gl) : NULL;
                                                                      ^^^^^^^^
NULL check

b76b6cdf7aa4710 Bob Peterson        2020-09-01  1445  	if (inode->i_nlink || sb_rdonly(sb))
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1446  		goto out;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1447  
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1448  	gfs2_holder_mark_uninitialized(&gh);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1449  	error = evict_unlinked(inode, &gh);
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1450  	if (error == -EEXIST) /* this gets ignored */
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1451  		goto out;
b76b6cdf7aa4710 Bob Peterson        2020-09-01  1452  	if (error)
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1453  		goto out_unlock;
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1454  
805c090750a315c Bob Peterson        2018-01-08  1455  	gfs2_log_flush(sdp, ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
805c090750a315c Bob Peterson        2018-01-08  1456  		       GFS2_LFC_EVICT_INODE);
2216db70c95a961 Benjamin Marzinski  2012-09-20  1457  	if (test_bit(GLF_DIRTY, &ip->i_gl->gl_flags)) {
2216db70c95a961 Benjamin Marzinski  2012-09-20  1458  		filemap_fdatawrite(metamapping);
2216db70c95a961 Benjamin Marzinski  2012-09-20  1459  		filemap_fdatawait(metamapping);
2216db70c95a961 Benjamin Marzinski  2012-09-20  1460  	}
40ac218f52aa5ca Steven Whitehouse   2011-08-02  1461  	write_inode_now(inode, 1);
b5b24d7aeb96089 Steven Whitehouse   2011-09-07  1462  	gfs2_ail_flush(ip->i_gl, 0);
40ac218f52aa5ca Steven Whitehouse   2011-08-02  1463  
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1464  	error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1465  	if (error)
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1466  		goto out_unlock;
380f7c65a7eb328 Steven Whitehouse   2011-07-14  1467  	/* Needs to be done before glock release & also in a transaction */
380f7c65a7eb328 Steven Whitehouse   2011-07-14  1468  	truncate_inode_pages(&inode->i_data, 0);
ee530beafeca982 Bob Peterson        2015-12-07  1469  	truncate_inode_pages(metamapping, 0);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1470  	gfs2_trans_end(sdp);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1471  
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1472  out_unlock:
a097dc7e24cba79 Bob Peterson        2015-07-16  1473  	if (gfs2_rs_active(&ip->i_res))
a097dc7e24cba79 Bob Peterson        2015-07-16  1474  		gfs2_rs_deltree(&ip->i_res);
8e2e00473598dd5 Bob Peterson        2012-07-19  1475  
240c6235dfe4fe4 Bob Peterson        2017-07-18  1476  	if (gfs2_holder_initialized(&gh)) {
240c6235dfe4fe4 Bob Peterson        2017-07-18 @1477  		glock_clear_object(ip->i_gl, ip);
                                                                                    ^^^^^^^
Unchecked dereference inside function.

9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1478  		gfs2_glock_dq_uninit(&gh);
240c6235dfe4fe4 Bob Peterson        2017-07-18  1479  	}
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1480  	if (error && error != GLR_TRYFAILED && error != -EROFS)
d5c1515cf374951 Al Viro             2010-06-07  1481  		fs_warn(sdp, "gfs2_evict_inode: %d\n", error);
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1482  out:
63bfc8f5b775576 Bob Peterson        2020-09-01  1483  	/* The following calls to truncate_inode_pages_final are not within
63bfc8f5b775576 Bob Peterson        2020-09-01  1484  	 * a transaction, so it's a bug if the inode still has dirty pages. */
63bfc8f5b775576 Bob Peterson        2020-09-01  1485  	BUG_ON(!gfs2_withdrawn(sdp) && inode->i_state & I_DIRTY);
91b0abe36a7b2b3 Johannes Weiner     2014-04-03  1486  	truncate_inode_pages_final(&inode->i_data);
63bfc8f5b775576 Bob Peterson        2020-09-01  1487  	if (metamapping)
63bfc8f5b775576 Bob Peterson        2020-09-01  1488  		truncate_inode_pages_final(metamapping);
2fba46a04c383f9 Bob Peterson        2020-02-27  1489  	if (ip->i_qadata)
2fba46a04c383f9 Bob Peterson        2020-02-27  1490  		gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1595548fe72ca83 Andreas Gruenbacher 2020-03-06  1491  	gfs2_rs_delete(ip, NULL);
4513899092b3254 Steven Whitehouse   2013-01-28  1492  	gfs2_ordered_del_inode(ip);
dbd5768f87ff6fb Jan Kara            2012-05-03  1493  	clear_inode(inode);
17d539f0499fa2c Steven Whitehouse   2011-06-15  1494  	gfs2_dir_hash_inval(ip);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1495  	if (ip->i_gl) {
df3d87bde121213 Bob Peterson        2017-07-18  1496  		glock_clear_object(ip->i_gl, ip);
4fd1a5795214bc6 Andreas Gruenbacher 2017-06-30  1497  		wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
29687a2ac8dfcd5 Steven Whitehouse   2011-03-30  1498  		gfs2_glock_add_to_lru(ip->i_gl);
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1499  		gfs2_glock_put_eventually(ip->i_gl);
d5c1515cf374951 Al Viro             2010-06-07  1500  		ip->i_gl = NULL;
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1501  	}
6df9f9a253c7dc9 Andreas Gruenbacher 2016-06-17  1502  	if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1503  		struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1504  
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1505  		glock_clear_object(gl, ip);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1506  		if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
a6a4d98b0124b5d Bob Peterson        2013-05-29  1507  			ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1508  			gfs2_glock_dq(&ip->i_iopen_gh);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1509  		}
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1510  		gfs2_glock_hold(gl);
40e7e86ef16550c Andreas Gruenbacher 2020-01-24  1511  		gfs2_holder_uninit(&ip->i_iopen_gh);
71c1b2136835c88 Andreas Gruenbacher 2017-08-01  1512  		gfs2_glock_put_eventually(gl);
d5c1515cf374951 Al Viro             2010-06-07  1513  	}
9e6e0a128bca0a1 Steven Whitehouse   2009-05-22  1514  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 50057 bytes --]

             reply	other threads:[~2020-09-10  9:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-10  9:41 Dan Carpenter [this message]
2020-09-10  9:41 ` [gfs2:for-next.bob7f 4/13] fs/gfs2/super.c:1477 gfs2_evict_inode() error: we previously assumed 'ip->i_gl' could be null (see line 1444) Dan Carpenter
2020-09-10  9:41 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200910094156.GC12635@kadam \
    --to=dan.carpenter@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.