public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John Fremlin <vii@users.sourceforge.net>
To: <linux-kernel@vger.kernel.org>
Cc: <torvalds@transmeta.com>
Subject: [PATCH] setuid(2) buggy or bad docs
Date: 20 Jun 2001 01:37:51 +0100	[thread overview]
Message-ID: <m23d8w2dgg.fsf@boreas.yi.org.> (raw)

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

setuid(2) differs from the OpenBSD setuid(2) in that -EPERM is
returned by the syscall even if the euid of the process matches the
uid passed to it.

Either I am non compos or the thing is very wrong. The docs
(man-pages-1.35) say

ERRORS
       EPERM  The  user  is  not the super-user, and uid does not
              match the effective or saved user ID of the calling
              process.

The following untested patch changes the kernel to match the
documentated behaviour.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: linux-2.4.4-setuid.patch --]
[-- Type: text/x-patch, Size: 459 bytes --]

--- linux-2.4.4-orig/kernel/sys.c	Tue May  1 14:34:43 2001
+++ linux-2.4.4/kernel/sys.c	Wed Jun 20 01:32:46 2001
@@ -603,7 +603,9 @@ asmlinkage long sys_setuid(uid_t uid)
 		if (uid != old_ruid && set_user(uid, old_euid != uid) < 0)
 			return -EAGAIN;
 		new_suid = uid;
-	} else if ((uid != current->uid) && (uid != new_suid))
+	} else if ((uid != current->uid)
+		   && (uid != new_suid)
+		&& (uid != old_euid))
 		return -EPERM;
 
 	if (old_euid != uid)

[-- Attachment #3: Type: text/plain, Size: 101 bytes --]

-- 
Summer job urgently sought due to last minute visa trouble!
Please see http://ape.n3.net/cv.html

             reply	other threads:[~2001-06-20  0:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-20  0:37 John Fremlin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-06-20  9:17 [PATCH] setuid(2) buggy or bad docs Andries.Brouwer

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=m23d8w2dgg.fsf@boreas.yi.org. \
    --to=vii@users.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --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