Lines Matching defs:inode
61 * With the new dcache, the pathname is stored at each inode, at least as
62 * long as the refcount of the inode is positive. As a side effect, the
63 * size of the dcache depends on the inode cache and thus is dynamic.
280 * @idmap: idmap of the mount the inode was found from
281 * @inode: inode to check permissions on
288 * If the inode has been found through an idmapped mount the idmap of
290 * care to map the inode according to @idmap before checking permissions.
292 * raw inode simply passs @nop_mnt_idmap.
295 struct inode *inode, int mask)
301 acl = get_cached_acl_rcu(inode, ACL_TYPE_ACCESS);
307 return posix_acl_permission(idmap, inode, acl, mask);
310 acl = get_inode_acl(inode, ACL_TYPE_ACCESS);
314 int error = posix_acl_permission(idmap, inode, acl, mask);
325 * @idmap: idmap of the mount the inode was found from
326 * @inode: inode to check permissions on
333 * If the inode has been found through an idmapped mount the idmap of
335 * care to map the inode according to @idmap before checking permissions.
337 * raw inode simply passs @nop_mnt_idmap.
340 struct inode *inode, int mask)
342 unsigned int mode = inode->i_mode;
346 vfsuid = i_uid_into_vfsuid(idmap, inode);
354 if (IS_POSIXACL(inode) && (mode & S_IRWXG)) {
355 int error = check_acl(idmap, inode, mask);
369 vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
380 * @idmap: idmap of the mount the inode was found from
381 * @inode: inode to check access rights for
394 * If the inode has been found through an idmapped mount the idmap of
396 * care to map the inode according to @idmap before checking permissions.
398 * raw inode simply passs @nop_mnt_idmap.
400 int generic_permission(struct mnt_idmap *idmap, struct inode *inode,
408 ret = acl_permission_check(idmap, inode, mask);
412 if (S_ISDIR(inode->i_mode)) {
415 if (capable_wrt_inode_uidgid(idmap, inode,
418 if (capable_wrt_inode_uidgid(idmap, inode,
429 if (capable_wrt_inode_uidgid(idmap, inode,
437 if (!(mask & MAY_EXEC) || (inode->i_mode & S_IXUGO))
438 if (capable_wrt_inode_uidgid(idmap, inode,
448 * @idmap: idmap of the mount the inode was found from
449 * @inode: inode to check permissions on
453 * even looking at the inode->i_op values. So we keep a cache
454 * flag in inode->i_opflags, that says "this has not special
458 struct inode *inode, int mask)
460 if (unlikely(!(inode->i_opflags & IOP_FASTPERM))) {
461 if (likely(inode->i_op->permission))
462 return inode->i_op->permission(idmap, inode, mask);
464 /* This gets set once for the inode lifetime */
465 spin_lock(&inode->i_lock);
466 inode->i_opflags |= IOP_FASTPERM;
467 spin_unlock(&inode->i_lock);
469 return generic_permission(idmap, inode, mask);
474 * @sb: Superblock of inode to check permission on
475 * @inode: Inode to check permission on
478 * Separate out file-system wide checks from inode-specific permission checks.
480 static int sb_permission(struct super_block *sb, struct inode *inode, int mask)
483 umode_t mode = inode->i_mode;
493 * inode_permission - Check for access rights to a given inode
494 * @idmap: idmap of the mount the inode was found from
495 * @inode: Inode to check permission on
498 * Check for read/write/execute permissions on an inode. We use fs[ug]id for
505 struct inode *inode, int mask)
509 retval = sb_permission(inode->i_sb, inode, mask);
517 if (IS_IMMUTABLE(inode))
525 if (HAS_UNMAPPED_ID(idmap, inode))
529 retval = do_inode_permission(idmap, inode, mask);
533 retval = devcgroup_inode_permission(inode, mask);
537 return security_inode_permission(inode, mask);
572 struct inode *inode; /* path.dentry.d_inode */
787 BUG_ON(nd->inode != parent->d_inode);
977 nd->inode = d->d_inode;
985 nd->inode = nd->path.dentry->d_inode;
1014 nd->inode = nd->path.dentry->d_inode;
1089 * @inode: Used for idmapping.
1102 static inline int may_follow_link(struct nameidata *nd, const struct inode *inode)
1111 vfsuid = i_uid_into_vfsuid(idmap, inode);
1134 * @idmap: idmap of the mount the inode was found from
1135 * @inode: the source inode to hardlink from
1138 * - inode is not a regular file
1139 * - inode is setuid
1140 * - inode is setgid and group-exec
1146 struct inode *inode)
1148 umode_t mode = inode->i_mode;
1163 if (inode_permission(idmap, inode, MAY_READ | MAY_WRITE))
1171 * @idmap: idmap of the mount the inode was found from
1176 * - fsuid does not match inode
1178 * - not CAP_FOWNER in a namespace with the inode owner uid mapped
1180 * If the inode has been found through an idmapped mount the idmap of
1182 * care to map the inode according to @idmap before checking permissions.
1184 * raw inode simply pass @nop_mnt_idmap.
1190 struct inode *inode = link->dentry->d_inode;
1193 if (!vfsuid_valid(i_uid_into_vfsuid(idmap, inode)) ||
1194 !vfsgid_valid(i_gid_into_vfsgid(idmap, inode)))
1200 /* Source inode owner (or CAP_FOWNER) can hardlink all they like,
1203 if (safe_hardlink_source(idmap, inode) ||
1204 inode_owner_or_capable(idmap, inode))
1215 * @idmap: idmap of the mount the inode was found from
1217 * @inode: the inode of the file to open
1230 * If the inode has been found through an idmapped mount the idmap of
1232 * care to map the inode according to @idmap before checking permissions.
1234 * raw inode simply pass @nop_mnt_idmap.
1239 struct nameidata *nd, struct inode *const inode)
1244 if ((!sysctl_protected_fifos && S_ISFIFO(inode->i_mode)) ||
1245 (!sysctl_protected_regular && S_ISREG(inode->i_mode)) ||
1247 vfsuid_eq(i_uid_into_vfsuid(idmap, inode), dir_vfsuid) ||
1248 vfsuid_eq_kuid(i_uid_into_vfsuid(idmap, inode), current_fsuid()))
1253 ((sysctl_protected_fifos >= 2 && S_ISFIFO(inode->i_mode)) ||
1254 (sysctl_protected_regular >= 2 && S_ISREG(inode->i_mode))))) {
1255 const char *operation = S_ISFIFO(inode->i_mode) ?
1584 * Parent directory has inode locked exclusive. This is one
1596 struct inode *dir = base->d_inode;
1672 struct inode *inode = dir->d_inode;
1676 if (unlikely(IS_DEADDIR(inode)))
1694 old = inode->i_op->lookup(inode, dentry, flags);
1708 struct inode *inode = dir->d_inode;
1710 inode_lock_shared(inode);
1712 inode_unlock_shared(inode);
1720 int err = inode_permission(idmap, nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
1724 return inode_permission(idmap, nd->inode, MAY_EXEC);
1756 struct inode *inode, int flags)
1773 error = may_follow_link(nd, inode);
1785 } else if (atime_needs_update(&last->link, inode)) {
1791 error = security_inode_follow_link(link->dentry, inode,
1796 res = READ_ONCE(inode->i_link);
1798 const char * (*get)(struct dentry *, struct inode *,
1800 get = inode->i_op->get_link;
1802 res = get(NULL, inode, &last->done);
1804 res = get(link->dentry, inode, &last->done);
1806 res = get(link->dentry, inode, &last->done);
1829 * to do this check without having to look at inode->i_op,
1839 struct inode *inode;
1844 inode = path.dentry->d_inode;
1852 if (unlikely(!inode))
1860 nd->inode = inode;
1865 /* make sure that d_is_symlink above matches inode */
1872 return pick_link(nd, &path, inode, flags);
1890 nd->inode = path.dentry->d_inode;
1929 nd->inode = path.dentry->d_inode;
2319 nd->dir_vfsuid = i_uid_into_vfsuid(idmap, nd->inode);
2320 nd->dir_mode = nd->inode->i_mode;
2375 struct inode *inode = root->d_inode;
2379 nd->inode = inode;
2408 nd->inode = nd->path.dentry->d_inode;
2413 nd->inode = nd->path.dentry->d_inode;
2432 nd->inode = nd->path.dentry->d_inode;
2436 nd->inode = nd->path.dentry->d_inode;
2918 int __check_sticky(struct mnt_idmap *idmap, struct inode *dir,
2919 struct inode *inode)
2923 if (vfsuid_eq_kuid(i_uid_into_vfsuid(idmap, inode), fsuid))
2927 return !capable_wrt_inode_uidgid(idmap, inode, CAP_FOWNER);
2944 * 7. If the victim has an unknown uid or gid we can't change the inode.
2951 static int may_delete(struct mnt_idmap *idmap, struct inode *dir,
2954 struct inode *inode = d_backing_inode(victim);
2959 BUG_ON(!inode);
2964 if (!vfsuid_valid(i_uid_into_vfsuid(idmap, inode)) ||
2965 !vfsgid_valid(i_gid_into_vfsgid(idmap, inode)))
2976 if (check_sticky(idmap, dir, inode) || IS_APPEND(inode) ||
2977 IS_IMMUTABLE(inode) || IS_SWAPFILE(inode) ||
2978 HAS_UNMAPPED_ID(idmap, inode))
3004 struct inode *dir, struct dentry *child)
3103 * @dir: parent directory of the new inode
3104 * @mode: mode of the new inode to be created in @dir
3113 static inline umode_t mode_strip_umask(const struct inode *dir, umode_t mode)
3121 * vfs_prepare_mode - prepare the mode to be used for a new inode
3122 * @idmap: idmap of the mount the inode was found from
3123 * @dir: parent directory of the new inode
3124 * @mode: mode of the new inode
3144 const struct inode *dir, umode_t mode,
3162 * @idmap: idmap of the mount the inode was found from
3163 * @dir: inode of @dentry
3170 * If the inode has been found through an idmapped mount the idmap of
3172 * care to map the inode according to @idmap before checking permissions.
3174 * raw inode simply passs @nop_mnt_idmap.
3176 int vfs_create(struct mnt_idmap *idmap, struct inode *dir,
3203 struct inode *dir = dentry->d_parent->d_inode;
3230 struct inode *inode = dentry->d_inode;
3233 if (!inode)
3236 switch (inode->i_mode & S_IFMT) {
3262 error = inode_permission(idmap, inode, MAY_OPEN | acc_mode);
3269 if (IS_APPEND(inode)) {
3277 if (flag & O_NOATIME && !inode_owner_or_capable(idmap, inode))
3286 struct inode *inode = path->dentry->d_inode;
3287 int error = get_write_access(inode);
3297 put_write_access(inode);
3345 struct inode *dir = nd->path.dentry->d_inode;
3401 struct inode *dir_inode = dir->d_inode;
3650 * @idmap: idmap of the mount the inode was found from
3657 * If the inode has been found through an idmapped mount the idmap of
3659 * care to map the inode according to @idmap before checking permissions.
3661 * raw inode simply passs @nop_mnt_idmap.
3668 struct inode *dir = d_inode(parentpath->dentry);
3669 struct inode *inode;
3689 /* Don't check for other permissions, the inode was just created */
3693 inode = file_inode(file);
3695 spin_lock(&inode->i_lock);
3696 inode->i_state |= I_LINKABLE;
3697 spin_unlock(&inode->i_lock);
3699 ima_post_create_tmpfile(idmap, inode);
3705 * @idmap: idmap of the mount the inode was found from
3954 * @idmap: idmap of the mount the inode was found from
3955 * @dir: inode of @dentry
3962 * If the inode has been found through an idmapped mount the idmap of
3964 * care to map the inode according to @idmap before checking permissions.
3966 * raw inode simply passs @nop_mnt_idmap.
3968 int vfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
4081 * @idmap: idmap of the mount the inode was found from
4082 * @dir: inode of @dentry
4088 * If the inode has been found through an idmapped mount the idmap of
4090 * care to map the inode according to @idmap before checking permissions.
4092 * raw inode simply passs @nop_mnt_idmap.
4094 int vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
4163 * @idmap: idmap of the mount the inode was found from
4164 * @dir: inode of @dentry
4169 * If the inode has been found through an idmapped mount the idmap of
4171 * care to map the inode according to @idmap before checking permissions.
4173 * raw inode simply passs @nop_mnt_idmap.
4175 int vfs_rmdir(struct mnt_idmap *idmap, struct inode *dir,
4281 * @idmap: idmap of the mount the inode was found from
4284 * @delegated_inode: returns victim inode, if the inode is delegated.
4289 * return a reference to the inode in delegated_inode. The caller
4290 * should then break the delegation on that inode and retry. Because
4298 * If the inode has been found through an idmapped mount the idmap of
4300 * care to map the inode according to @idmap before checking permissions.
4302 * raw inode simply passs @nop_mnt_idmap.
4304 int vfs_unlink(struct mnt_idmap *idmap, struct inode *dir,
4305 struct dentry *dentry, struct inode **delegated_inode)
4307 struct inode *target = dentry->d_inode;
4362 struct inode *inode = NULL;
4363 struct inode *delegated_inode = NULL;
4386 inode = dentry->d_inode;
4389 ihold(inode);
4399 if (inode)
4400 iput(inode); /* truncate the inode here */
4401 inode = NULL;
4412 inode = NULL;
4446 * @idmap: idmap of the mount the inode was found from
4447 * @dir: inode of @dentry
4453 * If the inode has been found through an idmapped mount the idmap of
4455 * care to map the inode according to @idmap before checking permissions.
4457 * raw inode simply passs @nop_mnt_idmap.
4459 int vfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
4531 * @delegated_inode: returns inode needing a delegation break
4537 * inode in delegated_inode. The caller should then break the delegation
4545 * If the inode has been found through an idmapped mount the idmap of
4547 * care to map the inode according to @idmap before checking permissions.
4549 * raw inode simply passs @nop_mnt_idmap.
4552 struct inode *dir, struct dentry *new_dentry,
4553 struct inode **delegated_inode)
4555 struct inode *inode = old_dentry->d_inode;
4559 if (!inode)
4566 if (dir->i_sb != inode->i_sb)
4572 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4579 if (HAS_UNMAPPED_ID(idmap, inode))
4583 if (S_ISDIR(inode->i_mode))
4590 inode_lock(inode);
4592 if (inode->i_nlink == 0 && !(inode->i_state & I_LINKABLE))
4594 else if (max_links && inode->i_nlink >= max_links)
4597 error = try_break_deleg(inode, delegated_inode);
4602 if (!error && (inode->i_state & I_LINKABLE)) {
4603 spin_lock(&inode->i_lock);
4604 inode->i_state &= ~I_LINKABLE;
4605 spin_unlock(&inode->i_lock);
4607 inode_unlock(inode);
4609 fsnotify_link(dir, inode, new_dentry);
4629 struct inode *delegated_inode = NULL;
4715 * reference to the inode in delegated_inode. The caller should then
4756 struct inode *old_dir = rd->old_dir, *new_dir = rd->new_dir;
4759 struct inode **delegated_inode = rd->delegated_inode;
4762 struct inode *source = old_dentry->d_inode;
4763 struct inode *target = new_dentry->d_inode;
4828 * they get locked after any subdirectories (in inode address order).
4922 struct inode *delegated_inode = NULL;
5104 struct inode *inode = d_inode(dentry);
5109 if (unlikely(!(inode->i_opflags & IOP_DEFAULT_READLINK))) {
5110 if (unlikely(inode->i_op->readlink))
5111 return inode->i_op->readlink(dentry, buffer, buflen);
5116 spin_lock(&inode->i_lock);
5117 inode->i_opflags |= IOP_DEFAULT_READLINK;
5118 spin_unlock(&inode->i_lock);
5121 link = READ_ONCE(inode->i_link);
5123 link = inode->i_op->get_link(dentry, inode, &done);
5138 * Calls security hook and i_op->get_link() on the supplied inode.
5147 struct inode *inode = d_inode(dentry);
5152 res = inode->i_op->get_link(dentry, inode, done);
5159 const char *page_get_link(struct dentry *dentry, struct inode *inode,
5164 struct address_space *mapping = inode->i_mapping;
5182 nd_terminate_link(kaddr, inode->i_size, PAGE_SIZE - 1);
5205 int page_symlink(struct inode *inode, const char *symname, int len)
5207 struct address_space *mapping = inode->i_mapping;
5233 mark_inode_dirty(inode);