Skip to content

Commit 0991abe

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: fix zero the unwritten part for dio read
For dio read, bio will be leave in flight when a successful partial aio read have been setup, blockdev_direct_IO() will return -EIOCBQUEUED. In the case, iter->iov_offset will be not advanced, the oops reported by syzbot will occur if revert iter->iov_offset with iov_iter_revert(). The unwritten part had been zeroed by aio read, so there is no need to zero it in dio read. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=fd404f6b03a58e8bc403 Fixes: 11a347f ("exfat: change to get file size from DataLength") Signed-off-by: Yuezhang Mo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 296455a commit 0991abe

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

fs/exfat/inode.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
501501
struct inode *inode = mapping->host;
502502
struct exfat_inode_info *ei = EXFAT_I(inode);
503503
loff_t pos = iocb->ki_pos;
504-
loff_t size = iocb->ki_pos + iov_iter_count(iter);
504+
loff_t size = pos + iov_iter_count(iter);
505505
int rw = iov_iter_rw(iter);
506506
ssize_t ret;
507507

@@ -525,11 +525,10 @@ static ssize_t exfat_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
525525
*/
526526
ret = blockdev_direct_IO(iocb, inode, iter, exfat_get_block);
527527
if (ret < 0) {
528-
if (rw == WRITE)
528+
if (rw == WRITE && ret != -EIOCBQUEUED)
529529
exfat_write_failed(mapping, size);
530530

531-
if (ret != -EIOCBQUEUED)
532-
return ret;
531+
return ret;
533532
} else
534533
size = pos + ret;
535534

0 commit comments

Comments
 (0)