-
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
zfs send does not handle invalid input gracefully #9001
Conversation
Due to some changes introduced in 30af21b 'zfs send' can crash when provided with invalid inputs: this change attempts to add more checks to the affected code paths. Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
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.
By coincidence I came up with nearly the same patch yesterday with just two differences
@@ -2422,6 +2422,10 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap, | |||
} | |||
zfs_handle_t *tosnap = zfs_open(zhp->zfs_hdl, | |||
full_tosnap_name, ZFS_TYPE_SNAPSHOT); | |||
if (tosnap == NULL) { | |||
err = -1; |
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.
err = EZFS_BADPATH;
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.
err = EZFS_BADPATH;
This is not necessarily true, zfs_open()
can fail for many different reasons, not just invalid input.
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.
Thats right. IRC this was how the old code handled it. Would have to look again to be sure though. Nonetheless I'm fine either way.
@@ -2707,6 +2711,8 @@ zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, | |||
if (from != NULL && strchr(from, '@')) { | |||
zfs_handle_t *from_zhp = zfs_open(hdl, from, | |||
ZFS_TYPE_DATASET); | |||
if (from_zhp == NULL) | |||
return (-1); |
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.
return (EZFS_NOENT);
Codecov Report
@@ Coverage Diff @@
## master #9001 +/- ##
==========================================
- Coverage 78.62% 78.59% -0.04%
==========================================
Files 388 388
Lines 119992 119997 +5
==========================================
- Hits 94349 94307 -42
- Misses 25643 25690 +47
Continue to review full report at Codecov.
|
As a side note, maybe we should add a regression test like so AttilaFueloep@d400ce1 ? |
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. I'd be OK with extending the test cases, but I don't think it's strictly necessarily since if #9003 has been applied the CI would have caught this prior to merging the feature.
Due to some changes introduced in 30af21b 'zfs send' can crash when provided with invalid inputs: this change attempts to add more checks to the affected code paths. Reviewed-by: Attila Fülöp <attila@fueloep.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes openzfs#9001
Due to some changes introduced in 30af21b 'zfs send' can crash when provided with invalid inputs: this change attempts to add more checks to the affected code paths. Reviewed-by: Attila Fülöp <attila@fueloep.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes openzfs#9001
Motivation and Context
On master
zfs send
can crash when provided with invalid inputs:Description
This change attempts to add more checks to the affected code paths.
How Has This Been Tested?
Run "zfs_send" test group on a local builder.
Types of changes
Checklist:
Signed-off-by
.