Re: [PATCH] audit: skip sessionid sentinel value when auto-incrementing

From: Paul Moore
Date: Mon Nov 14 2016 - 15:17:47 EST


On Thu, Nov 10, 2016 at 1:41 AM, Richard Guy Briggs <rgb@xxxxxxxxxx> wrote:
> The value (unsigned int)-1 is used as a sentinel to indicate the
> sessionID is unset. Skip this value when the session_id value wraps.
>
> Signed-off-by: Richard Guy Briggs <rgb@xxxxxxxxxx>
> ---
> kernel/auditsc.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)

Since we haven't merged the session ID kernel patches into audit#next
yet, why don't you just squash this patch in with the session ID patch
and resubmit upstream in one nice neat patch.

> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 5abf1dc..e414dfa 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -2025,8 +2025,11 @@ int audit_set_loginuid(kuid_t loginuid)
> goto out;
>
> /* are we setting or clearing? */
> - if (uid_valid(loginuid))
> + if (uid_valid(loginuid)) {
> sessionid = (unsigned int)atomic_inc_return(&session_id);
> + if (unlikely(sessionid == (unsigned int)-1))
> + sessionid = (unsigned int)atomic_inc_return(&session_id);
> + }
>
> task->sessionid = sessionid;
> task->loginuid = loginuid;
> --
> 1.7.1
>
> --
> Linux-audit mailing list
> Linux-audit@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/linux-audit



--
paul moore
www.paul-moore.com