Skip to content

Commit 7bd2ade

Browse files
Jebaitednekocyberknight777
authored andcommitted
fs: ntfs3: disallow namespaces
1 parent b4e1457 commit 7bd2ade

5 files changed

Lines changed: 49 additions & 55 deletions

File tree

fs/ntfs3/file.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static long ntfs_compat_ioctl(struct file *filp, u32 cmd, unsigned long arg)
7070
/*
7171
* ntfs_getattr - inode_operations::getattr
7272
*/
73-
int ntfs_getattr(struct user_namespace *mnt_userns, const struct path *path,
73+
int ntfs_getattr(const struct path *path,
7474
struct kstat *stat, u32 request_mask, u32 flags)
7575
{
7676
struct inode *inode = d_inode(path->dentry);
@@ -84,7 +84,7 @@ int ntfs_getattr(struct user_namespace *mnt_userns, const struct path *path,
8484

8585
stat->attributes_mask |= STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED;
8686

87-
generic_fillattr(mnt_userns, inode, stat);
87+
generic_fillattr(inode, stat);
8888

8989
stat->result_mask |= STATX_BTIME;
9090
stat->btime = ni->i_crtime;
@@ -726,7 +726,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
726726
/*
727727
* ntfs3_setattr - inode_operations::setattr
728728
*/
729-
int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
729+
int ntfs3_setattr(struct dentry *dentry,
730730
struct iattr *attr)
731731
{
732732
struct super_block *sb = dentry->d_sb;
@@ -745,7 +745,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
745745
ia_valid = attr->ia_valid;
746746
}
747747

748-
err = setattr_prepare(mnt_userns, dentry, attr);
748+
err = setattr_prepare(dentry, attr);
749749
if (err)
750750
goto out;
751751

@@ -770,10 +770,10 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
770770
ni->ni_flags |= NI_FLAG_UPDATE_PARENT;
771771
}
772772

773-
setattr_copy(mnt_userns, inode, attr);
773+
setattr_copy(inode, attr);
774774

775775
if (mode != inode->i_mode) {
776-
err = ntfs_acl_chmod(mnt_userns, inode);
776+
err = ntfs_acl_chmod(inode);
777777
if (err)
778778
goto out;
779779

fs/ntfs3/inode.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,7 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info *sbi, const char *symname,
11731173
return ERR_PTR(err);
11741174
}
11751175

1176-
struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
1177-
struct inode *dir, struct dentry *dentry,
1176+
struct inode *ntfs_create_inode(struct inode *dir, struct dentry *dentry,
11781177
const struct cpu_str *uni, umode_t mode,
11791178
dev_t dev, const char *symname, u32 size,
11801179
struct ntfs_fnd *fnd)
@@ -1286,7 +1285,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
12861285
goto out3;
12871286
}
12881287
inode = &ni->vfs_inode;
1289-
inode_init_owner(mnt_userns, inode, dir, mode);
1288+
inode_init_owner(inode, dir, mode);
12901289
mode = inode->i_mode;
12911290

12921291
inode->i_atime = inode->i_mtime = inode->i_ctime = ni->i_crtime =
@@ -1577,7 +1576,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
15771576

15781577
#ifdef CONFIG_NTFS3_FS_POSIX_ACL
15791578
if (!S_ISLNK(mode) && (sb->s_flags & SB_POSIXACL)) {
1580-
err = ntfs_init_acl(mnt_userns, inode, dir);
1579+
err = ntfs_init_acl(inode, dir);
15811580
if (err)
15821581
goto out6;
15831582
} else

fs/ntfs3/namei.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,
9696
/*
9797
* ntfs_create - inode_operations::create
9898
*/
99-
static int ntfs_create(struct user_namespace *mnt_userns, struct inode *dir,
99+
static int ntfs_create(struct inode *dir,
100100
struct dentry *dentry, umode_t mode, bool excl)
101101
{
102102
struct ntfs_inode *ni = ntfs_i(dir);
103103
struct inode *inode;
104104

105105
ni_lock_dir(ni);
106106

107-
inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, S_IFREG | mode,
107+
inode = ntfs_create_inode(dir, dentry, NULL, S_IFREG | mode,
108108
0, NULL, 0, NULL);
109109

110110
ni_unlock(ni);
@@ -117,15 +117,15 @@ static int ntfs_create(struct user_namespace *mnt_userns, struct inode *dir,
117117
*
118118
* inode_operations::mknod
119119
*/
120-
static int ntfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
120+
static int ntfs_mknod(struct inode *dir,
121121
struct dentry *dentry, umode_t mode, dev_t rdev)
122122
{
123123
struct ntfs_inode *ni = ntfs_i(dir);
124124
struct inode *inode;
125125

126126
ni_lock_dir(ni);
127127

128-
inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, mode, rdev,
128+
inode = ntfs_create_inode(dir, dentry, NULL, mode, rdev,
129129
NULL, 0, NULL);
130130

131131
ni_unlock(ni);
@@ -195,7 +195,7 @@ static int ntfs_unlink(struct inode *dir, struct dentry *dentry)
195195
/*
196196
* ntfs_symlink - inode_operations::symlink
197197
*/
198-
static int ntfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
198+
static int ntfs_symlink(struct inode *dir,
199199
struct dentry *dentry, const char *symname)
200200
{
201201
u32 size = strlen(symname);
@@ -204,7 +204,7 @@ static int ntfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
204204

205205
ni_lock_dir(ni);
206206

207-
inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, S_IFLNK | 0777,
207+
inode = ntfs_create_inode(dir, dentry, NULL, S_IFLNK | 0777,
208208
0, symname, size, NULL);
209209

210210
ni_unlock(ni);
@@ -215,15 +215,15 @@ static int ntfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
215215
/*
216216
* ntfs_mkdir- inode_operations::mkdir
217217
*/
218-
static int ntfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
218+
static int ntfs_mkdir(struct inode *dir,
219219
struct dentry *dentry, umode_t mode)
220220
{
221221
struct inode *inode;
222222
struct ntfs_inode *ni = ntfs_i(dir);
223223

224224
ni_lock_dir(ni);
225225

226-
inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, S_IFDIR | mode,
226+
inode = ntfs_create_inode(dir, dentry, NULL, S_IFDIR | mode,
227227
0, NULL, 0, NULL);
228228

229229
ni_unlock(ni);
@@ -251,7 +251,7 @@ static int ntfs_rmdir(struct inode *dir, struct dentry *dentry)
251251
/*
252252
* ntfs_rename - inode_operations::rename
253253
*/
254-
static int ntfs_rename(struct user_namespace *mnt_userns, struct inode *dir,
254+
static int ntfs_rename(struct inode *dir,
255255
struct dentry *dentry, struct inode *new_dir,
256256
struct dentry *new_dentry, u32 flags)
257257
{

fs/ntfs3/ntfs_fs.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,11 @@ bool dir_is_empty(struct inode *dir);
459459
extern const struct file_operations ntfs_dir_operations;
460460

461461
/* Globals from file.c */
462-
int ntfs_getattr(struct user_namespace *mnt_userns, const struct path *path,
462+
int ntfs_getattr(const struct path *path,
463463
struct kstat *stat, u32 request_mask, u32 flags);
464464
void ntfs_sparse_cluster(struct inode *inode, struct page *page0, CLST vcn,
465465
CLST len);
466-
int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
466+
int ntfs3_setattr(struct dentry *dentry,
467467
struct iattr *attr);
468468
int ntfs_file_open(struct inode *inode, struct file *file);
469469
int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
@@ -668,8 +668,7 @@ int ntfs_sync_inode(struct inode *inode);
668668
int ntfs_flush_inodes(struct super_block *sb, struct inode *i1,
669669
struct inode *i2);
670670
int inode_write_data(struct inode *inode, const void *data, size_t bytes);
671-
struct inode *ntfs_create_inode(struct user_namespace *mnt_userns,
672-
struct inode *dir, struct dentry *dentry,
671+
struct inode *ntfs_create_inode(struct inode *dir, struct dentry *dentry,
673672
const struct cpu_str *uni, umode_t mode,
674673
dev_t dev, const char *symname, u32 size,
675674
struct ntfs_fnd *fnd);
@@ -810,17 +809,17 @@ int ntfs_cmp_names_cpu(const struct cpu_str *uni1, const struct le_str *uni2,
810809
/* globals from xattr.c */
811810
#ifdef CONFIG_NTFS3_FS_POSIX_ACL
812811
struct posix_acl *ntfs_get_acl(struct inode *inode, int type);
813-
int ntfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
812+
int ntfs_set_acl(struct inode *inode,
814813
struct posix_acl *acl, int type);
815-
int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
814+
int ntfs_init_acl(struct inode *inode,
816815
struct inode *dir);
817816
#else
818817
#define ntfs_get_acl NULL
819818
#define ntfs_set_acl NULL
820819
#endif
821820

822-
int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode);
823-
int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode,
821+
int ntfs_acl_chmod(struct inode *inode);
822+
int ntfs_permission(struct inode *inode,
824823
int mask);
825824
ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
826825
extern const struct xattr_handler *ntfs_xattr_handlers[];

fs/ntfs3/xattr.c

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,7 @@ static inline void ntfs_posix_acl_release(struct posix_acl *acl)
484484
kfree(acl);
485485
}
486486

487-
static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
488-
struct inode *inode, int type,
487+
static struct posix_acl *ntfs_get_acl_ex(struct inode *inode, int type,
489488
int locked)
490489
{
491490
struct ntfs_inode *ni = ntfs_i(inode);
@@ -520,7 +519,7 @@ static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
520519

521520
/* Translate extended attribute to acl. */
522521
if (err >= 0) {
523-
acl = posix_acl_from_xattr(mnt_userns, buf, err);
522+
acl = posix_acl_from_xattr(&init_user_ns, buf, err);
524523
if (!IS_ERR(acl))
525524
set_cached_acl(inode, type, acl);
526525
} else {
@@ -538,11 +537,10 @@ static struct posix_acl *ntfs_get_acl_ex(struct user_namespace *mnt_userns,
538537
struct posix_acl *ntfs_get_acl(struct inode *inode, int type)
539538
{
540539
/* TODO: init_user_ns? */
541-
return ntfs_get_acl_ex(&init_user_ns, inode, type, 0);
540+
return ntfs_get_acl_ex(inode, type, 0);
542541
}
543542

544-
static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
545-
struct inode *inode, struct posix_acl *acl,
543+
static noinline int ntfs_set_acl_ex(struct inode *inode, struct posix_acl *acl,
546544
int type, int locked)
547545
{
548546
const char *name;
@@ -599,7 +597,7 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
599597
if (!value)
600598
return -ENOMEM;
601599

602-
err = posix_acl_to_xattr(mnt_userns, acl, value, size);
600+
err = posix_acl_to_xattr(&init_user_ns, acl, value, size);
603601
if (err < 0)
604602
goto out;
605603
}
@@ -617,14 +615,13 @@ static noinline int ntfs_set_acl_ex(struct user_namespace *mnt_userns,
617615
/*
618616
* ntfs_set_acl - inode_operations::set_acl
619617
*/
620-
int ntfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
618+
int ntfs_set_acl(struct inode *inode,
621619
struct posix_acl *acl, int type)
622620
{
623-
return ntfs_set_acl_ex(mnt_userns, inode, acl, type, 0);
621+
return ntfs_set_acl_ex(inode, acl, type, 0);
624622
}
625623

626-
static int ntfs_xattr_get_acl(struct user_namespace *mnt_userns,
627-
struct inode *inode, int type, void *buffer,
624+
static int ntfs_xattr_get_acl(struct inode *inode, int type, void *buffer,
628625
size_t size)
629626
{
630627
struct posix_acl *acl;
@@ -642,14 +639,13 @@ static int ntfs_xattr_get_acl(struct user_namespace *mnt_userns,
642639
if (!acl)
643640
return -ENODATA;
644641

645-
err = posix_acl_to_xattr(mnt_userns, acl, buffer, size);
642+
err = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
646643
ntfs_posix_acl_release(acl);
647644

648645
return err;
649646
}
650647

651-
static int ntfs_xattr_set_acl(struct user_namespace *mnt_userns,
652-
struct inode *inode, int type, const void *value,
648+
static int ntfs_xattr_set_acl(struct inode *inode, int type, const void *value,
653649
size_t size)
654650
{
655651
struct posix_acl *acl;
@@ -660,24 +656,24 @@ static int ntfs_xattr_set_acl(struct user_namespace *mnt_userns,
660656
return -EOPNOTSUPP;
661657
}
662658

663-
if (!inode_owner_or_capable(mnt_userns, inode))
659+
if (!inode_owner_or_capable(inode))
664660
return -EPERM;
665661

666662
if (!value) {
667663
acl = NULL;
668664
} else {
669-
acl = posix_acl_from_xattr(mnt_userns, value, size);
665+
acl = posix_acl_from_xattr(&init_user_ns, value, size);
670666
if (IS_ERR(acl))
671667
return PTR_ERR(acl);
672668

673669
if (acl) {
674-
err = posix_acl_valid(mnt_userns, acl);
670+
err = posix_acl_valid(&init_user_ns, acl);
675671
if (err)
676672
goto release_and_out;
677673
}
678674
}
679675

680-
err = ntfs_set_acl(mnt_userns, inode, acl, type);
676+
err = ntfs_set_acl(inode, acl, type);
681677

682678
release_and_out:
683679
ntfs_posix_acl_release(acl);
@@ -689,7 +685,7 @@ static int ntfs_xattr_set_acl(struct user_namespace *mnt_userns,
689685
*
690686
* Called from ntfs_create_inode().
691687
*/
692-
int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
688+
int ntfs_init_acl(struct inode *inode,
693689
struct inode *dir)
694690
{
695691
struct posix_acl *default_acl, *acl;
@@ -701,7 +697,7 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
701697
*/
702698
inode->i_default_acl = NULL;
703699

704-
default_acl = ntfs_get_acl_ex(mnt_userns, dir, ACL_TYPE_DEFAULT, 1);
700+
default_acl = ntfs_get_acl_ex(dir, ACL_TYPE_DEFAULT, 1);
705701

706702
if (!default_acl || default_acl == ERR_PTR(-EOPNOTSUPP)) {
707703
inode->i_mode &= ~current_umask();
@@ -729,13 +725,13 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
729725
}
730726

731727
if (default_acl)
732-
err = ntfs_set_acl_ex(mnt_userns, inode, default_acl,
728+
err = ntfs_set_acl_ex(inode, default_acl,
733729
ACL_TYPE_DEFAULT, 1);
734730

735731
if (!acl)
736732
inode->i_acl = NULL;
737733
else if (!err)
738-
err = ntfs_set_acl_ex(mnt_userns, inode, acl, ACL_TYPE_ACCESS,
734+
err = ntfs_set_acl_ex(inode, acl, ACL_TYPE_ACCESS,
739735
1);
740736

741737
posix_acl_release(acl);
@@ -750,7 +746,7 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
750746
/*
751747
* ntfs_acl_chmod - Helper for ntfs3_setattr().
752748
*/
753-
int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode)
749+
int ntfs_acl_chmod(struct inode *inode)
754750
{
755751
struct super_block *sb = inode->i_sb;
756752

@@ -760,21 +756,21 @@ int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode)
760756
if (S_ISLNK(inode->i_mode))
761757
return -EOPNOTSUPP;
762758

763-
return posix_acl_chmod(mnt_userns, inode, inode->i_mode);
759+
return posix_acl_chmod(inode, inode->i_mode);
764760
}
765761

766762
/*
767763
* ntfs_permission - inode_operations::permission
768764
*/
769-
int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode,
765+
int ntfs_permission(struct inode *inode,
770766
int mask)
771767
{
772768
if (ntfs_sb(inode->i_sb)->options.no_acs_rules) {
773769
/* "No access rules" mode - Allow all changes. */
774770
return 0;
775771
}
776772

777-
return generic_permission(mnt_userns, inode, mask);
773+
return generic_permission(inode, mask);
778774
}
779775

780776
/*
@@ -886,7 +882,7 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,
886882
sizeof(XATTR_NAME_POSIX_ACL_DEFAULT)))) {
887883
/* TODO: init_user_ns? */
888884
err = ntfs_xattr_get_acl(
889-
&init_user_ns, inode,
885+
inode,
890886
name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1
891887
? ACL_TYPE_ACCESS
892888
: ACL_TYPE_DEFAULT,
@@ -1013,7 +1009,7 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler,
10131009
!memcmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
10141010
sizeof(XATTR_NAME_POSIX_ACL_DEFAULT)))) {
10151011
err = ntfs_xattr_set_acl(
1016-
mnt_userns, inode,
1012+
inode,
10171013
name_len == sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1
10181014
? ACL_TYPE_ACCESS
10191015
: ACL_TYPE_DEFAULT,

0 commit comments

Comments
 (0)