Re: [PATCH 4.4 24/72] audit: add tty field to LOGIN event
From: Ben Hutchings
Date: Mon May 14 2018 - 12:19:06 EST
On Fri, 2018-04-06 at 15:23 +0200, Greg Kroah-Hartman wrote:
> 4.4-stable review patch.ÂÂIf anyone has any objections, please let me know.
>
> ------------------
>
> From: Richard Guy Briggs <rgb@xxxxxxxxxx>
>
> commit db0a6fb5d97afe01fd9c47d37c6daa82d4d4001d upstream.
[...]
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -1976,6 +1976,7 @@ static void audit_log_set_loginuid(kuid_
> Â{
> Â struct audit_buffer *ab;
> Â uid_t uid, oldloginuid, loginuid;
> + struct tty_struct *tty;
> Â
> Â if (!audit_enabled)
> Â return;
> @@ -1983,14 +1984,17 @@ static void audit_log_set_loginuid(kuid_
> Â uid = from_kuid(&init_user_ns, task_uid(current));
> Â oldloginuid = from_kuid(&init_user_ns, koldloginuid);
> Â loginuid = from_kuid(&init_user_ns, kloginuid),
> + tty = audit_get_tty(current);
> Â
> Â ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN);
> Â if (!ab)
> Â return;
This error path leaks the tty ref. Fixed upstream by:
commit 76a658c20efd541a62838d9ff68ce94170d7a549
Author: Richard Guy Briggs <rgb@xxxxxxxxxx>
Date: Tue Jun 28 12:06:58 2016 -0400
audit: move calcs after alloc and check when logging set loginuid
Ben.
> Â audit_log_format(ab, "pid=%d uid=%u", task_pid_nr(current), uid);
> Â audit_log_task_context(ab);
> - audit_log_format(ab, " old-auid=%u auid=%u old-ses=%u ses=%u res=%d",
> - Âoldloginuid, loginuid, oldsessionid, sessionid, !rc);
> + audit_log_format(ab, " old-auid=%u auid=%u tty=%s old-ses=%u ses=%u res=%d",
> + Âoldloginuid, loginuid, tty ? tty_name(tty) : "(none)",
> + Âoldsessionid, sessionid, !rc);
> + audit_put_tty(tty);
> Â audit_log_end(ab);
> Â}
> Â
--
Ben Hutchings
Software Developer, Codethink Ltd.