Skip to contentSkip to conversation

fuse: check for NULL file returned by fget

PATCH New Andrei Vagin 1 participant 1 message Mar 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: check for NULL file returned by fget

If an invalid file descriptor is provided in the mount options, fget() returns NULL. fuse_opt_fd() was dereferencing this NULL pointer when checking the file operations.

Fixes 6dcceeb72856 ("fuse: support FSCONFIG_SET_FD for "fd" option")
Reported-by [email protected]
---
 fs/fuse/inode.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/fuse/inode.c +4 -0
index af8ad96829fd..95bbc7b28b89 100644
@@ -862,6 +862,10 @@ static int fuse_parse_param(struct fs_context *fsc, struct fs_parameter *param)
 			return fuse_opt_fd(fsc, param->file);
 		} else {
 			struct file *file __free(fput) = fget(result.uint_32);
+
+			if (!file)
+				return invalfc(fsc, "invalid file descriptor");
+
 			return fuse_opt_fd(fsc, file);
 		}
 
Signature · 1 line
2.53.0.851.ga537e3e6e9-goog