[PATCH 1/2] kernel/sys.c: return the current uid when error occurs

From: Chen Gang
Date: Tue Aug 06 2013 - 04:17:07 EST


According to the API definition, when error occurs, need return current
fsuid instead of the previous one.

The related informations ("man setfsuid"):

RETURN VALUE
On success, the previous value of fsuid is returned. On error, the current value of fsuid is returned.


Signed-off-by: Chen Gang <gang.chen@xxxxxxxxxxx>
---
kernel/sys.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index 771129b..558ccdb 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -736,11 +736,11 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)

kuid = make_kuid(old->user_ns, uid);
if (!uid_valid(kuid))
- return old_fsuid;
+ return uid;

new = prepare_creds();
if (!new)
- return old_fsuid;
+ return uid;

if (uid_eq(kuid, old->uid) || uid_eq(kuid, old->euid) ||
uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
@@ -753,7 +753,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
}

abort_creds(new);
- return old_fsuid;
+ return uid;

change_okay:
commit_creds(new);
--
1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/