ChenXiaoSong
001c179c4e
xfs: fix NULL pointer dereference in xfs_getbmap()
...
Reproducer:
1. fallocate -l 100M image
2. mkfs.xfs -f image
3. mount image /mnt
4. setxattr("/mnt", "trusted.overlay.upper", NULL, 0, XATTR_CREATE)
5. char arg[32] = "\x01\xff\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x08\x00\x00\x00\xc6\x2a\xf7";
fd = open("/mnt", O_RDONLY|O_DIRECTORY);
ioctl(fd, _IOC(_IOC_READ|_IOC_WRITE, 0x58, 0x2c, 0x20), arg);
NULL pointer dereference will occur when race happens between xfs_getbmap()
and xfs_bmap_set_attrforkoff():
ioctl | setxattr
----------------------------|---------------------------
xfs_getbmap |
xfs_ifork_ptr |
xfs_inode_has_attr_fork |
ip->i_forkoff == 0 |
return NULL |
ifp == NULL |
| xfs_bmap_set_attrforkoff
| ip->i_forkoff > 0
xfs_inode_has_attr_fork |
ip->i_forkoff > 0 |
ifp == NULL |
ifp->if_format |
Fix this by locking i_lock before xfs_ifork_ptr().
Fixes: abbf9e8a4507 ("xfs: rewrite getbmap using the xfs_iext_* helpers")
Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
[djwong: added fixes tag]
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2022-07-31 09:21:27 -07:00
..
2022-07-22 10:58:39 -07:00
2022-07-20 16:40:39 -07:00
2022-01-15 16:30:29 +02:00
2021-10-22 16:00:31 -07:00
2022-07-14 11:47:42 +10:00
2022-05-27 10:34:04 +10:00
2022-04-26 13:34:42 +10:00
2022-05-24 19:55:07 -07:00
2022-07-20 16:40:39 -07:00
2022-06-29 08:47:56 -07:00
2022-05-23 08:43:46 +10:00
2022-07-09 15:17:21 -07:00
2022-04-01 19:30:44 -07:00
2022-05-04 11:46:47 +10:00
2021-10-22 16:04:20 -07:00
2022-07-31 09:21:27 -07:00
2022-01-17 09:16:41 -08:00
2022-05-27 10:27:19 +10:00
2022-03-20 08:59:49 -07:00
2022-04-21 10:46:40 +10:00
2022-07-20 16:40:39 -07:00
2022-07-20 16:40:39 -07:00
2022-07-09 15:17:21 -07:00
2022-07-07 19:07:40 +10:00
2021-08-19 10:07:12 -07:00
2021-08-06 11:05:36 -07:00
2021-08-06 11:05:36 -07:00
2022-07-22 10:58:39 -07:00
2022-05-11 17:12:09 +10:00
2022-05-11 17:01:23 +10:00
2022-04-21 10:47:25 +10:00
2021-08-19 10:07:13 -07:00
2021-06-02 10:48:24 +10:00
2021-06-02 10:48:24 +10:00
2022-07-07 19:07:40 +10:00
2021-10-22 16:04:20 -07:00
2022-06-01 17:23:53 -07:00
2022-07-07 19:07:40 +10:00
2021-08-19 10:07:12 -07:00
2022-07-07 19:07:40 +10:00
2022-07-07 19:13:02 +10:00
2021-02-03 09:18:50 -08:00
2022-05-11 17:01:22 +10:00
2021-08-19 10:07:13 -07:00
2022-07-20 16:40:39 -07:00
2022-06-23 13:34:38 -07:00
2022-05-04 11:45:11 +10:00
2021-10-22 16:04:20 -07:00
2022-05-04 11:45:50 +10:00
2022-07-12 11:17:27 -07:00
2022-03-29 18:21:59 -07:00
2022-07-14 09:46:37 -07:00
2022-07-14 09:46:37 -07:00
2022-05-04 12:41:02 +10:00
2022-01-18 10:18:36 -08:00
2022-07-09 15:17:21 -07:00
2022-01-17 09:16:41 -08:00
2022-07-12 11:17:27 -07:00
2021-12-04 08:58:53 -08:00
2022-07-12 11:17:27 -07:00
2022-07-09 10:56:02 -07:00
2022-07-12 11:17:27 -07:00
2022-04-13 07:02:45 +00:00
2022-07-14 11:47:42 +10:00
2022-07-14 11:47:42 +10:00
2021-08-09 11:13:16 -07:00
2022-04-13 07:02:44 +00:00
2022-03-29 18:22:02 -07:00
2022-07-07 18:56:09 +10:00
2022-07-07 18:56:09 +10:00
2022-07-14 11:46:43 +10:00
2022-07-07 18:56:09 +10:00
2022-07-07 18:56:08 +10:00
2022-04-21 16:45:03 +10:00
2022-05-27 10:31:34 +10:00
2022-07-07 19:13:02 +10:00
2022-06-23 13:34:38 -07:00
2021-10-22 16:04:20 -07:00
2022-05-04 12:41:02 +10:00
2022-03-14 10:23:16 -07:00
2021-02-03 09:18:49 -08:00
2021-02-03 09:18:49 -08:00
2021-08-19 10:07:12 -07:00
2022-06-23 13:34:38 -07:00
2022-07-14 09:46:37 -07:00
2022-05-11 17:12:09 +10:00
2021-08-09 10:52:18 -07:00
2022-05-11 17:12:09 +10:00
2022-05-04 11:46:47 +10:00
2021-10-22 16:04:20 -07:00
2022-07-09 15:17:21 -07:00
2022-07-07 19:07:40 +10:00
2022-05-04 11:46:47 +10:00
2021-10-22 16:04:20 -07:00
2022-04-21 16:46:17 +10:00
2022-04-12 06:49:42 +10:00
2022-07-20 16:40:39 -07:00
2022-05-27 10:33:29 +10:00
2022-07-12 11:17:27 -07:00
2021-01-24 14:43:46 +01:00
2021-02-24 10:16:08 -08:00
2022-05-11 17:01:22 +10:00
2022-05-11 17:01:22 +10:00
2021-08-18 18:46:00 -07:00
2022-07-14 09:46:37 -07:00
2022-03-29 18:22:01 -07:00
2021-08-19 10:07:14 -07:00
2022-05-11 17:12:09 +10:00
2022-07-07 18:55:59 +10:00
2022-07-14 09:21:42 -07:00
2022-07-14 09:21:42 -07:00
2022-06-15 23:13:32 -07:00
2022-05-27 10:34:04 +10:00