audit: skip sessionid sentinel value when auto-incrementing
authorRichard Guy Briggs <rgb@redhat.com>
Thu, 10 Nov 2016 06:41:14 +0000 (01:41 -0500)
committerPaul Moore <paul@paul-moore.com>
Sun, 20 Nov 2016 20:28:22 +0000 (15:28 -0500)
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@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
kernel/auditsc.c

index 8c434318ec8d69a711de8ca747597d4accde9789..d161b17ce8cef04029c211b2f29f8e188643f8a4 100644 (file)
@@ -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;