mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chris@wirex.com>
To: torvalds@transmeta.com, akpm@digeo.com
Cc: linux-kernel@vger.kernel.org, linux-security-module@wirex.com,
	greg@kroah.com, sds@epoch.ncsc.mil
Subject: Re: [PATCH][LSM] setfsuid/setgsuid bug fix 4/4
Date: Fri, 13 Jun 2003 00:22:24 -0700	[thread overview]
Message-ID: <20030613002224.G31636@figure1.int.wirex.com> (raw)
In-Reply-To: <20030613001908.F31636@figure1.int.wirex.com>; from chris@wirex.com on Fri, Jun 13, 2003 at 12:19:08AM -0700

Patch from Jakub Jelínek <jakub@redhat.com>

[LSM] make sure setfsuid/setfsgid return values are right. Before
include/linux/security.h was added, setfsuid/setfsgid always returned
old_fsuid, no matter if the fsuid was actually changed or not.  With
the default security ops it seems to do the same, because both
security_task_setuid and security_task_post_setuid return 0, but
these are hooks which seem to return 0 on success, -errno on failure,
so if some non-default security hook is installed and ever returns
-errno in setfsuid/setfsgid, -errno will be returned from the syscall
instead of the expected old_fsuid. This makes it hard to distinguish
uids 0xfffff001 .. 0xffffffff from errors of security hooks.

--- linus-2.5/kernel/sys.c.setfsuid	Thu Jun 12 22:53:14 2003
+++ linus-2.5/kernel/sys.c	Thu Jun 12 22:53:14 2003
@@ -831,13 +831,11 @@
 asmlinkage long sys_setfsuid(uid_t uid)
 {
 	int old_fsuid;
-	int retval;
-
-	retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS);
-	if (retval)
-		return retval;
 
 	old_fsuid = current->fsuid;
+	if (security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS))
+		return old_fsuid;
+
 	if (uid == current->uid || uid == current->euid ||
 	    uid == current->suid || uid == current->fsuid || 
 	    capable(CAP_SETUID))
@@ -850,9 +848,7 @@
 		current->fsuid = uid;
 	}
 
-	retval = security_task_post_setuid(old_fsuid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS);
-	if (retval)
-		return retval;
+	security_task_post_setuid(old_fsuid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS);
 
 	return old_fsuid;
 }
@@ -863,13 +859,11 @@
 asmlinkage long sys_setfsgid(gid_t gid)
 {
 	int old_fsgid;
-	int retval;
-
-	retval = security_task_setgid(gid, (gid_t)-1, (gid_t)-1, LSM_SETID_FS);
-	if (retval)
-		return retval;
 
 	old_fsgid = current->fsgid;
+	if (security_task_setgid(gid, (gid_t)-1, (gid_t)-1, LSM_SETID_FS))
+		return old_fsgid;
+
 	if (gid == current->gid || gid == current->egid ||
 	    gid == current->sgid || gid == current->fsgid || 
 	    capable(CAP_SETGID))

  reply	other threads:[~2003-06-13  7:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-13  7:10 Chris Wright
2003-06-13  7:15 ` [PATCH][LSM] Remove task_kmod_set_label hook 2/4 Chris Wright
2003-06-13  7:19   ` [PATCH][LSM] Remove inode_permission_lite hook 3/4 Chris Wright
2003-06-13  7:22     ` Chris Wright [this message]
2003-06-13  7:30 ` [PATCH][LSM] Early init for security modules 1/4 Chris Wright

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=20030613002224.G31636@figure1.int.wirex.com \
    --to=chris@wirex.com \
    --cc=akpm@digeo.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@wirex.com \
    --cc=sds@epoch.ncsc.mil \
    --cc=torvalds@transmeta.com \
    /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

all inboxes | Powered by JetHome®