Skip to content

Commit 2e14967

Browse files
hallyntorvalds
authored andcommitted
userns: rename is_owner_or_cap to inode_owner_or_capable
And give it a kernel-doc comment. [[email protected]: btrfs changed in linux-next] Signed-off-by: Serge E. Hallyn <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Daniel Lezcano <[email protected]> Acked-by: David Howells <[email protected]> Cc: James Morris <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent e795b71 commit 2e14967

File tree

30 files changed

+47
-44
lines changed

30 files changed

+47
-44
lines changed

fs/9p/acl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
323323

324324
if (S_ISLNK(inode->i_mode))
325325
return -EOPNOTSUPP;
326-
if (!is_owner_or_cap(inode))
326+
if (!inode_owner_or_capable(inode))
327327
return -EPERM;
328328
if (value) {
329329
/* update the cached acl value */

fs/attr.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
5959

6060
/* Make sure a caller can chmod. */
6161
if (ia_valid & ATTR_MODE) {
62-
if (!is_owner_or_cap(inode))
62+
if (!inode_owner_or_capable(inode))
6363
return -EPERM;
6464
/* Also check the setgid bit! */
6565
if (!in_group_p((ia_valid & ATTR_GID) ? attr->ia_gid :
@@ -69,7 +69,7 @@ int inode_change_ok(const struct inode *inode, struct iattr *attr)
6969

7070
/* Check for setting the inode time. */
7171
if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) {
72-
if (!is_owner_or_cap(inode))
72+
if (!inode_owner_or_capable(inode))
7373
return -EPERM;
7474
}
7575

fs/btrfs/acl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
170170
int ret;
171171
struct posix_acl *acl = NULL;
172172

173-
if (!is_owner_or_cap(dentry->d_inode))
173+
if (!inode_owner_or_capable(dentry->d_inode))
174174
return -EPERM;
175175

176176
if (!IS_POSIXACL(dentry->d_inode))

fs/btrfs/ioctl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static int btrfs_ioctl_setflags(struct file *file, void __user *arg)
158158
FS_SYNC_FL | FS_DIRSYNC_FL))
159159
return -EOPNOTSUPP;
160160

161-
if (!is_owner_or_cap(inode))
161+
if (!inode_owner_or_capable(inode))
162162
return -EACCES;
163163

164164
mutex_lock(&inode->i_mutex);
@@ -1077,7 +1077,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file,
10771077
if (flags & ~BTRFS_SUBVOL_RDONLY)
10781078
return -EOPNOTSUPP;
10791079

1080-
if (!is_owner_or_cap(inode))
1080+
if (!inode_owner_or_capable(inode))
10811081
return -EACCES;
10821082

10831083
down_write(&root->fs_info->subvol_sem);

fs/ext2/acl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
406406
return -EINVAL;
407407
if (!test_opt(dentry->d_sb, POSIX_ACL))
408408
return -EOPNOTSUPP;
409-
if (!is_owner_or_cap(dentry->d_inode))
409+
if (!inode_owner_or_capable(dentry->d_inode))
410410
return -EPERM;
411411

412412
if (value) {

fs/ext2/ioctl.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3939
if (ret)
4040
return ret;
4141

42-
if (!is_owner_or_cap(inode)) {
42+
if (!inode_owner_or_capable(inode)) {
4343
ret = -EACCES;
4444
goto setflags_out;
4545
}
@@ -89,7 +89,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
8989
case EXT2_IOC_GETVERSION:
9090
return put_user(inode->i_generation, (int __user *) arg);
9191
case EXT2_IOC_SETVERSION:
92-
if (!is_owner_or_cap(inode))
92+
if (!inode_owner_or_capable(inode))
9393
return -EPERM;
9494
ret = mnt_want_write(filp->f_path.mnt);
9595
if (ret)
@@ -115,7 +115,7 @@ long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
115115
if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode))
116116
return -ENOTTY;
117117

118-
if (!is_owner_or_cap(inode))
118+
if (!inode_owner_or_capable(inode))
119119
return -EACCES;
120120

121121
if (get_user(rsv_window_size, (int __user *)arg))

fs/ext3/acl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ ext3_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
435435
return -EINVAL;
436436
if (!test_opt(inode->i_sb, POSIX_ACL))
437437
return -EOPNOTSUPP;
438-
if (!is_owner_or_cap(inode))
438+
if (!inode_owner_or_capable(inode))
439439
return -EPERM;
440440

441441
if (value) {

fs/ext3/ioctl.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3838
unsigned int oldflags;
3939
unsigned int jflag;
4040

41-
if (!is_owner_or_cap(inode))
41+
if (!inode_owner_or_capable(inode))
4242
return -EACCES;
4343

4444
if (get_user(flags, (int __user *) arg))
@@ -123,7 +123,7 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
123123
__u32 generation;
124124
int err;
125125

126-
if (!is_owner_or_cap(inode))
126+
if (!inode_owner_or_capable(inode))
127127
return -EPERM;
128128

129129
err = mnt_want_write(filp->f_path.mnt);
@@ -192,7 +192,7 @@ long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
192192
if (err)
193193
return err;
194194

195-
if (!is_owner_or_cap(inode)) {
195+
if (!inode_owner_or_capable(inode)) {
196196
err = -EACCES;
197197
goto setrsvsz_out;
198198
}

fs/ext4/acl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
433433
return -EINVAL;
434434
if (!test_opt(inode->i_sb, POSIX_ACL))
435435
return -EOPNOTSUPP;
436-
if (!is_owner_or_cap(inode))
436+
if (!inode_owner_or_capable(inode))
437437
return -EPERM;
438438

439439
if (value) {

fs/ext4/ioctl.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3838
unsigned int oldflags;
3939
unsigned int jflag;
4040

41-
if (!is_owner_or_cap(inode))
41+
if (!inode_owner_or_capable(inode))
4242
return -EACCES;
4343

4444
if (get_user(flags, (int __user *) arg))
@@ -146,7 +146,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
146146
__u32 generation;
147147
int err;
148148

149-
if (!is_owner_or_cap(inode))
149+
if (!inode_owner_or_capable(inode))
150150
return -EPERM;
151151

152152
err = mnt_want_write(filp->f_path.mnt);
@@ -298,7 +298,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
298298
case EXT4_IOC_MIGRATE:
299299
{
300300
int err;
301-
if (!is_owner_or_cap(inode))
301+
if (!inode_owner_or_capable(inode))
302302
return -EACCES;
303303

304304
err = mnt_want_write(filp->f_path.mnt);
@@ -320,7 +320,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
320320
case EXT4_IOC_ALLOC_DA_BLKS:
321321
{
322322
int err;
323-
if (!is_owner_or_cap(inode))
323+
if (!inode_owner_or_capable(inode))
324324
return -EACCES;
325325

326326
err = mnt_want_write(filp->f_path.mnt);

fs/fcntl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
159159

160160
/* O_NOATIME can only be set by the owner or superuser */
161161
if ((arg & O_NOATIME) && !(filp->f_flags & O_NOATIME))
162-
if (!is_owner_or_cap(inode))
162+
if (!inode_owner_or_capable(inode))
163163
return -EPERM;
164164

165165
/* required for strict SunOS emulation */

fs/generic_acl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ generic_acl_set(struct dentry *dentry, const char *name, const void *value,
7474
return -EINVAL;
7575
if (S_ISLNK(inode->i_mode))
7676
return -EOPNOTSUPP;
77-
if (!is_owner_or_cap(inode))
77+
if (!inode_owner_or_capable(inode))
7878
return -EPERM;
7979
if (value) {
8080
acl = posix_acl_from_xattr(value, size);

fs/gfs2/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
221221
goto out_drop_write;
222222

223223
error = -EACCES;
224-
if (!is_owner_or_cap(inode))
224+
if (!inode_owner_or_capable(inode))
225225
goto out;
226226

227227
error = 0;

fs/hfsplus/ioctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
4747
if (err)
4848
goto out;
4949

50-
if (!is_owner_or_cap(inode)) {
50+
if (!inode_owner_or_capable(inode)) {
5151
err = -EACCES;
5252
goto out_drop_write;
5353
}

fs/inode.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -1735,11 +1735,14 @@ void inode_init_owner(struct inode *inode, const struct inode *dir,
17351735
}
17361736
EXPORT_SYMBOL(inode_init_owner);
17371737

1738-
/*
1739-
* return true if current either has CAP_FOWNER to the
1740-
* file, or owns the file.
1738+
/**
1739+
* inode_owner_or_capable - check current task permissions to inode
1740+
* @inode: inode being checked
1741+
*
1742+
* Return true if current either has CAP_FOWNER to the inode, or
1743+
* owns the file.
17411744
*/
1742-
bool is_owner_or_cap(const struct inode *inode)
1745+
bool inode_owner_or_capable(const struct inode *inode)
17431746
{
17441747
struct user_namespace *ns = inode_userns(inode);
17451748

@@ -1749,4 +1752,4 @@ bool is_owner_or_cap(const struct inode *inode)
17491752
return true;
17501753
return false;
17511754
}
1752-
EXPORT_SYMBOL(is_owner_or_cap);
1755+
EXPORT_SYMBOL(inode_owner_or_capable);

fs/jffs2/acl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static int jffs2_acl_setxattr(struct dentry *dentry, const char *name,
402402

403403
if (name[0] != '\0')
404404
return -EINVAL;
405-
if (!is_owner_or_cap(dentry->d_inode))
405+
if (!inode_owner_or_capable(dentry->d_inode))
406406
return -EPERM;
407407

408408
if (value) {

fs/jfs/ioctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7272
if (err)
7373
return err;
7474

75-
if (!is_owner_or_cap(inode)) {
75+
if (!inode_owner_or_capable(inode)) {
7676
err = -EACCES;
7777
goto setflags_out;
7878
}

fs/jfs/xattr.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ static int can_set_system_xattr(struct inode *inode, const char *name,
678678
struct posix_acl *acl;
679679
int rc;
680680

681-
if (!is_owner_or_cap(inode))
681+
if (!inode_owner_or_capable(inode))
682682
return -EPERM;
683683

684684
/*

fs/logfs/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ long logfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
196196
if (IS_RDONLY(inode))
197197
return -EROFS;
198198

199-
if (!is_owner_or_cap(inode))
199+
if (!inode_owner_or_capable(inode))
200200
return -EACCES;
201201

202202
err = get_user(flags, (int __user *)arg);

fs/namei.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ static int may_open(struct path *path, int acc_mode, int flag)
20362036
}
20372037

20382038
/* O_NOATIME can only be set by the owner or superuser */
2039-
if (flag & O_NOATIME && !is_owner_or_cap(inode))
2039+
if (flag & O_NOATIME && !inode_owner_or_capable(inode))
20402040
return -EPERM;
20412041

20422042
/*

fs/nilfs2/ioctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int nilfs_ioctl_setflags(struct inode *inode, struct file *filp,
113113
unsigned int flags, oldflags;
114114
int ret;
115115

116-
if (!is_owner_or_cap(inode))
116+
if (!inode_owner_or_capable(inode))
117117
return -EACCES;
118118

119119
if (get_user(flags, (int __user *)argp))

fs/ocfs2/acl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name,
497497
if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
498498
return -EOPNOTSUPP;
499499

500-
if (!is_owner_or_cap(inode))
500+
if (!inode_owner_or_capable(inode))
501501
return -EPERM;
502502

503503
if (value) {

fs/ocfs2/ioctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
8282
}
8383

8484
status = -EACCES;
85-
if (!is_owner_or_cap(inode))
85+
if (!inode_owner_or_capable(inode))
8686
goto bail_unlock;
8787

8888
if (!S_ISDIR(inode->i_mode))

fs/reiserfs/ioctl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5959
if (err)
6060
break;
6161

62-
if (!is_owner_or_cap(inode)) {
62+
if (!inode_owner_or_capable(inode)) {
6363
err = -EPERM;
6464
goto setflags_out;
6565
}
@@ -103,7 +103,7 @@ long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
103103
err = put_user(inode->i_generation, (int __user *)arg);
104104
break;
105105
case REISERFS_IOC_SETVERSION:
106-
if (!is_owner_or_cap(inode)) {
106+
if (!inode_owner_or_capable(inode)) {
107107
err = -EPERM;
108108
break;
109109
}

fs/reiserfs/xattr_acl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ posix_acl_set(struct dentry *dentry, const char *name, const void *value,
2626
size_t jcreate_blocks;
2727
if (!reiserfs_posixacl(inode->i_sb))
2828
return -EOPNOTSUPP;
29-
if (!is_owner_or_cap(inode))
29+
if (!inode_owner_or_capable(inode))
3030
return -EPERM;
3131

3232
if (value) {

fs/ubifs/ioctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
160160
if (IS_RDONLY(inode))
161161
return -EROFS;
162162

163-
if (!is_owner_or_cap(inode))
163+
if (!inode_owner_or_capable(inode))
164164
return -EACCES;
165165

166166
if (get_user(flags, (int __user *) arg))

fs/utimes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static int utimes_common(struct path *path, struct timespec *times)
9595
if (IS_IMMUTABLE(inode))
9696
goto mnt_drop_write_and_out;
9797

98-
if (!is_owner_or_cap(inode)) {
98+
if (!inode_owner_or_capable(inode)) {
9999
error = inode_permission(inode, MAY_WRITE);
100100
if (error)
101101
goto mnt_drop_write_and_out;

fs/xattr.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ xattr_permission(struct inode *inode, const char *name, int mask)
5959
if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
6060
return -EPERM;
6161
if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
62-
(mask & MAY_WRITE) && !is_owner_or_cap(inode))
62+
(mask & MAY_WRITE) && !inode_owner_or_capable(inode))
6363
return -EPERM;
6464
}
6565

include/linux/fs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,7 @@ enum {
14631463
*/
14641464
extern struct user_namespace init_user_ns;
14651465
#define inode_userns(inode) (&init_user_ns)
1466-
extern bool is_owner_or_cap(const struct inode *inode);
1466+
extern bool inode_owner_or_capable(const struct inode *inode);
14671467

14681468
/* not quite ready to be deprecated, but... */
14691469
extern void lock_super(struct super_block *);

security/selinux/hooks.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2725,7 +2725,7 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
27252725
if (!(sbsec->flags & SE_SBLABELSUPP))
27262726
return -EOPNOTSUPP;
27272727

2728-
if (!is_owner_or_cap(inode))
2728+
if (!inode_owner_or_capable(inode))
27292729
return -EPERM;
27302730

27312731
COMMON_AUDIT_DATA_INIT(&ad, FS);

0 commit comments

Comments
 (0)