hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/open.c
....@@ -666,10 +666,10 @@
666666 newattrs.ia_valid |= ATTR_GID;
667667 newattrs.ia_gid = gid;
668668 }
669
- if (!S_ISDIR(inode->i_mode))
670
- newattrs.ia_valid |=
671
- ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV;
672669 inode_lock(inode);
670
+ if (!S_ISDIR(inode->i_mode))
671
+ newattrs.ia_valid |= ATTR_KILL_SUID | ATTR_KILL_PRIV |
672
+ setattr_should_drop_sgid(inode);
673673 error = security_path_chown(path, uid, gid);
674674 if (!error)
675675 error = notify_change(path->dentry, &newattrs, &delegated_inode);
....@@ -1112,7 +1112,7 @@
11121112 lookup_flags |= LOOKUP_IN_ROOT;
11131113 if (how->resolve & RESOLVE_CACHED) {
11141114 /* Don't bother even trying for create/truncate/tmpfile open */
1115
- if (flags & (O_TRUNC | O_CREAT | O_TMPFILE))
1115
+ if (flags & (O_TRUNC | O_CREAT | __O_TMPFILE))
11161116 return -EAGAIN;
11171117 lookup_flags |= LOOKUP_CACHED;
11181118 }