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: <alpine.DEB.2.22.394.2112301354190.15550@hadrien>
Date:   Thu, 30 Dec 2021 13:54:52 +0100 (CET)
From:   Julia Lawall <julia.lawall@...ia.fr>
To:     Goldwyn Rodrigues <rgoldwyn@...e.com>
cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: [goldwynr:iomap 27/33] fs/btrfs/file.c:1517:19-21: ERROR: reference
 preceded by free on line 1516 (fwd)



---------- Forwarded message ----------
Date: Thu, 30 Dec 2021 19:59:25 +0800
From: kernel test robot <lkp@...el.com>
To: kbuild@...ts.01.org
Cc: lkp@...el.com, Julia Lawall <julia.lawall@...6.fr>
Subject: [goldwynr:iomap 27/33] fs/btrfs/file.c:1517:19-21: ERROR: reference
    preceded by free on line 1516

CC: kbuild-all@...ts.01.org
CC: linux-kernel@...r.kernel.org
TO: Goldwyn Rodrigues <rgoldwyn@...e.com>

tree:   https://github.com/goldwynr/linux iomap
head:   30c74a8c201365178cae26d0d7aefa120c3245ab
commit: f3623890897fee87c24f37ae01a2f1a5c35a39d9 [27/33] btrfs: use srcmap for read-before-write cases
:::::: branch date: 13 hours ago
:::::: commit date: 18 hours ago
config: i386-randconfig-c001-20211228 (https://download.01.org/0day-ci/archive/20211230/202112301901.eLLE2zEp-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Julia Lawall <julia.lawall@...6.fr>


cocci warnings: (new ones prefixed by >>)
>> fs/btrfs/file.c:1517:19-21: ERROR: reference preceded by free on line 1516

vim +1517 fs/btrfs/file.c

e95dc238df949a Goldwyn Rodrigues 2021-05-11  1489
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1490  static int btrfs_buffered_iomap_begin(struct inode *inode, loff_t pos,
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1491  		loff_t length, unsigned flags, struct iomap *iomap,
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1492  		struct iomap *srcmap)
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1493  {
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1494  	int ret;
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1495  	size_t write_bytes = length;
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1496  	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1497  	size_t sector_offset = pos & (fs_info->sectorsize - 1);
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1498  	struct btrfs_iomap *bi;
f3623890897fee Goldwyn Rodrigues 2021-04-21  1499  	loff_t end = pos + length;
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1500
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1501  	bi = kzalloc(sizeof(struct btrfs_iomap), GFP_NOFS);
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1502  	if (!bi)
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1503  		return -ENOMEM;
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1504
f3623890897fee Goldwyn Rodrigues 2021-04-21  1505  	if ((pos & (PAGE_SIZE - 1) || end & (PAGE_SIZE - 1))) {
f3623890897fee Goldwyn Rodrigues 2021-04-21  1506  		loff_t isize = i_size_read(inode);
f3623890897fee Goldwyn Rodrigues 2021-04-21  1507  		if (pos >= isize) {
f3623890897fee Goldwyn Rodrigues 2021-04-21  1508  			srcmap->addr = IOMAP_NULL_ADDR;
f3623890897fee Goldwyn Rodrigues 2021-04-21  1509  			srcmap->type = IOMAP_HOLE;
f3623890897fee Goldwyn Rodrigues 2021-04-21  1510  			srcmap->offset = isize;
f3623890897fee Goldwyn Rodrigues 2021-04-21  1511  			srcmap->length = end - isize;
f3623890897fee Goldwyn Rodrigues 2021-04-21  1512  		} else {
f3623890897fee Goldwyn Rodrigues 2021-04-21  1513  			bi->em = btrfs_get_extent(BTRFS_I(inode), NULL, 0,
f3623890897fee Goldwyn Rodrigues 2021-04-21  1514  					pos - sector_offset, length);
f3623890897fee Goldwyn Rodrigues 2021-04-21  1515  			if (IS_ERR(bi->em)) {
f3623890897fee Goldwyn Rodrigues 2021-04-21 @1516  				kfree(bi);
f3623890897fee Goldwyn Rodrigues 2021-04-21 @1517  				return PTR_ERR(bi->em);
f3623890897fee Goldwyn Rodrigues 2021-04-21  1518  			}
f3623890897fee Goldwyn Rodrigues 2021-04-21  1519  			btrfs_em_to_iomap(inode, bi->em, srcmap,
f3623890897fee Goldwyn Rodrigues 2021-04-21  1520  					pos - sector_offset);
f3623890897fee Goldwyn Rodrigues 2021-04-21  1521  		}
f3623890897fee Goldwyn Rodrigues 2021-04-21  1522  	}
f3623890897fee Goldwyn Rodrigues 2021-04-21  1523
f3623890897fee Goldwyn Rodrigues 2021-04-21  1524  	if ((srcmap->type != IOMAP_HOLE) &&
f3623890897fee Goldwyn Rodrigues 2021-04-21  1525  			(end > srcmap->offset + srcmap->length))
f3623890897fee Goldwyn Rodrigues 2021-04-21  1526  			write_bytes = srcmap->offset + srcmap->length - pos;
f3623890897fee Goldwyn Rodrigues 2021-04-21  1527
f3623890897fee Goldwyn Rodrigues 2021-04-21  1528
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1529  	ret = btrfs_check_data_free_space(BTRFS_I(inode),
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1530  			&bi->data_reserved, pos, write_bytes);
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1531  	if (ret < 0) {
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1532  		/*
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1533  		 * If we don't have to COW at the offset, reserve
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1534  		 * metadata only. write_bytes may get smaller than
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1535  		 * requested here.
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1536  		 */
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1537  		if (btrfs_check_nocow_lock(BTRFS_I(inode), pos,
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1538  					&write_bytes) > 0)
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1539  			bi->metadata_only = true;
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1540  		else
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1541  			return ret;
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1542  	}
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1543
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1544  	bi->reserved_bytes = round_up(write_bytes + sector_offset,
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1545  			fs_info->sectorsize);
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1546  	WARN_ON(bi->reserved_bytes == 0);
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1547  	ret = btrfs_delalloc_reserve_metadata(BTRFS_I(inode),
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1548  			bi->reserved_bytes);
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1549  	if (ret) {
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1550  		if (!bi->metadata_only)
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1551  			btrfs_free_reserved_data_space(BTRFS_I(inode),
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1552  					bi->data_reserved, pos,
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1553  					write_bytes);
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1554  		else
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1555  			btrfs_check_nocow_unlock(BTRFS_I(inode));
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1556  		return ret;
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1557  	}
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1558
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1559  	if (pos < inode->i_size) {
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1560  		bi->lockstart = round_down(pos, fs_info->sectorsize);
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1561  		bi->lockend = round_up(pos + write_bytes, fs_info->sectorsize) - 1;
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1562  		btrfs_lock_and_flush_ordered_range(BTRFS_I(inode),
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1563  				bi->lockstart, bi->lockend,
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1564  				&bi->cached_state);
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1565  		bi->extents_locked = true;
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1566  	}
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1567
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1568  	iomap->private = bi;
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1569  	iomap->length = round_up(write_bytes + sector_offset,
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1570  			         fs_info->sectorsize);
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1571  	iomap->offset = round_down(pos, fs_info->sectorsize);
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1572  	iomap->addr = IOMAP_NULL_ADDR;
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1573  	iomap->type = IOMAP_DELALLOC;
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1574  	iomap->bdev = fs_info->fs_devices->latest_dev->bdev;
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1575  	iomap->page_ops = &btrfs_iomap_page_ops;
f4ecee4435f363 Goldwyn Rodrigues 2021-04-21  1576
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1577  	return 0;
b192ee8d4db510 Goldwyn Rodrigues 2021-04-21  1578

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ