Commit c364b6d
committed
xfs: fix bmv_count confusion w/ shared extents
In a bmapx call, bmv_count is the total size of the array, including the
zeroth element that userspace uses to supply the search key. The output
array starts at offset 1 so that we can set up the user for the next
invocation. Since we now can split an extent into multiple bmap records
due to shared/unshared status, we have to be careful that we don't
overflow the output array.
In the original patch f86f403 ("xfs: teach get_bmapx about shared
extents and the CoW fork") I used cur_ext (the output index) to check
for overflows, albeit with an off-by-one error. Since nexleft no longer
describes the number of unfilled slots in the output, we can rip all
that out and use cur_ext for the overflow check directly.
Failure to do this causes heap corruption in bmapx callers such as
xfs_io and xfs_scrub. xfs/328 can reproduce this problem.
Reviewed-by: Eric Sandeen <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>1 parent 2aa6ba7 commit c364b6d
1 file changed
+18
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
528 | 528 | | |
529 | 529 | | |
530 | 530 | | |
531 | | - | |
532 | 531 | | |
533 | 532 | | |
534 | 533 | | |
| |||
686 | 685 | | |
687 | 686 | | |
688 | 687 | | |
689 | | - | |
690 | | - | |
691 | 688 | | |
692 | | - | |
| 689 | + | |
693 | 690 | | |
694 | 691 | | |
695 | 692 | | |
696 | 693 | | |
697 | 694 | | |
698 | 695 | | |
699 | 696 | | |
700 | | - | |
701 | | - | |
| 697 | + | |
| 698 | + | |
702 | 699 | | |
703 | 700 | | |
704 | 701 | | |
| |||
760 | 757 | | |
761 | 758 | | |
762 | 759 | | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
763 | 773 | | |
764 | 774 | | |
765 | 775 | | |
766 | | - | |
767 | | - | |
| 776 | + | |
768 | 777 | | |
769 | 778 | | |
770 | 779 | | |
771 | | - | |
772 | | - | |
| 780 | + | |
773 | 781 | | |
774 | 782 | | |
775 | 783 | | |
| |||
0 commit comments