From def1a401f44abce71196949feaecbd66ebcddf0b Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Mon, 13 Jun 2022 20:24:23 +0000 Subject: [PATCH] libzfs: zfs_userns: Don't leak the namespace fd 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 Reviewed-by: Allan Jude Signed-off-by: Ryan Moeller Closes #13554 --- lib/libzfs/os/linux/libzfs_util_os.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/libzfs/os/linux/libzfs_util_os.c b/lib/libzfs/os/linux/libzfs_util_os.c index 7bd26ea98..0ab79be4e 100644 --- a/lib/libzfs/os/linux/libzfs_util_os.c +++ b/lib/libzfs/os/linux/libzfs_util_os.c @@ -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); }