Re: [PATCH 2/2] kernel/sys.c: remove useless variable 'old_fsuid'for setfsuid()

From: Chen Gang
Date: Tue Aug 06 2013 - 04:56:57 EST


On 08/06/2013 04:16 PM, Chen Gang wrote:
> Remove useless variable 'old_fsuid' to make code clearer for readers.
>
> Signed-off-by: Chen Gang <gang.chen@xxxxxxxxxxx>
> ---
> kernel/sys.c | 14 ++++++--------
> 1 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/sys.c b/kernel/sys.c
> index 558ccdb..e3983b2 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -728,11 +728,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
> {
> const struct cred *old;
> struct cred *new;
> - uid_t old_fsuid;
> kuid_t kuid;
>
> old = current_cred();
> - old_fsuid = from_kuid_munged(old->user_ns, old->fsuid);
>

Oh... should old_fsuid be get before commit_creds() or prepare_creds() ?

> kuid = make_kuid(old->user_ns, uid);
> if (!uid_valid(kuid))
> @@ -747,17 +745,17 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
> nsown_capable(CAP_SETUID)) {
> if (!uid_eq(kuid, old->fsuid)) {
> new->fsuid = kuid;
> - if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
> - goto change_okay;
> + if (security_task_fix_setuid(new,
> + old, LSM_SETID_FS) == 0) {
> + commit_creds(new);
> + return from_kuid_munged(old->user_ns,
> + old->fsuid);
> + }

Oh... should old_fsuid be get before commit_creds() or prepare_creds() ?

> }
> }
>
> abort_creds(new);
> return uid;
> -
> -change_okay:
> - commit_creds(new);
> - return old_fsuid;
> }
>
> /*
>


--
Chen Gang
--
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/