tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git 
for-next.bob6m
head:   fd5ce905071cc34294900a21a773d9f8c72f5119
commit: 4b98604ca5531f8d662e07d4a10d5fe98c9d4eae [6/11] gfs2: Create 
transaction for inodes with i_nlink != 0
config: i386-randconfig-m021-20200820 (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 <l...@intel.com>
Reported-by: Dan Carpenter <dan.carpen...@oracle.com>

New smatch warnings:
fs/gfs2/super.c:1443 gfs2_evict_inode() error: potentially dereferencing 
uninitialized 'metamapping'.

# 
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/?id=4b98604ca5531f8d662e07d4a10d5fe98c9d4eae
git remote add gfs2 
https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git
git fetch --no-tags gfs2 for-next.bob6m
git checkout 4b98604ca5531f8d662e07d4a10d5fe98c9d4eae
vim +/metamapping +1443 fs/gfs2/super.c

d5c1515cf37495 Al Viro             2010-06-07  1332  static void 
gfs2_evict_inode(struct inode *inode)
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1333  {
001e8e8df4283d Steven Whitehouse   2011-03-30  1334     struct super_block *sb 
= inode->i_sb;
001e8e8df4283d Steven Whitehouse   2011-03-30  1335     struct gfs2_sbd *sdp = 
sb->s_fs_info;
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1336     struct gfs2_inode *ip = 
GFS2_I(inode);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1337     struct gfs2_holder gh;
ee530beafeca98 Bob Peterson        2015-12-07  1338     struct address_space 
*metamapping;
e7450d984b481c Bob Peterson        2020-08-12  1339     int nr_revokes;
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1340     int error;
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1341  
059788039f1e63 Abhi Das            2014-03-31  1342     if 
(test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
059788039f1e63 Abhi Das            2014-03-31  1343             
clear_inode(inode);
059788039f1e63 Abhi Das            2014-03-31  1344             return;
059788039f1e63 Abhi Das            2014-03-31  1345     }
059788039f1e63 Abhi Das            2014-03-31  1346  
4b98604ca5531f Bob Peterson        2020-08-12  1347     if (sb_rdonly(sb))
d5c1515cf37495 Al Viro             2010-06-07  1348             goto out;
d5c1515cf37495 Al Viro             2010-06-07  1349  
e0b62e21b71bbe Andreas Gruenbacher 2017-06-30  1350     if 
(test_bit(GIF_ALLOC_FAILED, &ip->i_flags)) {
e0b62e21b71bbe Andreas Gruenbacher 2017-06-30  1351             
BUG_ON(!gfs2_glock_is_locked_by_me(ip->i_gl));
e0b62e21b71bbe Andreas Gruenbacher 2017-06-30  1352             
gfs2_holder_mark_uninitialized(&gh);
8c7b9262a86076 Andreas Gruenbacher 2020-01-13  1353             goto out_delete;
e0b62e21b71bbe Andreas Gruenbacher 2017-06-30  1354     }
e0b62e21b71bbe Andreas Gruenbacher 2017-06-30  1355  
8c7b9262a86076 Andreas Gruenbacher 2020-01-13  1356     if 
(test_bit(GIF_DEFERRED_DELETE, &ip->i_flags))
8c7b9262a86076 Andreas Gruenbacher 2020-01-13  1357             goto out;
8c7b9262a86076 Andreas Gruenbacher 2020-01-13  1358  
6a1c8f6dcf815d Andreas Gruenbacher 2017-08-01  1359     /* Deletes should never 
happen under memory pressure anymore.  */
6a1c8f6dcf815d Andreas Gruenbacher 2017-08-01  1360     if 
(WARN_ON_ONCE(current->flags & PF_MEMALLOC))
6a1c8f6dcf815d Andreas Gruenbacher 2017-08-01  1361             goto out;
6a1c8f6dcf815d Andreas Gruenbacher 2017-08-01  1362  
44ad37d69b2cc4 Bob Peterson        2011-03-17  1363     /* Must not read inode 
block until block type has been verified */
44ad37d69b2cc4 Bob Peterson        2011-03-17  1364     error = 
gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, &gh);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1365     if (unlikely(error)) {
240c6235dfe4fe Bob Peterson        2017-07-18  1366             
glock_clear_object(ip->i_iopen_gh.gh_gl, ip);
a6a4d98b0124b5 Bob Peterson        2013-05-29  1367             
ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
d4da31986c5da1 Andreas Gruenbacher 2017-02-22  1368             
gfs2_glock_dq_uninit(&ip->i_iopen_gh);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1369             goto out;
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1370     }
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1371  
f286d627ef026a Andreas Gruenbacher 2020-01-13  1372     if 
(gfs2_inode_already_deleted(ip->i_gl, ip->i_no_formal_ino))
4b98604ca5531f Bob Peterson        2020-08-12  1373             goto out_flush;
acf7e2444acfaf Steven Whitehouse   2009-09-08  1374     error = 
gfs2_check_blk_type(sdp, ip->i_no_addr, GFS2_BLKST_UNLINKED);
4b98604ca5531f Bob Peterson        2020-08-12  1375     if (error) {
4b98604ca5531f Bob Peterson        2020-08-12  1376             error = 0;
4b98604ca5531f Bob Peterson        2020-08-12  1377             goto out_flush;
4b98604ca5531f Bob Peterson        2020-08-12  1378     }
acf7e2444acfaf Steven Whitehouse   2009-09-08  1379  
44ad37d69b2cc4 Bob Peterson        2011-03-17  1380     if 
(test_bit(GIF_INVALID, &ip->i_flags)) {
44ad37d69b2cc4 Bob Peterson        2011-03-17  1381             error = 
gfs2_inode_refresh(ip);
4b98604ca5531f Bob Peterson        2020-08-12  1382             if (error) {
4b98604ca5531f Bob Peterson        2020-08-12  1383                     error = 
0;
4b98604ca5531f Bob Peterson        2020-08-12  1384                     goto 
out_flush;
4b98604ca5531f Bob Peterson        2020-08-12  1385             }
44ad37d69b2cc4 Bob Peterson        2011-03-17  1386     }
44ad37d69b2cc4 Bob Peterson        2011-03-17  1387  
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1388     /*
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1389      * The inode may have 
been recreated in the meantime.
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1390      */
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1391     if (inode->i_nlink)
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1392             goto 
out_truncate;

This one is a lot more clearly a bug...

71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1393  
8c7b9262a86076 Andreas Gruenbacher 2020-01-13  1394  out_delete:
6df9f9a253c7dc Andreas Gruenbacher 2016-06-17  1395     if 
(gfs2_holder_initialized(&ip->i_iopen_gh) &&
7508abc4bdac43 Bob Peterson        2015-12-18  1396         
test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
9e73330f298acf Andreas Gruenbacher 2020-01-14  1397             if 
(!gfs2_upgrade_iopen_glock(inode)) {
9e73330f298acf Andreas Gruenbacher 2020-01-14  1398                     
gfs2_holder_uninit(&ip->i_iopen_gh);
4b98604ca5531f Bob Peterson        2020-08-12  1399                     goto 
out_flush;
7508abc4bdac43 Bob Peterson        2015-12-18  1400             }
9e73330f298acf Andreas Gruenbacher 2020-01-14  1401     }
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1402  
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1403     if 
(S_ISDIR(inode->i_mode) &&
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1404         (ip->i_diskflags & 
GFS2_DIF_EXHASH)) {
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1405             error = 
gfs2_dir_exhash_dealloc(ip);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1406             if (error)
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1407                     goto 
out_unlock;
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1408     }
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1409  
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1410     if (ip->i_eattr) {
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1411             error = 
gfs2_ea_dealloc(ip);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1412             if (error)
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1413                     goto 
out_unlock;
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1414     }
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1415  
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1416     if 
(!gfs2_is_stuffed(ip)) {
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1417             error = 
gfs2_file_dealloc(ip);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1418             if (error)
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1419                     goto 
out_unlock;
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1420     }
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1421  
240c6235dfe4fe Bob Peterson        2017-07-18  1422     /* We're about to clear 
the bitmap for the dinode, but as soon as we
240c6235dfe4fe Bob Peterson        2017-07-18  1423        do, 
gfs2_create_inode can create another inode at the same block
240c6235dfe4fe Bob Peterson        2017-07-18  1424        location and try to 
set gl_object again. We clear gl_object here so
240c6235dfe4fe Bob Peterson        2017-07-18  1425        that subsequent 
inode creates don't see an old gl_object. */
240c6235dfe4fe Bob Peterson        2017-07-18  1426     
glock_clear_object(ip->i_gl, ip);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1427     error = 
gfs2_dinode_dealloc(ip);
f286d627ef026a Andreas Gruenbacher 2020-01-13  1428     
gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1429     goto out_unlock;
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1430  
4b98604ca5531f Bob Peterson        2020-08-12  1431  out_flush:
805c090750a315 Bob Peterson        2018-01-08  1432     gfs2_log_flush(sdp, 
ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
805c090750a315 Bob Peterson        2018-01-08  1433                    
GFS2_LFC_EVICT_INODE);
ee530beafeca98 Bob Peterson        2015-12-07  1434     metamapping = 
gfs2_glock2aspace(ip->i_gl);
2216db70c95a96 Benjamin Marzinski  2012-09-20  1435     if (test_bit(GLF_DIRTY, 
&ip->i_gl->gl_flags)) {
2216db70c95a96 Benjamin Marzinski  2012-09-20  1436             
filemap_fdatawrite(metamapping);
2216db70c95a96 Benjamin Marzinski  2012-09-20  1437             
filemap_fdatawait(metamapping);
2216db70c95a96 Benjamin Marzinski  2012-09-20  1438     }
40ac218f52aa5c Steven Whitehouse   2011-08-02  1439     write_inode_now(inode, 
1);
b5b24d7aeb9608 Steven Whitehouse   2011-09-07  1440     
gfs2_ail_flush(ip->i_gl, 0);
40ac218f52aa5c Steven Whitehouse   2011-08-02  1441  
4b98604ca5531f Bob Peterson        2020-08-12  1442  out_truncate:
e7450d984b481c Bob Peterson        2020-08-12 @1443     nr_revokes = 
inode->i_mapping->nrpages + metamapping->nrpages;
                                                                                
                 ^^^^^^^^^^^^^^^^^^^^
This will Oops.

e7450d984b481c Bob Peterson        2020-08-12  1444     if (!nr_revokes)
e7450d984b481c Bob Peterson        2020-08-12  1445             goto out_unlock;
e7450d984b481c Bob Peterson        2020-08-12  1446  
e7450d984b481c Bob Peterson        2020-08-12  1447     error = 
gfs2_trans_begin(sdp, 0, nr_revokes);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1448     if (error)
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1449             goto out_unlock;
380f7c65a7eb32 Steven Whitehouse   2011-07-14  1450     /* Needs to be done 
before glock release & also in a transaction */
380f7c65a7eb32 Steven Whitehouse   2011-07-14  1451     
truncate_inode_pages(&inode->i_data, 0);
ee530beafeca98 Bob Peterson        2015-12-07  1452     
truncate_inode_pages(metamapping, 0);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1453     gfs2_trans_end(sdp);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1454  
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1455  out_unlock:
a097dc7e24cba7 Bob Peterson        2015-07-16  1456     if 
(gfs2_rs_active(&ip->i_res))
a097dc7e24cba7 Bob Peterson        2015-07-16  1457             
gfs2_rs_deltree(&ip->i_res);
8e2e00473598dd Bob Peterson        2012-07-19  1458  
240c6235dfe4fe Bob Peterson        2017-07-18  1459     if 
(gfs2_holder_initialized(&gh)) {
240c6235dfe4fe Bob Peterson        2017-07-18  1460             
glock_clear_object(ip->i_gl, ip);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1461             
gfs2_glock_dq_uninit(&gh);
240c6235dfe4fe Bob Peterson        2017-07-18  1462     }
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1463     if (error && error != 
GLR_TRYFAILED && error != -EROFS)
d5c1515cf37495 Al Viro             2010-06-07  1464             fs_warn(sdp, 
"gfs2_evict_inode: %d\n", error);
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1465  out:
91b0abe36a7b2b Johannes Weiner     2014-04-03  1466     
truncate_inode_pages_final(&inode->i_data);
2fba46a04c383f Bob Peterson        2020-02-27  1467     if (ip->i_qadata)
2fba46a04c383f Bob Peterson        2020-02-27  1468             
gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1595548fe72ca8 Andreas Gruenbacher 2020-03-06  1469     gfs2_rs_delete(ip, 
NULL);
4513899092b325 Steven Whitehouse   2013-01-28  1470     
gfs2_ordered_del_inode(ip);
dbd5768f87ff6f Jan Kara            2012-05-03  1471     clear_inode(inode);
17d539f0499fa2 Steven Whitehouse   2011-06-15  1472     gfs2_dir_hash_inval(ip);
40e7e86ef16550 Andreas Gruenbacher 2020-01-24  1473     if (ip->i_gl) {
df3d87bde12121 Bob Peterson        2017-07-18  1474             
glock_clear_object(ip->i_gl, ip);
4fd1a5795214bc Andreas Gruenbacher 2017-06-30  1475             
wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
29687a2ac8dfcd Steven Whitehouse   2011-03-30  1476             
gfs2_glock_add_to_lru(ip->i_gl);
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1477             
gfs2_glock_put_eventually(ip->i_gl);
d5c1515cf37495 Al Viro             2010-06-07  1478             ip->i_gl = NULL;
40e7e86ef16550 Andreas Gruenbacher 2020-01-24  1479     }
6df9f9a253c7dc Andreas Gruenbacher 2016-06-17  1480     if 
(gfs2_holder_initialized(&ip->i_iopen_gh)) {
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1481             struct 
gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1482  
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1483             
glock_clear_object(gl, ip);
40e7e86ef16550 Andreas Gruenbacher 2020-01-24  1484             if 
(test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
a6a4d98b0124b5 Bob Peterson        2013-05-29  1485                     
ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
40e7e86ef16550 Andreas Gruenbacher 2020-01-24  1486                     
gfs2_glock_dq(&ip->i_iopen_gh);
40e7e86ef16550 Andreas Gruenbacher 2020-01-24  1487             }
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1488             
gfs2_glock_hold(gl);
40e7e86ef16550 Andreas Gruenbacher 2020-01-24  1489             
gfs2_holder_uninit(&ip->i_iopen_gh);
71c1b2136835c8 Andreas Gruenbacher 2017-08-01  1490             
gfs2_glock_put_eventually(gl);
d5c1515cf37495 Al Viro             2010-06-07  1491     }
9e6e0a128bca0a Steven Whitehouse   2009-05-22  1492  }

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

Attachment: .config.gz
Description: application/gzip

Reply via email to