linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ovl: Do not override fsuid and fsgid in ovl_link()
@ 2022-08-17  3:45 Zhang Tianci
  2022-08-17  7:36 ` Amir Goldstein
  0 siblings, 1 reply; 12+ messages in thread
From: Zhang Tianci @ 2022-08-17  3:45 UTC (permalink / raw)
  To: miklos; +Cc: Zhang Tianci, linux-unionfs, linux-kernel, Jiachen Zhang

ovl_link() did not create a new inode after commit
51f7e52dc943 ("ovl: share inode for hard link"), so
in ovl_create_or_link() we should not override cred's
fsuid and fsgid when called by ovl_link().

Signed-off-by: Zhang Tianci <zhangtianci.1997@bytedance.com>
Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
---
 fs/overlayfs/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 6b03457f72bb..568d338032db 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -595,9 +595,9 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
 	err = -ENOMEM;
 	override_cred = prepare_creds();
 	if (override_cred) {
-		override_cred->fsuid = inode->i_uid;
-		override_cred->fsgid = inode->i_gid;
 		if (!attr->hardlink) {
+			override_cred->fsuid = inode->i_uid;
+			override_cred->fsgid = inode->i_gid;
 			err = security_dentry_create_files_as(dentry,
 					attr->mode, &dentry->d_name, old_cred,
 					override_cred);
-- 
2.32.1 (Apple Git-133)


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-08-25  8:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-17  3:45 [PATCH] ovl: Do not override fsuid and fsgid in ovl_link() Zhang Tianci
2022-08-17  7:36 ` Amir Goldstein
2022-08-17  9:11   ` [External] " 天赐张
2022-08-17  9:53     ` Amir Goldstein
2022-08-17  9:55       ` Amir Goldstein
2022-08-17 10:27         ` Christian Brauner
2022-08-17 10:29           ` Christian Brauner
2022-08-17 11:36             ` 天赐张
2022-08-17 11:56               ` Christian Brauner
2022-08-17 12:29                 ` Christian Brauner
2022-08-17 12:37                   ` Christian Brauner
2022-08-25  8:46                     ` 天赐张

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).