audit: convert sessionid unset to a macro
Use a macro, "AUDIT_SID_UNSET", to replace each instance of initialization and comparison to an audit session ID. Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
326bee0286
commit
f0b752168d
5 changed files with 7 additions and 5 deletions
|
@ -510,7 +510,7 @@ static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
|
||||||
}
|
}
|
||||||
static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
|
static inline unsigned int audit_get_sessionid(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
return -1;
|
return AUDIT_SID_UNSET;
|
||||||
}
|
}
|
||||||
static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
|
static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp)
|
||||||
{ }
|
{ }
|
||||||
|
|
|
@ -751,7 +751,7 @@ static inline void xfrm_audit_helper_usrinfo(bool task_valid,
|
||||||
audit_get_loginuid(current) :
|
audit_get_loginuid(current) :
|
||||||
INVALID_UID);
|
INVALID_UID);
|
||||||
const unsigned int ses = task_valid ? audit_get_sessionid(current) :
|
const unsigned int ses = task_valid ? audit_get_sessionid(current) :
|
||||||
(unsigned int) -1;
|
AUDIT_SID_UNSET;
|
||||||
|
|
||||||
audit_log_format(audit_buf, " auid=%u ses=%u", auid, ses);
|
audit_log_format(audit_buf, " auid=%u ses=%u", auid, ses);
|
||||||
audit_log_task_context(audit_buf);
|
audit_log_task_context(audit_buf);
|
||||||
|
|
|
@ -465,6 +465,7 @@ struct audit_tty_status {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define AUDIT_UID_UNSET (unsigned int)-1
|
#define AUDIT_UID_UNSET (unsigned int)-1
|
||||||
|
#define AUDIT_SID_UNSET ((unsigned int)-1)
|
||||||
|
|
||||||
/* audit_rule_data supports filter rules with both integer and string
|
/* audit_rule_data supports filter rules with both integer and string
|
||||||
* fields. It corresponds with AUDIT_ADD_RULE, AUDIT_DEL_RULE and
|
* fields. It corresponds with AUDIT_ADD_RULE, AUDIT_DEL_RULE and
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
|
#include <linux/audit.h>
|
||||||
|
|
||||||
#include <asm/pgtable.h>
|
#include <asm/pgtable.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
@ -119,7 +120,7 @@ struct task_struct init_task
|
||||||
.thread_node = LIST_HEAD_INIT(init_signals.thread_head),
|
.thread_node = LIST_HEAD_INIT(init_signals.thread_head),
|
||||||
#ifdef CONFIG_AUDITSYSCALL
|
#ifdef CONFIG_AUDITSYSCALL
|
||||||
.loginuid = INVALID_UID,
|
.loginuid = INVALID_UID,
|
||||||
.sessionid = (unsigned int)-1,
|
.sessionid = AUDIT_SID_UNSET,
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_PERF_EVENTS
|
#ifdef CONFIG_PERF_EVENTS
|
||||||
.perf_event_mutex = __MUTEX_INITIALIZER(init_task.perf_event_mutex),
|
.perf_event_mutex = __MUTEX_INITIALIZER(init_task.perf_event_mutex),
|
||||||
|
|
|
@ -2050,7 +2050,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
|
||||||
int audit_set_loginuid(kuid_t loginuid)
|
int audit_set_loginuid(kuid_t loginuid)
|
||||||
{
|
{
|
||||||
struct task_struct *task = current;
|
struct task_struct *task = current;
|
||||||
unsigned int oldsessionid, sessionid = (unsigned int)-1;
|
unsigned int oldsessionid, sessionid = AUDIT_SID_UNSET;
|
||||||
kuid_t oldloginuid;
|
kuid_t oldloginuid;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
@ -2064,7 +2064,7 @@ int audit_set_loginuid(kuid_t loginuid)
|
||||||
/* are we setting or clearing? */
|
/* are we setting or clearing? */
|
||||||
if (uid_valid(loginuid)) {
|
if (uid_valid(loginuid)) {
|
||||||
sessionid = (unsigned int)atomic_inc_return(&session_id);
|
sessionid = (unsigned int)atomic_inc_return(&session_id);
|
||||||
if (unlikely(sessionid == (unsigned int)-1))
|
if (unlikely(sessionid == AUDIT_SID_UNSET))
|
||||||
sessionid = (unsigned int)atomic_inc_return(&session_id);
|
sessionid = (unsigned int)atomic_inc_return(&session_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue