Bug #6175
closedsdev can create bogus zvol directories
100%
Description
devzvol_valiate and devzvol_objset_check can work together to create a directory that shouldn't exist. Consider the case, as in 5421, where we tried to lookup /dev/zvol/rdskzones, importantly what we tried to look up is actually almost a valid part of the ZFS hierarchy, /dev/zvol/rdsk/zones is what actually exists.
What happens is that when we do the fop_lookup, we initially fail to find something, so we try to do the general lookup. Because the first invocation of devzvol_make_dsname returns NULL, we end up in the devname_lookup_func which goes through devzvol_create_dir to create a token sdev_node for the entry '/dev/zvol/rdskzones'. While not great, that should generally be okay because we have devzvol_validate() to make sure that this is valid.
But, when we go into that, we actually hit a problem. We pass the entire path name to devzvol_make_dsname() at the first argument, eg. '/dev/zvol/rdskzones'. That function does a strncmp for '/rdsk' after accounting for /dev/zvol, and then just doesn't really care about the '/' and whether or not it's there. However, because of that, we end up getting zones returned to us, which is an actually valid dataset which causes the look up function to return that it's successful.
To fix this, we should probably go through and explicitly check for the trailing '/' on both dsk and rdsk.
Updated by Electric Monk over 8 years ago
- Status changed from New to Closed
git commit e3c6427a8c15992042ea477cf18805764b7e41e0
commit e3c6427a8c15992042ea477cf18805764b7e41e0 Author: Alex Wilson <alex.wilson@joyent.com> Date: 2015-09-02T00:29:08.000Z 6175 sdev can create bogus zvol directories Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Jason King <jason.brian.king@gmail.com> Approved by: Dan McDonald <danmcd@omniti.com>