From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Chen Gang <gang.chen@asianux.com>
Cc: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>,
Oleg Nesterov <oleg@redhat.com>,
Andy Lutomirski <luto@amacapital.net>,
Kees Cook <keescook@chromium.org>,
Al Viro <viro@zeniv.linux.org.uk>,
holt@sgi.com, Andrew Morton <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] kernel/sys.c: return the current gid when error occurs
Date: Fri, 09 Aug 2013 09:27:35 +0200 [thread overview]
Message-ID: <520499E7.1000203@gmail.com> (raw)
In-Reply-To: <52043EF4.6070809@asianux.com>
On 08/09/13 02:59, Chen Gang wrote:
> On 08/08/2013 09:37 PM, Michael Kerrisk (man-pages) wrote:
>> On 08/07/13 18:21, Oleg Nesterov wrote:
>>> On 08/06, Andy Lutomirski wrote:
>>>>
>>>> I assume that what the man page means is that the return value is
>>>> whatever fsgid was prior to the call. On error, fsgid isn't changed, so
>>>> the return value is still "current".
>>>
>>> Probably... Still
>>>
>>> On success, the previous value of fsuid is returned.
>>> On error, the current value of fsuid is returned.
>>>
>>> looks confusing. sys_setfsuid() always returns the old value.
>>>
>>>> (FWIW, this behavior is awful and is probably the cause of a security
>>>> bug or three, since success and failure are indistinguishable.
>>>
>>> At least this all looks strange.
>>>
>>> I dunno if we can change this old behaviour. I won't be surprized
>>> if someone already uses setfsuid(-1) as getfsuid().
>>>
>>> And perhaps the man page should be changed. Add Michael.
>>
>> Thanks, Oleg. I've applied the following patch to setfsuid.2
>> (and a similar patch to setfsgid.2).
>>
>> Cheers,
>>
>> Michael
>>
>> --- a/man2/setfsuid.2
>> +++ b/man2/setfsuid.2
>> @@ -67,12 +67,8 @@ matches either the real user ID, effective user ID, saved set-user-ID, or
>> the current value of
>> .IR fsuid .
>> .SH RETURN VALUE
>> -On success, the previous value of
>> -.I fsuid
>> -is returned.
>> -On error, the current value of
>> -.I fsuid
>> -is returned.
>> +On both success and failure,
>> +this call returns the previous filesystem user ID of the caller.
>> .SH VERSIONS
>> This system call is present in Linux since version 1.2.
>> .\" This system call is present since Linux 1.1.44
>> @@ -102,7 +98,16 @@ The glibc
>> .BR setfsuid ()
>> wrapper function transparently deals with the variation across kernel versions.
>> .SH BUGS
>> -No error messages of any kind are returned to the caller.
>> +No error indications of any kind are returned to the caller,
>> +and the fact that both successful and unsuccessful calls return
>> +the same value makes it impossible to directly determine
>> +whether the call succeeded or failed.
>> +Instead, the caller must resort to looking at the return value
>> +from a further call such as
>> +.IR setfsuid(\-1)
>> +(which will always fail), in order to determine if a preceding call to
>> +.BR setfsuid ()
>> +changed the filesystem user ID.
>> At the very
>> least,
>> .B EPERM
>>
>
> Is it suitable to mention this API is obsoleted and unneeded in man page
> ? ;-)
Yes, that seems reasonable. Done.
Cheers,
Michael
next prev parent reply other threads:[~2013-08-09 7:38 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-06 8:00 [PATCH 0/2] kernel/sys.c: for setfsgid(), return the current gid when error occurs Chen Gang
2013-08-06 8:01 ` [PATCH 1/2] kernel/sys.c: " Chen Gang
2013-08-06 20:21 ` Andy Lutomirski
2013-08-07 3:30 ` Chen Gang
2013-08-07 16:21 ` Oleg Nesterov
2013-08-07 16:58 ` Andy Lutomirski
2013-08-08 1:30 ` Chen Gang
2013-08-08 1:35 ` Andy Lutomirski
2013-08-08 1:48 ` Chen Gang
2013-08-08 13:52 ` Michael Kerrisk (man-pages)
2013-08-09 0:55 ` Chen Gang
2013-08-08 13:37 ` Michael Kerrisk (man-pages)
2013-08-09 0:59 ` Chen Gang
2013-08-09 7:27 ` Michael Kerrisk (man-pages) [this message]
2013-08-06 8:02 ` [PATCH 2/2] kernel/sys.c: remove useless variable 'old_fsgid' for setfsgid() Chen Gang
2013-08-06 8:56 ` Chen Gang
2013-08-06 8:13 ` kernel/sys.c: for setfsuid(), return the current uid when error occurs Chen Gang
2013-08-06 8:14 ` Chen Gang
2013-08-06 8:15 ` [PATCH 0/2] " Chen Gang
2013-08-06 8:15 ` [PATCH 1/2] kernel/sys.c: " Chen Gang
2013-08-06 8:16 ` [PATCH 2/2] kernel/sys.c: remove useless variable 'old_fsuid' for setfsuid() Chen Gang
2013-08-06 8:55 ` Chen Gang
2013-08-06 8:43 ` [PATCH] kernel/sys.c: improve the usage of return value Chen Gang
2013-08-07 10:44 ` Chen Gang
2013-08-06 18:36 ` [PATCH 0/2] kernel/sys.c: for setfsgid(), return the current gid when error occurs Kees Cook
2013-08-07 2:25 ` Chen Gang
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=520499E7.1000203@gmail.com \
--to=mtk.manpages@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=gang.chen@asianux.com \
--cc=holt@sgi.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=oleg@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/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