Skip to contentSkip to conversation

fs/xfs/xfs_error.c:308 xfs_errortag_add() error: buffer overflow 'xfs_errortag_random_default' 38 <= 38

PATCH In review Dan Carpenter 2 participants 2 messages Mar 2, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 5/5 fs/xfs/xfs_error.c:308 xfs_errortag_add() error: buffer overflow 'xfs_errortag_random_default' 38 <= 38

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/xiang/linux.git  xfs/shrink_lastag
head:   95891836ec5d4d45e5fab66bff969fa3f4063d77
commit: 95891836ec5d4d45e5fab66bff969fa3f4063d77 [5/5] xfs: add error injection for per-AG resv failure
config: i386-randconfig-m021-20210301 (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

smatch warnings:
fs/xfs/xfs_error.c:308 xfs_errortag_add() error: buffer overflow 'xfs_errortag_random_default' 38 <= 38

vim +/xfs_errortag_random_default +308 fs/xfs/xfs_error.c

^1da177e4c3f41 Linus Torvalds  2005-04-16  299  int
31965ef34802f4 Darrick J. Wong 2017-06-20  300  xfs_errortag_add(
31965ef34802f4 Darrick J. Wong 2017-06-20  301  	struct xfs_mount	*mp,
31965ef34802f4 Darrick J. Wong 2017-06-20  302  	unsigned int		error_tag)
^1da177e4c3f41 Linus Torvalds  2005-04-16  303  {
31965ef34802f4 Darrick J. Wong 2017-06-20  304  	if (error_tag >= XFS_ERRTAG_MAX)
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
31965ef34802f4 Darrick J. Wong 2017-06-20  305  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds  2005-04-16  306  
31965ef34802f4 Darrick J. Wong 2017-06-20  307  	return xfs_errortag_set(mp, error_tag,
31965ef34802f4 Darrick J. Wong 2017-06-20 @308  			xfs_errortag_random_default[error_tag]);
                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It looks like this off by one bug is fixed in commit dd2149fbe83e ("xfs: add error injection for per-AG resv failure"). You may want to fold that in to the original commit and declare xfs_errortag_random_default[] as having XFS_ERRTAG_MAX elements.

^1da177e4c3f41 Linus Torvalds 2005-04-16 309 }

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

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org

#1 lore raw

Hi Dan,

Quoted 6 lines · Dan Carpenter
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/xiang/linux.git  xfs/shrink_lastag
head:   95891836ec5d4d45e5fab66bff969fa3f4063d77
commit: 95891836ec5d4d45e5fab66bff969fa3f4063d77 [5/5] xfs: add error injection for per-AG resv failure
config: i386-randconfig-m021-20210301 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
Quoted 6 lines

If you fix the issue, kindly add following tag as appropriate

smatch warnings:
fs/xfs/xfs_error.c:308 xfs_errortag_add() error: buffer overflow 'xfs_errortag_random_default' 38 <= 38

Thanks for your report. I've got the problem,
and fixed it in
https://git.kernel.org/pub/scm/linux/kernel/git/xiang/linux.git/commit/?h=xfs/shrink_lastag&id=dd2149fbe83e838e4819b90b2233dad20a876f5c

That was a pending patchset intended for reviewing. I will wait the 0day CI result of fixed version, and send out then.

Thanks,
Gao Xiang

Quoted 32 lines

vim +/xfs_errortag_random_default +308 fs/xfs/xfs_error.c

^1da177e4c3f41 Linus Torvalds  2005-04-16  299  int
31965ef34802f4 Darrick J. Wong 2017-06-20  300  xfs_errortag_add(
31965ef34802f4 Darrick J. Wong 2017-06-20  301  	struct xfs_mount	*mp,
31965ef34802f4 Darrick J. Wong 2017-06-20  302  	unsigned int		error_tag)
^1da177e4c3f41 Linus Torvalds  2005-04-16  303  {
31965ef34802f4 Darrick J. Wong 2017-06-20  304  	if (error_tag >= XFS_ERRTAG_MAX)
                                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
31965ef34802f4 Darrick J. Wong 2017-06-20  305  		return -EINVAL;
^1da177e4c3f41 Linus Torvalds  2005-04-16  306  
31965ef34802f4 Darrick J. Wong 2017-06-20  307  	return xfs_errortag_set(mp, error_tag,
31965ef34802f4 Darrick J. Wong 2017-06-20 @308  			xfs_errortag_random_default[error_tag]);
                                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

It looks like this off by one bug is fixed in commit dd2149fbe83e ("xfs: add error injection for per-AG resv failure"). You may want to fold that in to the original commit and declare xfs_errortag_random_default[] as having XFS_ERRTAG_MAX elements.

^1da177e4c3f41 Linus Torvalds 2005-04-16 309 }

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

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org