Skip to content

Commit b524858

Browse files
committed
Merge: kernel hung task hot unplugging SCSI devices under write workload
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6610 JIRA: https://issues.redhat.com/browse/RHEL-79099 ``` commit 381c043 Author: Christoph Hellwig <hch@lst.de> Date: Mon Sep 25 08:54:45 2023 -0700 iomap: add a workaround for racy i_size updates on block devices A szybot reproducer that does write I/O while truncating the size of a block device can end up in clean_bdev_aliases, which tries to clean the bdev aliases that it uses. This is because iomap_to_bh automatically sets the BH_New flag when outside of i_size. For block devices updates to i_size are racy and we can hit this case in a tiny race window, leading to the eventual clean_bdev_aliases call. Fix this by erroring out of > i_size I/O on block devices. Reported-by: syzbot+1fa947e7f09e136925b8@syzkaller.appspotmail.com Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: syzbot+1fa947e7f09e136925b8@syzkaller.appspotmail.com Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>``` Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> --- <small>Created 2025-03-20 13:41 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://gitlab.com/cki-project/kernel-workflow/-/issues/new?issue%5Btitle%5D=backporter%20webhook%20issue)</small> Approved-by: Brian Foster <bfoster@redhat.com> Approved-by: Ewan D. Milne <emilne@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents 850610d + cc97093 commit b524858

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

fs/buffer.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,8 +2016,17 @@ iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh,
20162016
fallthrough;
20172017
case IOMAP_MAPPED:
20182018
if ((iomap->flags & IOMAP_F_NEW) ||
2019-
offset >= i_size_read(inode))
2019+
offset >= i_size_read(inode)) {
2020+
/*
2021+
* This can happen if truncating the block device races
2022+
* with the check in the caller as i_size updates on
2023+
* block devices aren't synchronized by i_rwsem for
2024+
* block devices.
2025+
*/
2026+
if (S_ISBLK(inode->i_mode))
2027+
return -EIO;
20202028
set_buffer_new(bh);
2029+
}
20212030
bh->b_blocknr = (iomap->addr + offset - iomap->offset) >>
20222031
inode->i_blkbits;
20232032
set_buffer_mapped(bh);

0 commit comments

Comments
 (0)