inode.c (e67fe63341b8117d7e0d9acf0f1222d5138b9266) inode.c (c14329d39f2daa8132e1bbe5cc531da387bcf44a)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * (C) 1997 Linus Torvalds
4 * (C) 1999 Andrea Arcangeli <andrea@suse.de> (dynamic inode allocation)
5 */
6#include <linux/export.h>
7#include <linux/fs.h>
8#include <linux/mm.h>

--- 2279 unchanged lines hidden (view full) ---

2288 * the vfsmount must be passed through @idmap. This function will then take
2289 * care to map the inode according to @idmap before checking permissions
2290 * and initializing i_uid and i_gid. On non-idmapped mounts or if permission
2291 * checking is to be performed on the raw inode simply pass @nop_mnt_idmap.
2292 */
2293void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
2294 const struct inode *dir, umode_t mode)
2295{
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * (C) 1997 Linus Torvalds
4 * (C) 1999 Andrea Arcangeli <andrea@suse.de> (dynamic inode allocation)
5 */
6#include <linux/export.h>
7#include <linux/fs.h>
8#include <linux/mm.h>

--- 2279 unchanged lines hidden (view full) ---

2288 * the vfsmount must be passed through @idmap. This function will then take
2289 * care to map the inode according to @idmap before checking permissions
2290 * and initializing i_uid and i_gid. On non-idmapped mounts or if permission
2291 * checking is to be performed on the raw inode simply pass @nop_mnt_idmap.
2292 */
2293void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
2294 const struct inode *dir, umode_t mode)
2295{
2296 struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
2297
2298 inode_fsuid_set(inode, mnt_userns);
2296 inode_fsuid_set(inode, idmap);
2299 if (dir && dir->i_mode & S_ISGID) {
2300 inode->i_gid = dir->i_gid;
2301
2302 /* Directories are special, and always inherit S_ISGID */
2303 if (S_ISDIR(mode))
2304 mode |= S_ISGID;
2305 } else
2297 if (dir && dir->i_mode & S_ISGID) {
2298 inode->i_gid = dir->i_gid;
2299
2300 /* Directories are special, and always inherit S_ISGID */
2301 if (S_ISDIR(mode))
2302 mode |= S_ISGID;
2303 } else
2306 inode_fsgid_set(inode, mnt_userns);
2304 inode_fsgid_set(inode, idmap);
2307 inode->i_mode = mode;
2308}
2309EXPORT_SYMBOL(inode_init_owner);
2310
2311/**
2312 * inode_owner_or_capable - check current task permissions to inode
2313 * @idmap: idmap of the mount the inode was found from
2314 * @inode: inode being checked

--- 194 unchanged lines hidden ---
2305 inode->i_mode = mode;
2306}
2307EXPORT_SYMBOL(inode_init_owner);
2308
2309/**
2310 * inode_owner_or_capable - check current task permissions to inode
2311 * @idmap: idmap of the mount the inode was found from
2312 * @inode: inode being checked

--- 194 unchanged lines hidden ---