Skip to content

Commit

Permalink
audit: skip sessionid sentinel value when auto-incrementing
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
rgbriggs authored and pcmoore committed Nov 20, 2016
1 parent 8443075 commit 833fc48
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion kernel/auditsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 833fc48

Please sign in to comment.