-
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
Stop segfaulting on unmount error case #12804
Conversation
After interrupting ZTS runs that errored out, I found that "zpool export testpool2" was segfaulting. This seems unnecessary. Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
I am probably at fault here. Looks good! |
return (zfs_error_fmt(zhp->zfs_hdl, libzfs_err, | ||
dgettext(TEXT_DOMAIN, "cannot unmount '%s'"), | ||
mountpoint)); | ||
if (zhp) { |
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.
If zhp == NULL
invoking unmount_one
doesn't make sense at all. Most likely null value is injected from
Line 1636 in d41856a
if (unmount_one(sets[i].dataset, sets[i].mountpoint, |
Line 1642 in d41856a
if (sets[i].dataset) |
and
Line 1652 in d41856a
if (sets[i].dataset) |
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.
I mostly put the guard in there because of the comment at
Line 1599 in d41856a
/* |
I don't particularly care either way, I just went for the option that changed less behavior.
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.
You're right, Rich. Indeed zhp
is used in neither of OS-specific implementations, what really matters is the mountpoint
. Quite a surprise to be honest :)
After interrupting ZTS runs that errored out, I found that "zpool export testpool2" was segfaulting. This seems unnecessary. Reviewed-by: szubersk <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Closes openzfs#12804
After interrupting ZTS runs that errored out, I found that "zpool export testpool2" was segfaulting. This seems unnecessary. Reviewed-by: szubersk <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Closes openzfs#12804
After interrupting ZTS runs that errored out, I found that "zpool export testpool2" was segfaulting. This seems unnecessary. Reviewed-by: szubersk <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Closes openzfs#12804
After interrupting ZTS runs that errored out, I found that "zpool export testpool2" was segfaulting. This seems unnecessary. Reviewed-by: szubersk <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Closes openzfs#12804
After interrupting ZTS runs that errored out, I found that "zpool export testpool2" was segfaulting. This seems unnecessary. Reviewed-by: szubersk <szuberskidamian@gmail.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Closes openzfs#12804
Motivation and Context
After a ZTS run errored out, trying to
zpool export testpool2
segfaulted on trying to deref a NULL zhp.I'm not a fan of my tools segfaulting, personally, unless the world is on fire.
(If there's a better way to extract the error code once this happens, I'm all ears, but with NULL zhp, we've got no hdl...could special-case getting back something negative more than 1, I guess, but that's a big change just to smuggle an error out...)
Description
Add a NULL check.
How Has This Been Tested?
It passes testing, but unfortunately I unwedged the system with some
zpool online
commands and haven't had it reproduce since, so I'm basing this working on having a core dump saying it was NULL dereferencing there.Types of changes
Checklist:
Signed-off-by
.