diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2024-05-31 22:45:26 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2024-11-03 01:28:06 -0500 |
commit | 048181992cade404028c287241f570657195c81d (patch) | |
tree | d5f2f64bc922ef7a3a0bd88ddf2268351475cbb4 /security | |
parent | a6f46579d7da68baa8873ea43acdcc354d55a848 (diff) | |
download | lwn-048181992cade404028c287241f570657195c81d.tar.gz lwn-048181992cade404028c287241f570657195c81d.zip |
fdget_raw() users: switch to CLASS(fd_raw)
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security')
-rw-r--r-- | security/landlock/syscalls.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/security/landlock/syscalls.c b/security/landlock/syscalls.c index f5a0e7182ec0..f32eb38abd0f 100644 --- a/security/landlock/syscalls.c +++ b/security/landlock/syscalls.c @@ -276,15 +276,12 @@ out_fdput: */ static int get_path_from_fd(const s32 fd, struct path *const path) { - struct fd f; - int err = 0; + CLASS(fd_raw, f)(fd); BUILD_BUG_ON(!__same_type( fd, ((struct landlock_path_beneath_attr *)NULL)->parent_fd)); - /* Handles O_PATH. */ - f = fdget_raw(fd); - if (!fd_file(f)) + if (fd_empty(f)) return -EBADF; /* * Forbids ruleset FDs, internal filesystems (e.g. nsfs), including @@ -295,16 +292,12 @@ static int get_path_from_fd(const s32 fd, struct path *const path) (fd_file(f)->f_path.mnt->mnt_flags & MNT_INTERNAL) || (fd_file(f)->f_path.dentry->d_sb->s_flags & SB_NOUSER) || d_is_negative(fd_file(f)->f_path.dentry) || - IS_PRIVATE(d_backing_inode(fd_file(f)->f_path.dentry))) { - err = -EBADFD; - goto out_fdput; - } + IS_PRIVATE(d_backing_inode(fd_file(f)->f_path.dentry))) + return -EBADFD; + *path = fd_file(f)->f_path; path_get(path); - -out_fdput: - fdput(f); - return err; + return 0; } static int add_rule_path_beneath(struct landlock_ruleset *const ruleset, |