-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/fix uio partial copies #10148
Bugfix/fix uio partial copies #10148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for running this down. Your analysis looks right to be, I'm surprised we didn't handle this, but that's clearly the case.
module/zfs/zfs_vnops.c
Outdated
/ data itself, generate an EFAULT, and make | ||
/ the loop break early without completing the | ||
/ last chunk. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the detailed comment is welcome, but perhaps it could be a little more concise. Also please use the existing comment style found elsewhere in this function. You can run make checkstyle
locally to verify the formatting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed all "make checkstyle" issues, and made the comment shorter.
Let me know if it's ok.
f2b6553
to
10ad043
Compare
Codecov Report
@@ Coverage Diff @@
## master #10148 +/- ##
==========================================
+ Coverage 79.28% 79.38% +0.10%
==========================================
Files 385 385
Lines 122440 122445 +5
==========================================
+ Hits 97079 97206 +127
+ Misses 25361 25239 -122
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Would you just mind rebasing this on the latest master branch. This will get us a clean CI run, and we'll get backported for the next 0.8 point release.
@wgqimut would you mind reviewing this PR. |
EFAULT. Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com>
the loop, and leave a lengthy comment explaining the reason why this is done. Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com>
… this is not reachable. Fix double-counting bug. Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com>
Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com>
…request on PR. Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com>
Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com>
ab66235
to
7a7c85f
Compare
Done, let me know if something else is missing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me.
@fsvm88 thanks for the rebase. This is ready to go, I'll get it merged. Thank you for resolving this! |
In zfs_write(), the loop continues to the next iteration without accounting for partial copies occurring in uiomove_iov when copy_from_user/__copy_from_user_inatomic return a non-zero status. This results in "zfs: accessing past end of object..." in the kernel log, and the write failing. Account for partial copies and update uio struct before returning EFAULT, leave a comment explaining the reason why this is done. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: ilbsmart <wgqimut@gmail.com> Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com> Closes openzfs#8673 Closes openzfs#10148
@fsvm88 can you point me to reproducer? I think it would be great to have a test for this case. |
@gmelikov As explained in the PR's detail, my workload was compiling big projects (kernel, GCC) in a musl chroot (from a glibc host). |
In zfs_write(), the loop continues to the next iteration without accounting for partial copies occurring in uiomove_iov when copy_from_user/__copy_from_user_inatomic return a non-zero status. This results in "zfs: accessing past end of object..." in the kernel log, and the write failing. Account for partial copies and update uio struct before returning EFAULT, leave a comment explaining the reason why this is done. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: ilbsmart <wgqimut@gmail.com> Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com> Closes openzfs#8673 Closes openzfs#10148
In zfs_write(), the loop continues to the next iteration without accounting for partial copies occurring in uiomove_iov when copy_from_user/__copy_from_user_inatomic return a non-zero status. This results in "zfs: accessing past end of object..." in the kernel log, and the write failing. Account for partial copies and update uio struct before returning EFAULT, leave a comment explaining the reason why this is done. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: ilbsmart <wgqimut@gmail.com> Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com> Closes openzfs#8673 Closes openzfs#10148
In zfs_write(), the loop continues to the next iteration without accounting for partial copies occurring in uiomove_iov when copy_from_user/__copy_from_user_inatomic return a non-zero status. This results in "zfs: accessing past end of object..." in the kernel log, and the write failing. Account for partial copies and update uio struct before returning EFAULT, leave a comment explaining the reason why this is done. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: ilbsmart <wgqimut@gmail.com> Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com> Closes openzfs#8673 Closes openzfs#10148
In zfs_write(), the loop continues to the next iteration without accounting for partial copies occurring in uiomove_iov when copy_from_user/__copy_from_user_inatomic return a non-zero status. This results in "zfs: accessing past end of object..." in the kernel log, and the write failing. Account for partial copies and update uio struct before returning EFAULT, leave a comment explaining the reason why this is done. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: ilbsmart <wgqimut@gmail.com> Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com> Closes #8673 Closes #10148
In zfs_write(), the loop continues to the next iteration without accounting for partial copies occurring in uiomove_iov when copy_from_user/__copy_from_user_inatomic return a non-zero status. This results in "zfs: accessing past end of object..." in the kernel log, and the write failing. Account for partial copies and update uio struct before returning EFAULT, leave a comment explaining the reason why this is done. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: ilbsmart <wgqimut@gmail.com> Signed-off-by: Fabio Scaccabarozzi <fsvm88@gmail.com> Closes openzfs#8673 Closes openzfs#10148
In zfs_write(), the loop continues to the next iteration without accounting for partial copies occurring in uiomove_iov when copy_from_user/__copy_from_user_inatomic return a non-zero status.
This results in "zfs: accessing past end of object..." in the kernel log, and the write failing.
Motivation and Context
On some workloads, writing to disk results in "zfs: accessing past end of object".
See issue #8673.
Description
In zfs_write(), the loop continues to the next iteration without accounting for partial copies occurring in uiomove_iov (which does not update the uio struct) when copy_from_user/__copy_from_user_inatomic return a non-zero status, which indicates the bytes left to copy.
How Has This Been Tested?
I had a reproducer workload: compiling GCC in a musl chroot, from a glibc host system. The bug would happen at random, at different parts and times of the build.
Before the provided PR, I was never able to compile GCC successfully in the chroot.
I had a couple revisions of the patch that worked partially, before reaching the ones submitted in this PR.
After applying the fixes in this PR, I was able to compile GCC 11 times in a row without any breakage.
Types of changes
Checklist:
Signed-off-by
.