From 831814b4132bd31dd693298bc9498d9b793fb712 Mon Sep 17 00:00:00 2001
From: Ksawlii <ksawery.blaszczak@proton.me>
Date: Sun, 24 Nov 2024 00:23:15 +0100
Subject: [PATCH] Revert "fs: Fix file_set_fowner LSM hook inconsistencies"

This reverts commit 33a22518e48427af56ccf4a7642908d3c5d75223.
---
 fs/fcntl.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/fs/fcntl.c b/fs/fcntl.c
index 58b285a6e..38f334a5f 100755
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -100,8 +100,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
 	return error;
 }
 
-void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
-		int force)
+static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
+                     int force)
 {
 	write_lock_irq(&filp->f_owner.lock);
 	if (force || !filp->f_owner.pid) {
@@ -111,13 +111,19 @@ void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
 
 		if (pid) {
 			const struct cred *cred = current_cred();
-			security_file_set_fowner(filp);
 			filp->f_owner.uid = cred->uid;
 			filp->f_owner.euid = cred->euid;
 		}
 	}
 	write_unlock_irq(&filp->f_owner.lock);
 }
+
+void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
+		int force)
+{
+	security_file_set_fowner(filp);
+	f_modown(filp, pid, type, force);
+}
 EXPORT_SYMBOL(__f_setown);
 
 int f_setown(struct file *filp, unsigned long arg, int force)
@@ -153,7 +159,7 @@ EXPORT_SYMBOL(f_setown);
 
 void f_delown(struct file *filp)
 {
-	__f_setown(filp, NULL, PIDTYPE_TGID, 1);
+	f_modown(filp, NULL, PIDTYPE_TGID, 1);
 }
 
 pid_t f_getown(struct file *filp)