Skip to content

Commit

Permalink
libzfs: zfs_userns: Don't leak the namespace fd
Browse files Browse the repository at this point in the history
zfs_userns opens a file descriptor for the kernel to look up a
namespace, but does not close it.

Close the fd when we're done with it.

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Allan Jude <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes openzfs#13554
Ryan Moeller authored and behlendorf committed Jun 14, 2022
1 parent 482505f commit def1a40
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/libzfs/os/linux/libzfs_util_os.c
Original file line number Diff line number Diff line change
@@ -274,5 +274,7 @@ zfs_userns(zfs_handle_t *zhp, const char *nspath, int attach)
if ((ret = zfs_ioctl(hdl, cmd, &zc)) != 0)
zfs_standard_error(hdl, errno, errbuf);

(void) close(zc.zc_cleanup_fd);

return (ret);
}

0 comments on commit def1a40

Please sign in to comment.