BACKPORT: audit: use inline function to get audit context
Recognizing that the audit context is an internal audit value, use an access function to retrieve the audit context pointer for the task rather than reaching directly into the task struct to get it. Signed-off-by: Richard Guy Briggs <rgb@redhat.com> [PM: merge fuzz in auditsc.c and selinuxfs.c, checkpatch.pl fixes] Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Sorayukii <sorayukii69@gmail.com>
This commit is contained in:
parent
bc16fa4507
commit
63eb8ee669
6 changed files with 73 additions and 63 deletions
|
|
@ -318,7 +318,7 @@ void ima_audit_measurement(struct integrity_iint_cache *iint,
|
|||
hex_byte_pack(hash + (i * 2), iint->ima_hash->digest[i]);
|
||||
hash[i * 2] = '\0';
|
||||
|
||||
ab = audit_log_start(current->audit_context, GFP_KERNEL,
|
||||
ab = audit_log_start(audit_context(), GFP_KERNEL,
|
||||
AUDIT_INTEGRITY_RULE);
|
||||
if (!ab)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode,
|
|||
if (!integrity_audit_info && audit_info == 1) /* Skip info messages */
|
||||
return;
|
||||
|
||||
ab = audit_log_start(current->audit_context, GFP_KERNEL, audit_msgno);
|
||||
ab = audit_log_start(audit_context(), GFP_KERNEL, audit_msgno);
|
||||
if (!ab)
|
||||
return;
|
||||
audit_log_format(ab, "pid=%d uid=%u auid=%u ses=%u",
|
||||
|
|
|
|||
|
|
@ -436,7 +436,7 @@ void common_lsm_audit(struct common_audit_data *a,
|
|||
if (a == NULL)
|
||||
return;
|
||||
/* we use GFP_ATOMIC so we won't sleep */
|
||||
ab = audit_log_start(current->audit_context, GFP_ATOMIC | __GFP_NOWARN,
|
||||
ab = audit_log_start(audit_context(), GFP_ATOMIC | __GFP_NOWARN,
|
||||
AUDIT_AVC);
|
||||
|
||||
if (ab == NULL)
|
||||
|
|
|
|||
|
|
@ -3193,7 +3193,8 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
|
|||
str = "";
|
||||
audit_size = 0;
|
||||
}
|
||||
ab = audit_log_start(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR);
|
||||
ab = audit_log_start(audit_context(),
|
||||
GFP_ATOMIC, AUDIT_SELINUX_ERR);
|
||||
audit_log_format(ab, "op=setxattr invalid_context=");
|
||||
audit_log_n_untrustedstring(ab, value, audit_size);
|
||||
audit_log_end(ab);
|
||||
|
|
@ -5992,7 +5993,9 @@ static int selinux_setprocattr(struct task_struct *p,
|
|||
audit_size = size - 1;
|
||||
else
|
||||
audit_size = size;
|
||||
ab = audit_log_start(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR);
|
||||
ab = audit_log_start(audit_context(),
|
||||
GFP_ATOMIC,
|
||||
AUDIT_SELINUX_ERR);
|
||||
audit_log_format(ab, "op=fscreate invalid_context=");
|
||||
audit_log_n_untrustedstring(ab, value, audit_size);
|
||||
audit_log_end(ab);
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ static ssize_t sel_write_enforce(struct file *file, const char __user *buf,
|
|||
length = task_has_security(current, SECURITY__SETENFORCE);
|
||||
if (length)
|
||||
goto out;
|
||||
audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS,
|
||||
audit_log(audit_context(), GFP_KERNEL, AUDIT_MAC_STATUS,
|
||||
"enforcing=%d old_enforcing=%d auid=%u ses=%u",
|
||||
new_value, selinux_enforcing,
|
||||
from_kuid(&init_user_ns, audit_get_loginuid(current)),
|
||||
|
|
@ -292,7 +292,7 @@ static ssize_t sel_write_disable(struct file *file, const char __user *buf,
|
|||
length = selinux_disable();
|
||||
if (length)
|
||||
goto out;
|
||||
audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_STATUS,
|
||||
audit_log(audit_context(), GFP_KERNEL, AUDIT_MAC_STATUS,
|
||||
"selinux=0 auid=%u ses=%u",
|
||||
from_kuid(&init_user_ns, audit_get_loginuid(current)),
|
||||
audit_get_sessionid(current));
|
||||
|
|
@ -538,7 +538,7 @@ static ssize_t sel_write_load(struct file *file, const char __user *buf,
|
|||
length = count;
|
||||
|
||||
out1:
|
||||
audit_log(current->audit_context, GFP_KERNEL, AUDIT_MAC_POLICY_LOAD,
|
||||
audit_log(audit_context(), GFP_KERNEL, AUDIT_MAC_POLICY_LOAD,
|
||||
"policy loaded auid=%u ses=%u",
|
||||
from_kuid(&init_user_ns, audit_get_loginuid(current)),
|
||||
audit_get_sessionid(current));
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ static void security_dump_masked_av(struct context *scontext,
|
|||
goto out;
|
||||
|
||||
/* audit a message */
|
||||
ab = audit_log_start(current->audit_context,
|
||||
ab = audit_log_start(audit_context(),
|
||||
GFP_ATOMIC, AUDIT_SELINUX_ERR);
|
||||
if (!ab)
|
||||
goto out;
|
||||
|
|
@ -740,7 +740,7 @@ static int security_validtrans_handle_fail(struct context *ocontext,
|
|||
goto out;
|
||||
if (context_struct_to_string(tcontext, &t, &tlen))
|
||||
goto out;
|
||||
audit_log(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR,
|
||||
audit_log(audit_context(), GFP_ATOMIC, AUDIT_SELINUX_ERR,
|
||||
"op=security_validate_transition seresult=denied"
|
||||
" oldcontext=%s newcontext=%s taskcontext=%s tclass=%s",
|
||||
o, n, t, sym_name(&policydb, SYM_CLASSES, tclass-1));
|
||||
|
|
@ -910,7 +910,7 @@ int security_bounded_transition(u32 old_sid, u32 new_sid)
|
|||
&old_name, &length) &&
|
||||
!context_struct_to_string(new_context,
|
||||
&new_name, &length)) {
|
||||
audit_log(current->audit_context,
|
||||
audit_log(audit_context(),
|
||||
GFP_ATOMIC, AUDIT_SELINUX_ERR,
|
||||
"op=security_bounded_transition "
|
||||
"seresult=denied "
|
||||
|
|
@ -1522,7 +1522,7 @@ static int compute_sid_handle_invalid_context(
|
|||
goto out;
|
||||
if (context_struct_to_string(newcontext, &n, &nlen))
|
||||
goto out;
|
||||
audit_log(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR,
|
||||
audit_log(audit_context(), GFP_ATOMIC, AUDIT_SELINUX_ERR,
|
||||
"op=security_compute_sid invalid_context=%s"
|
||||
" scontext=%s"
|
||||
" tcontext=%s"
|
||||
|
|
@ -2647,7 +2647,7 @@ int security_set_bools(int len, int *values)
|
|||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!!values[i] != policydb.bool_val_to_struct[i]->state) {
|
||||
audit_log(current->audit_context, GFP_ATOMIC,
|
||||
audit_log(audit_context(), GFP_ATOMIC,
|
||||
AUDIT_MAC_CONFIG_CHANGE,
|
||||
"bool=%s val=%d old_val=%d auid=%u ses=%u",
|
||||
sym_name(&policydb, SYM_BOOLS, i),
|
||||
|
|
@ -2781,7 +2781,7 @@ int security_sid_mls_copy(u32 sid, u32 mls_sid, u32 *new_sid)
|
|||
rc = convert_context_handle_invalid_context(&newcon);
|
||||
if (rc) {
|
||||
if (!context_struct_to_string(&newcon, &s, &len)) {
|
||||
audit_log(current->audit_context,
|
||||
audit_log(audit_context(),
|
||||
GFP_ATOMIC, AUDIT_SELINUX_ERR,
|
||||
"op=security_sid_mls_copy "
|
||||
"invalid_context=%s", s);
|
||||
|
|
|
|||
Loading…
Reference in a new issue