aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErnesto A. Fernandez <ernesto.mnd.fernandez@gmail.com>2018-02-06 18:49:02 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-02-06 21:32:45 -0500
commitb0cd38c7f54c9176f78cce2e2b23e1513bf5a224 (patch)
tree590524511319243c72325593651f2b1ef8823e32
parentfb04b91bc2c3a83e9e2ba9c5ce0f0124dd3ffef0 (diff)
hfsplus: honor setgid flag on directories
When creating a file inside a directory that has the setgid flag set, give the new file the group ID of the parent, and also the setgid flag if it is a directory itself. Link: http://lkml.kernel.org/r/20171204192705.GA6101@debian.home Signed-off-by: Ernesto A. Fernandez <ernesto.mnd.fernandez@gmail.com> Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/hfsplus/dir.c4
-rw-r--r--fs/hfsplus/hfsplus_fs.h3
-rw-r--r--fs/hfsplus/inode.c7
-rw-r--r--fs/hfsplus/super.c2
4 files changed, 8 insertions, 8 deletions
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index e8120a282435..15e06fb552da 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -444,7 +444,7 @@ static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,
444 int res = -ENOMEM; 444 int res = -ENOMEM;
445 445
446 mutex_lock(&sbi->vh_mutex); 446 mutex_lock(&sbi->vh_mutex);
447 inode = hfsplus_new_inode(dir->i_sb, S_IFLNK | S_IRWXUGO); 447 inode = hfsplus_new_inode(dir->i_sb, dir, S_IFLNK | S_IRWXUGO);
448 if (!inode) 448 if (!inode)
449 goto out; 449 goto out;
450 450
@@ -486,7 +486,7 @@ static int hfsplus_mknod(struct inode *dir, struct dentry *dentry,
486 int res = -ENOMEM; 486 int res = -ENOMEM;
487 487
488 mutex_lock(&sbi->vh_mutex); 488 mutex_lock(&sbi->vh_mutex);
489 inode = hfsplus_new_inode(dir->i_sb, mode); 489 inode = hfsplus_new_inode(dir->i_sb, dir, mode);
490 if (!inode) 490 if (!inode)
491 goto out; 491 goto out;
492 492
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index a015044daa05..d9255abafb81 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -478,7 +478,8 @@ extern const struct address_space_operations hfsplus_aops;
478extern const struct address_space_operations hfsplus_btree_aops; 478extern const struct address_space_operations hfsplus_btree_aops;
479extern const struct dentry_operations hfsplus_dentry_operations; 479extern const struct dentry_operations hfsplus_dentry_operations;
480 480
481struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode); 481struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
482 umode_t mode);
482void hfsplus_delete_inode(struct inode *inode); 483void hfsplus_delete_inode(struct inode *inode);
483void hfsplus_inode_read_fork(struct inode *inode, 484void hfsplus_inode_read_fork(struct inode *inode,
484 struct hfsplus_fork_raw *fork); 485 struct hfsplus_fork_raw *fork);
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 190c60efbc99..c0c8d433864f 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -354,7 +354,8 @@ static const struct file_operations hfsplus_file_operations = {
354 .unlocked_ioctl = hfsplus_ioctl, 354 .unlocked_ioctl = hfsplus_ioctl,
355}; 355};
356 356
357struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode) 357struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
358 umode_t mode)
358{ 359{
359 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); 360 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
360 struct inode *inode = new_inode(sb); 361 struct inode *inode = new_inode(sb);
@@ -364,9 +365,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode)
364 return NULL; 365 return NULL;
365 366
366 inode->i_ino = sbi->next_cnid++; 367 inode->i_ino = sbi->next_cnid++;
367 inode->i_mode = mode; 368 inode_init_owner(inode, dir, mode);
368 inode->i_uid = current_fsuid();
369 inode->i_gid = current_fsgid();
370 set_nlink(inode, 1); 369 set_nlink(inode, 1);
371 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); 370 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
372 371
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 1d458b716957..513c357c734b 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -549,7 +549,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
549 549
550 if (!sbi->hidden_dir) { 550 if (!sbi->hidden_dir) {
551 mutex_lock(&sbi->vh_mutex); 551 mutex_lock(&sbi->vh_mutex);
552 sbi->hidden_dir = hfsplus_new_inode(sb, S_IFDIR); 552 sbi->hidden_dir = hfsplus_new_inode(sb, root, S_IFDIR);
553 if (!sbi->hidden_dir) { 553 if (!sbi->hidden_dir) {
554 mutex_unlock(&sbi->vh_mutex); 554 mutex_unlock(&sbi->vh_mutex);
555 err = -ENOMEM; 555 err = -ENOMEM;