-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Avoid core dump on invalid redaction bookmark #10138
Avoid core dump on invalid redaction bookmark #10138
Conversation
Haven't done a detailed review yet, but my first thought is that this code would probably be better suited to being in libzfs itself, rather than in zfs_main.c. Why not just handle the EINVAL in |
In general it seems most validation is done outside of libzfs. I had originally put the validation in libzfs but found that there was much more input validation happening in the zfs command rather than in the libzfs function, so I opted to obey that convention. My first idea was rather than validating input, to simply handle EINVAL as you suggest. But EINVAL can be the result of a lot of things, so I didn't feel it would be appropriate to give a more specific error message that may not be correct. It seems more useful to check for the likely user error and give a specific reason why the command failed, leaving the generic message and abort in place to catch other, less likely, cases. |
Plenty of validation happens in libzfs, and I think that this would be better suited to inclusion in libzfs. Most of the validation that happens in zfs_main is basic validation of the general validity of a command, and very little or none of it involves inspecting the details of a particular dataset or bookmark. EDIT: I looked at it a bit more, ZFS send definitely has more validation in zfs_main.c than in libzfs, but it is something of an outlier compared to other commands, and we should probably attempt to reverse that trend if possible. As for handling EINVAL, it can be caused by many things, but it should still probably be handled. The error message can be fully generic. It shouldn't throw an internal error when we call zfs_send_one with an invalid set of arguments. We should probably just add it to the list of errors that just does |
libzfs aborts and dumps core on EINVAL from the kernel when trying to do a redacted send with a bookmark that is not a redaction bookmark. Move redacted bookmark validation into libzfs. Check if the bookmark given for redactions is actually a redaction bookmark. Print an error message and exit gracefully if it is not. Don't abort on EINVAL in zfs_send_one. Signed-off-by: Ryan Moeller <[email protected]>
470a20f
to
24d9cb5
Compare
|
Codecov Report
@@ Coverage Diff @@
## master #10138 +/- ##
========================================
+ Coverage 79% 79% +<1%
========================================
Files 385 385
Lines 122435 122448 +13
========================================
+ Hits 96681 96860 +179
+ Misses 25754 25588 -166
Continue to review full report at Codecov.
|
libzfs aborts and dumps core on EINVAL from the kernel when trying to do a redacted send with a bookmark that is not a redaction bookmark. Move redacted bookmark validation into libzfs. Check if the bookmark given for redactions is actually a redaction bookmark. Print an error message and exit gracefully if it is not. Don't abort on EINVAL in zfs_send_one. Reviewed-by: Paul Dagnelie <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes openzfs#10138
Motivation and Context
libzfs aborts and dumps core on EINVAL from the kernel when trying to
do a redacted send with a bookmark that is not a redaction bookmark.
Description
Move redaction bookmark validation to zfs_send_one in libzfs.
Check if the bookmark given for redactions is actually a redaction
bookmark. Print an error message and exit gracefully if it is not.
Don't abort on EINVAL in zfs_send_one.
How Has This Been Tested?
ZTS on FreeBSD
Types of changes
Checklist:
Signed-off-by
.