Commit f5f0ed8
xfs: don't call remap_verify_area with sb write protection held
The XFS_IOC_EXCHANGE_RANGE ioctl with the XFS_EXCHANGE_RANGE_TO_EOF flag
operates on a range bounded by the end of the file. This means the
actual amount of blocks exchanged is derived from the inode size, which
is only stable with the IOLOCK (i_rwsem) held. Do that, it currently
calls remap_verify_area from inside the sb write protection which nests
outside the IOLOCK. But this makes fsnotify_file_area_perm which is
called from remap_verify_area unhappy when the kernel is built with
lockdep and the recently added CONFIG_FANOTIFY_ACCESS_PERMISSIONS
option.
Fix this by always calling remap_verify_area before taking the write
protection, and passing a 0 size to remap_verify_area similar to
the FICLONE/FICLONERANGE ioctls when they are asked to clone until
the file end.
(Note: the size argument gets passed to fsnotify_file_area_perm, but
then isn't actually used there).
Fixes: 9a64d9b ("xfs: introduce new file range exchange ioctl")
Cc: <[email protected]> # v6.10
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Carlos Maiolino <[email protected]>1 parent 89841b2 commit f5f0ed8
1 file changed
+27
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | 332 | | |
349 | 333 | | |
350 | 334 | | |
| |||
355 | 339 | | |
356 | 340 | | |
357 | 341 | | |
| 342 | + | |
358 | 343 | | |
| 344 | + | |
359 | 345 | | |
360 | 346 | | |
361 | 347 | | |
362 | | - | |
| 348 | + | |
363 | 349 | | |
364 | 350 | | |
365 | 351 | | |
| |||
368 | 354 | | |
369 | 355 | | |
370 | 356 | | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | 357 | | |
375 | 358 | | |
376 | 359 | | |
377 | 360 | | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
383 | 367 | | |
384 | 368 | | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
389 | 376 | | |
390 | 377 | | |
391 | 378 | | |
| |||
401 | 388 | | |
402 | 389 | | |
403 | 390 | | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | 391 | | |
414 | 392 | | |
415 | 393 | | |
| |||
747 | 725 | | |
748 | 726 | | |
749 | 727 | | |
| 728 | + | |
750 | 729 | | |
751 | 730 | | |
752 | 731 | | |
| |||
779 | 758 | | |
780 | 759 | | |
781 | 760 | | |
782 | | - | |
783 | | - | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
784 | 764 | | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
790 | 773 | | |
791 | 774 | | |
792 | 775 | | |
| |||
0 commit comments