Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'iomap-5.19-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull iomap updates from Darrick Wong:
"There's a couple of corrections sent in by Andreas for some accounting
errors.

The biggest change this time around is that writeback errors longer
clear pageuptodate nor does XFS invalidate the page cache anymore.
This brings XFS (and gfs2/zonefs) behavior in line with every other
Linux filesystem driver, and fixes some UAF bugs that only cropped up
after willy turned on multipage folios for XFS in 5.18-rc1.

Regrettably, it took all the way to the end of the 5.18 cycle to find
the source of these bugs and reach a consensus that XFS' writeback
failure behavior from 20 years ago is no longer necessary.

Summary:

- Fix a couple of accounting errors in the buffered io code.

- Discontinue the practice of marking folios !uptodate and
invalidating them when writeback fails.

This fixes some UAF bugs when multipage folios are enabled, and
brings the behavior of XFS/gfs/zonefs into alignment with the
behavior of all the other Linux filesystems"

* tag 'iomap-5.19-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
iomap: don't invalidate folios after writeback errors
iomap: iomap_write_end cleanup
iomap: iomap_write_failed fix

+4 -6
+3 -3
fs/iomap/buffered-io.c
··· 531 531 * write started inside the existing inode size. 532 532 */ 533 533 if (pos + len > i_size) 534 - truncate_pagecache_range(inode, max(pos, i_size), pos + len); 534 + truncate_pagecache_range(inode, max(pos, i_size), 535 + pos + len - 1); 535 536 } 536 537 537 538 static int iomap_read_folio_sync(loff_t block_start, struct folio *folio, ··· 734 733 folio_put(folio); 735 734 736 735 if (ret < len) 737 - iomap_write_failed(iter->inode, pos, len); 736 + iomap_write_failed(iter->inode, pos + ret, len - ret); 738 737 return ret; 739 738 } 740 739 ··· 1387 1386 if (wpc->ops->discard_folio) 1388 1387 wpc->ops->discard_folio(folio, pos); 1389 1388 if (!count) { 1390 - folio_clear_uptodate(folio); 1391 1389 folio_unlock(folio); 1392 1390 goto done; 1393 1391 }
+1 -3
fs/xfs/xfs_aops.c
··· 464 464 int error; 465 465 466 466 if (xfs_is_shutdown(mp)) 467 - goto out_invalidate; 467 + return; 468 468 469 469 xfs_alert_ratelimited(mp, 470 470 "page discard on page "PTR_FMT", inode 0x%llx, pos %llu.", ··· 474 474 i_blocks_per_folio(inode, folio) - pageoff_fsb); 475 475 if (error && !xfs_is_shutdown(mp)) 476 476 xfs_alert(mp, "page discard unable to remove delalloc mapping."); 477 - out_invalidate: 478 - iomap_invalidate_folio(folio, offset, folio_size(folio) - offset); 479 477 } 480 478 481 479 static const struct iomap_writeback_ops xfs_writeback_ops = {