public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Howells <dhowells@redhat.com>,
	Eugene Teo <eugene@redhat.com>, James Morris <jmorris@namei.org>,
	Roland McGrath <roland@redhat.com>,
	solar@openwall.com, linux-kernel@vger.kernel.org
Subject: [PATCH] shift current_cred() from __f_setown() to f_modown()
Date: Tue, 16 Jun 2009 22:07:46 +0200	[thread overview]
Message-ID: <20090616200746.GA28663@redhat.com> (raw)
In-Reply-To: <alpine.LFD.2.01.0906161224110.3282@localhost.localdomain>

Shift current_cred() from __f_setown() to f_modown(). This reduces
the number of arguments and saves 48 bytes from fs/fcntl.o.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>

--- a/fs/fcntl.c~f_modown	2009-04-06 00:03:41.000000000 +0200
+++ b/fs/fcntl.c	2009-06-16 21:41:18.000000000 +0200
@@ -196,15 +196,19 @@ static int setfl(int fd, struct file * f
 }
 
 static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
-                     uid_t uid, uid_t euid, int force)
+                     int force)
 {
 	write_lock_irq(&filp->f_owner.lock);
 	if (force || !filp->f_owner.pid) {
 		put_pid(filp->f_owner.pid);
 		filp->f_owner.pid = get_pid(pid);
 		filp->f_owner.pid_type = type;
-		filp->f_owner.uid = uid;
-		filp->f_owner.euid = euid;
+
+		if (pid) {
+			const struct cred *cred = current_cred();
+			filp->f_owner.uid = cred->uid;
+			filp->f_owner.euid = cred->euid;
+		}
 	}
 	write_unlock_irq(&filp->f_owner.lock);
 }
@@ -212,14 +216,13 @@ static void f_modown(struct file *filp, 
 int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
 		int force)
 {
-	const struct cred *cred = current_cred();
 	int err;
-	
+
 	err = security_file_set_fowner(filp);
 	if (err)
 		return err;
 
-	f_modown(filp, pid, type, cred->uid, cred->euid, force);
+	f_modown(filp, pid, type, force);
 	return 0;
 }
 EXPORT_SYMBOL(__f_setown);
@@ -245,7 +248,7 @@ EXPORT_SYMBOL(f_setown);
 
 void f_delown(struct file *filp)
 {
-	f_modown(filp, NULL, PIDTYPE_PID, 0, 0, 1);
+	f_modown(filp, NULL, PIDTYPE_PID, 1);
 }
 
 pid_t f_getown(struct file *filp)


       reply	other threads:[~2009-06-16 20:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4A36532E.3050006@redhat.com>
     [not found] ` <20090615174544.GA10467@redhat.com>
     [not found]   ` <4A36E555.80206@redhat.com>
     [not found]     ` <20090616183829.GA10027@redhat.com>
     [not found]       ` <alpine.LFD.2.01.0906161224110.3282@localhost.localdomain>
2009-06-16 20:07         ` Oleg Nesterov [this message]
2009-06-16 20:17           ` [PATCH] shift current_cred() from __f_setown() to f_modown() David Howells
2009-06-16 20:21           ` Linus Torvalds
2009-06-16 21:00             ` Oleg Nesterov
2009-06-16 22:56           ` James Morris
     [not found]         ` <20090616204941.GB28663@redhat.com>
     [not found]           ` <alpine.LFD.2.01.0906161433270.16802@localhost.localdomain>
     [not found]             ` <20090616215103.GA4853@redhat.com>
2009-06-16 22:27               ` [PATCH] send_sigio_to_task: sanitize the usage of fown->signum Oleg Nesterov
2009-06-16 23:00                 ` James Morris
2009-06-16 23:10                 ` David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090616200746.GA28663@redhat.com \
    --to=oleg@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=eugene@redhat.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    --cc=solar@openwall.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox