Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ernesto A. Fernandez and committed by
Linus Torvalds
b0cd38c7 fb04b91b

+8 -8
+2 -2
fs/hfsplus/dir.c
··· 444 444 int res = -ENOMEM; 445 445 446 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 448 if (!inode) 449 449 goto out; 450 450 ··· 486 486 int res = -ENOMEM; 487 487 488 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 490 if (!inode) 491 491 goto out; 492 492
+2 -1
fs/hfsplus/hfsplus_fs.h
··· 478 478 extern const struct address_space_operations hfsplus_btree_aops; 479 479 extern const struct dentry_operations hfsplus_dentry_operations; 480 480 481 - struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode); 481 + struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir, 482 + umode_t mode); 482 483 void hfsplus_delete_inode(struct inode *inode); 483 484 void hfsplus_inode_read_fork(struct inode *inode, 484 485 struct hfsplus_fork_raw *fork);
+3 -4
fs/hfsplus/inode.c
··· 354 354 .unlocked_ioctl = hfsplus_ioctl, 355 355 }; 356 356 357 - struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode) 357 + struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir, 358 + umode_t mode) 358 359 { 359 360 struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb); 360 361 struct inode *inode = new_inode(sb); ··· 365 364 return NULL; 366 365 367 366 inode->i_ino = sbi->next_cnid++; 368 - inode->i_mode = mode; 369 - inode->i_uid = current_fsuid(); 370 - inode->i_gid = current_fsgid(); 367 + inode_init_owner(inode, dir, mode); 371 368 set_nlink(inode, 1); 372 369 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode); 373 370
+1 -1
fs/hfsplus/super.c
··· 549 549 550 550 if (!sbi->hidden_dir) { 551 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 553 if (!sbi->hidden_dir) { 554 554 mutex_unlock(&sbi->vh_mutex); 555 555 err = -ENOMEM;