Lines Matching defs:inode

59  * With the new dcache, the pathname is stored at each inode, at least as
60 * long as the refcount of the inode is positive. As a side effect, the
61 * size of the dcache depends on the inode cache and thus is dynamic.
262 static int check_acl(struct inode *inode, int mask)
268 acl = get_cached_acl_rcu(inode, ACL_TYPE_ACCESS);
274 return posix_acl_permission(inode, acl, mask);
277 acl = get_acl(inode, ACL_TYPE_ACCESS);
281 int error = posix_acl_permission(inode, acl, mask);
296 static int acl_permission_check(struct inode *inode, int mask)
298 unsigned int mode = inode->i_mode;
301 if (likely(uid_eq(current_fsuid(), inode->i_uid))) {
308 if (IS_POSIXACL(inode) && (mode & S_IRWXG)) {
309 int error = check_acl(inode, mask);
323 if (in_group_p(inode->i_gid))
333 * @inode: inode to check access rights for
346 int generic_permission(struct inode *inode, int mask)
353 ret = acl_permission_check(inode, mask);
357 if (S_ISDIR(inode->i_mode)) {
360 if (capable_wrt_inode_uidgid(inode,
363 if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
373 if (capable_wrt_inode_uidgid(inode, CAP_DAC_READ_SEARCH))
380 if (!(mask & MAY_EXEC) || (inode->i_mode & S_IXUGO))
381 if (capable_wrt_inode_uidgid(inode, CAP_DAC_OVERRIDE))
390 * even looking at the inode->i_op values. So we keep a cache
391 * flag in inode->i_opflags, that says "this has not special
394 static inline int do_inode_permission(struct inode *inode, int mask)
396 if (unlikely(!(inode->i_opflags & IOP_FASTPERM))) {
397 if (likely(inode->i_op->permission))
398 return inode->i_op->permission(inode, mask);
400 /* This gets set once for the inode lifetime */
401 spin_lock(&inode->i_lock);
402 inode->i_opflags |= IOP_FASTPERM;
403 spin_unlock(&inode->i_lock);
405 return generic_permission(inode, mask);
410 * @sb: Superblock of inode to check permission on
411 * @inode: Inode to check permission on
414 * Separate out file-system wide checks from inode-specific permission checks.
416 static int sb_permission(struct super_block *sb, struct inode *inode, int mask)
419 umode_t mode = inode->i_mode;
429 * inode_permission - Check for access rights to a given inode
430 * @inode: Inode to check permission on
433 * Check for read/write/execute permissions on an inode. We use fs[ug]id for
439 int inode_permission(struct inode *inode, int mask)
443 retval = sb_permission(inode->i_sb, inode, mask);
451 if (IS_IMMUTABLE(inode))
459 if (HAS_UNMAPPED_ID(inode))
463 retval = do_inode_permission(inode, mask);
467 retval = devcgroup_inode_permission(inode, mask);
471 return security_inode_permission(inode, mask);
506 struct inode *inode; /* path.dentry.d_inode */
710 BUG_ON(nd->inode != parent->d_inode);
897 nd->inode = d->d_inode;
905 nd->inode = nd->path.dentry->d_inode;
934 nd->inode = nd->path.dentry->d_inode;
971 static inline int may_follow_link(struct nameidata *nd, const struct inode *inode)
977 if (uid_eq(current_cred()->fsuid, inode->i_uid))
985 if (uid_valid(nd->dir_uid) && uid_eq(nd->dir_uid, inode->i_uid))
998 * @inode: the source inode to hardlink from
1001 * - inode is not a regular file
1002 * - inode is setuid
1003 * - inode is setgid and group-exec
1008 static bool safe_hardlink_source(struct inode *inode)
1010 umode_t mode = inode->i_mode;
1025 if (inode_permission(inode, MAY_READ | MAY_WRITE))
1037 * - fsuid does not match inode
1039 * - not CAP_FOWNER in a namespace with the inode owner uid mapped
1045 struct inode *inode = link->dentry->d_inode;
1048 if (!uid_valid(inode->i_uid) || !gid_valid(inode->i_gid))
1054 /* Source inode owner (or CAP_FOWNER) can hardlink all they like,
1057 if (safe_hardlink_source(inode) || inode_owner_or_capable(inode))
1070 * @inode: the inode of the file to open
1086 struct inode * const inode)
1088 if ((!sysctl_protected_fifos && S_ISFIFO(inode->i_mode)) ||
1089 (!sysctl_protected_regular && S_ISREG(inode->i_mode)) ||
1091 uid_eq(inode->i_uid, dir_uid) ||
1092 uid_eq(current_fsuid(), inode->i_uid))
1097 ((sysctl_protected_fifos >= 2 && S_ISFIFO(inode->i_mode)) ||
1098 (sysctl_protected_regular >= 2 && S_ISREG(inode->i_mode))))) {
1099 const char *operation = S_ISFIFO(inode->i_mode) ?
1329 struct inode **inode, unsigned *seqp)
1359 *inode = dentry->d_inode;
1379 struct path *path, struct inode **inode,
1389 if (unlikely(!*inode))
1391 if (likely(__follow_mount_rcu(nd, path, inode, seqp)))
1411 *inode = d_backing_inode(path->dentry);
1439 * Parent directory has inode locked exclusive. This is one
1450 struct inode *dir = base->d_inode;
1472 struct inode **inode,
1493 * This sequence count validates that the inode matches
1496 *inode = d_backing_inode(dentry);
1540 struct inode *inode = dir->d_inode;
1544 if (unlikely(IS_DEADDIR(inode)))
1562 old = inode->i_op->lookup(inode, dentry, flags);
1576 struct inode *inode = dir->d_inode;
1578 inode_lock_shared(inode);
1580 inode_unlock_shared(inode);
1587 int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
1591 return inode_permission(nd->inode, MAY_EXEC);
1623 struct inode *inode, unsigned seq, int flags)
1640 error = may_follow_link(nd, inode);
1652 } else if (atime_needs_update(&last->link, inode)) {
1658 error = security_inode_follow_link(link->dentry, inode,
1663 res = READ_ONCE(inode->i_link);
1665 const char * (*get)(struct dentry *, struct inode *,
1667 get = inode->i_op->get_link;
1669 res = get(NULL, inode, &last->done);
1671 res = get(link->dentry, inode, &last->done);
1673 res = get(link->dentry, inode, &last->done);
1696 * to do this check without having to look at inode->i_op,
1701 struct dentry *dentry, struct inode *inode, unsigned seq)
1704 int err = handle_mounts(nd, dentry, &path, &inode, &seq);
1718 nd->inode = inode;
1723 /* make sure that d_is_symlink above matches inode */
1730 return pick_link(nd, &path, inode, seq, flags);
1734 struct inode **inodep,
1750 nd->inode = path.dentry->d_inode;
1774 struct inode **inodep,
1789 nd->inode = path.dentry->d_inode;
1815 struct inode *inode;
1824 parent = follow_dotdot_rcu(nd, &inode, &seq);
1826 parent = follow_dotdot(nd, &inode, &seq);
1831 nd->path.dentry, nd->inode, nd->seq);
1834 parent, inode, seq);
1858 struct inode *inode;
1870 dentry = lookup_fast(nd, &inode, &seq);
1880 return step_into(nd, flags, dentry, inode, seq);
2187 nd->dir_uid = nd->inode->i_uid;
2188 nd->dir_mode = nd->inode->i_mode;
2242 struct inode *inode = root->d_inode;
2246 nd->inode = inode;
2275 nd->inode = nd->path.dentry->d_inode;
2280 nd->inode = nd->path.dentry->d_inode;
2299 nd->inode = nd->path.dentry->d_inode;
2303 nd->inode = nd->path.dentry->d_inode;
2334 nd->path.dentry, nd->inode, nd->seq));
2668 int __check_sticky(struct inode *dir, struct inode *inode)
2672 if (uid_eq(inode->i_uid, fsuid))
2676 return !capable_wrt_inode_uidgid(inode, CAP_FOWNER);
2693 * 7. If the victim has an unknown uid or gid we can't change the inode.
2700 static int may_delete(struct inode *dir, struct dentry *victim, bool isdir)
2702 struct inode *inode = d_backing_inode(victim);
2707 BUG_ON(!inode);
2712 if (!uid_valid(inode->i_uid) || !gid_valid(inode->i_gid))
2723 if (check_sticky(dir, inode) || IS_APPEND(inode) ||
2724 IS_IMMUTABLE(inode) || IS_SWAPFILE(inode) || HAS_UNMAPPED_ID(inode))
2749 static inline int may_create(struct inode *dir, struct dentry *child)
2804 * @dir: parent directory of the new inode
2805 * @mode: mode of the new inode to be created in @dir
2814 static inline umode_t mode_strip_umask(const struct inode *dir, umode_t mode)
2822 * vfs_prepare_mode - prepare the mode to be used for a new inode
2823 * @dir: parent directory of the new inode
2824 * @mode: mode of the new inode
2843 static inline umode_t vfs_prepare_mode(const struct inode *dir, umode_t mode,
2859 int vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
2884 struct inode *dir = dentry->d_parent->d_inode;
2910 struct inode *inode = dentry->d_inode;
2913 if (!inode)
2916 switch (inode->i_mode & S_IFMT) {
2942 error = inode_permission(inode, MAY_OPEN | acc_mode);
2949 if (IS_APPEND(inode)) {
2957 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
2966 struct inode *inode = path->dentry->d_inode;
2967 int error = get_write_access(inode);
2981 put_write_access(inode);
3029 struct inode *dir = nd->path.dentry->d_inode;
3084 struct inode *dir_inode = dir->d_inode;
3193 struct inode *inode;
3209 dentry = lookup_fast(nd, &inode, &seq);
3263 res = step_into(nd, WALK_TRAILING, dentry, inode, seq);
3331 struct inode *dir = dentry->d_inode;
3332 struct inode *inode;
3351 inode = child->d_inode;
3352 if (unlikely(!inode))
3355 spin_lock(&inode->i_lock);
3356 inode->i_state |= I_LINKABLE;
3357 spin_unlock(&inode->i_lock);
3359 ima_post_create_tmpfile(inode);
3387 /* Don't check for other permissions, the inode was just created */
3591 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
3693 int vfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
3753 int vfs_rmdir(struct inode *dir, struct dentry *dentry)
3859 * @delegated_inode: returns victim inode, if the inode is delegated.
3864 * return a reference to the inode in delegated_inode. The caller
3865 * should then break the delegation on that inode and retry. Because
3873 int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegated_inode)
3875 struct inode *target = dentry->d_inode;
3928 struct inode *inode = NULL;
3929 struct inode *delegated_inode = NULL;
3951 inode = dentry->d_inode;
3954 ihold(inode);
3963 if (inode)
3964 iput(inode); /* truncate the inode here */
3965 inode = NULL;
3976 inode = NULL;
4007 int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
4075 * @delegated_inode: returns inode needing a delegation break
4081 * inode in delegated_inode. The caller should then break the delegation
4089 int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry, struct inode **delegated_inode)
4091 struct inode *inode = old_dentry->d_inode;
4095 if (!inode)
4102 if (dir->i_sb != inode->i_sb)
4108 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4115 if (HAS_UNMAPPED_ID(inode))
4119 if (S_ISDIR(inode->i_mode))
4126 inode_lock(inode);
4128 if (inode->i_nlink == 0 && !(inode->i_state & I_LINKABLE))
4130 else if (max_links && inode->i_nlink >= max_links)
4133 error = try_break_deleg(inode, delegated_inode);
4138 if (!error && (inode->i_state & I_LINKABLE)) {
4139 spin_lock(&inode->i_lock);
4140 inode->i_state &= ~I_LINKABLE;
4141 spin_unlock(&inode->i_lock);
4143 inode_unlock(inode);
4145 fsnotify_link(dir, inode, new_dentry);
4164 struct inode *delegated_inode = NULL;
4241 * @delegated_inode: returns an inode needing a delegation break
4248 * reference to the inode in delegated_inode. The caller should then
4286 int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
4287 struct inode *new_dir, struct dentry *new_dentry,
4288 struct inode **delegated_inode, unsigned int flags)
4292 struct inode *source = old_dentry->d_inode;
4293 struct inode *target = new_dentry->d_inode;
4354 * they get locked after any subdirectories (in inode address order).
4443 struct inode *delegated_inode = NULL;
4623 struct inode *inode = d_inode(dentry);
4628 if (unlikely(!(inode->i_opflags & IOP_DEFAULT_READLINK))) {
4629 if (unlikely(inode->i_op->readlink))
4630 return inode->i_op->readlink(dentry, buffer, buflen);
4635 spin_lock(&inode->i_lock);
4636 inode->i_opflags |= IOP_DEFAULT_READLINK;
4637 spin_unlock(&inode->i_lock);
4640 link = READ_ONCE(inode->i_link);
4642 link = inode->i_op->get_link(dentry, inode, &done);
4657 * Calls security hook and i_op->get_link() on the supplied inode.
4666 struct inode *inode = d_inode(dentry);
4671 res = inode->i_op->get_link(dentry, inode, done);
4678 const char *page_get_link(struct dentry *dentry, struct inode *inode,
4683 struct address_space *mapping = inode->i_mapping;
4701 nd_terminate_link(kaddr, inode->i_size, PAGE_SIZE - 1);
4727 int __page_symlink(struct inode *inode, const char *symname, int len, int nofs)
4729 struct address_space *mapping = inode->i_mapping;
4752 mark_inode_dirty(inode);
4759 int page_symlink(struct inode *inode, const char *symname, int len)
4761 return __page_symlink(inode, symname, len,
4762 !mapping_gfp_constraint(inode->i_mapping, __GFP_FS));