History

audit: use inline function to set audit context

Recognizing that the audit context is an internal audit value, use an access function to set the audit context pointer for the task rather than reaching directly into the task struct to set it.

Richard Guy Briggs committed 8 years ago

Commit c0b0ae81 parent cdfb6b33 files · +11 −5Browse files

Unified · Split

3 files
  1. include/linux/audit.h +7 −0
  2. kernel/auditsc.c +3 −4
  3. kernel/fork.c +1 −1
include/linux/audit.h+7−0
@@ -237,6 +237,11 @@ extern void audit_seccomp_actions_logged(const char *names, · 236 unmodified lines
237237 const char *old_names, int res);
238238 extern void __audit_ptrace(struct task_struct *t);
239239
240+static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx)
241+{
242+ task->audit_context = ctx;
243+}
244+
240245 static inline struct audit_context *audit_context(void)
241246 {
242247 return current->audit_context;
@@ -469,6 +474,8 @@ static inline bool audit_dummy_context(void) · 226 unmodified lines
469474 {
470475 return true;
471476 }
477+static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx)
478+{ }
472479 static inline struct audit_context *audit_context(void)
473480 {
474481 return NULL;
kernel/auditsc.c+3−4
@@ -865,7 +865,7 @@ static inline struct audit_context *audit_take_context(struct task_struct *tsk, · 864 unmodified lines
865865 audit_filter_inodes(tsk, context);
866866 }
867867
868− tsk->audit_context = NULL;
868+ audit_set_context(tsk, NULL);
869869 return context;
870870 }
871871
@@ -952,7 +952,7 @@ int audit_alloc(struct task_struct *tsk) · 80 unmodified lines
952952 }
953953 context->filterkey = key;
954954
955− tsk->audit_context = context;
955+ audit_set_context(tsk, context);
956956 set_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT);
957957 return 0;
958958 }
@@ -1554,7 +1554,6 @@ void __audit_syscall_entry(int major, unsigned long a1, unsigned long a2, · 595 unmodified lines
15541554 */
15551555 void __audit_syscall_exit(int success, long return_code)
15561556 {
1557− struct task_struct *tsk = current;
15581557 struct audit_context *context;
15591558
15601559 if (success)
@@ -1589,7 +1588,7 @@ void __audit_syscall_exit(int success, long return_code) · 28 unmodified lines
15891588 kfree(context->filterkey);
15901589 context->filterkey = NULL;
15911590 }
1592− tsk->audit_context = context;
1591+ audit_set_context(current, context);
15931592 }
15941593
15951594 static inline void handle_one(const struct inode *inode)
kernel/fork.c+1−1
@@ -1713,7 +1713,7 @@ static __latent_entropy struct task_struct *copy_process( · 1712 unmodified lines
17131713 p->start_time = ktime_get_ns();
17141714 p->real_start_time = ktime_get_boot_ns();
17151715 p->io_context = NULL;
1716− p->audit_context = NULL;
1716+ audit_set_context(p, NULL);
17171717 cgroup_fork(p);
17181718 #ifdef CONFIG_NUMA
17191719 p->mempolicy = mpol_dup(p->mempolicy);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t