Message ID | 2f0566af8ccafdaf400a3d002cb4aef9b80e44cf.1525466167.git.rgb@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, May 04, 2018 at 04:54:37PM -0400, Richard Guy Briggs wrote: > 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. > > Signed-off-by: Richard Guy Briggs <rgb@redhat.com> > --- > include/linux/audit.h | 8 ++++++++ > kernel/auditsc.c | 6 +++--- > kernel/fork.c | 2 +- > 3 files changed, 12 insertions(+), 4 deletions(-) > > diff --git a/include/linux/audit.h b/include/linux/audit.h > index 93e4c61..dba0d45 100644 > --- a/include/linux/audit.h > +++ b/include/linux/audit.h > @@ -235,6 +235,10 @@ extern void __audit_inode_child(struct inode *parent, > extern void __audit_seccomp(unsigned long syscall, long signr, int code); > extern void __audit_ptrace(struct task_struct *t); > > +static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) > +{ > + task->audit_context = ctx; > +} > static inline struct audit_context *audit_context(struct task_struct *task) > { > return task->audit_context; > @@ -472,6 +476,10 @@ static inline bool audit_dummy_context(void) > { > return true; > } > +static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) > +{ > + task->audit_context = ctx; > +} If audit_context is an internal audit value why do we set it when CONFIG_AUDITSYSCALL is not set? thanks, Tobin.
On 2018-05-09 12:07, Tobin C. Harding wrote: > On Fri, May 04, 2018 at 04:54:37PM -0400, Richard Guy Briggs wrote: > > 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. > > > > Signed-off-by: Richard Guy Briggs <rgb@redhat.com> > > --- > > include/linux/audit.h | 8 ++++++++ > > kernel/auditsc.c | 6 +++--- > > kernel/fork.c | 2 +- > > 3 files changed, 12 insertions(+), 4 deletions(-) > > > > diff --git a/include/linux/audit.h b/include/linux/audit.h > > index 93e4c61..dba0d45 100644 > > --- a/include/linux/audit.h > > +++ b/include/linux/audit.h > > @@ -235,6 +235,10 @@ extern void __audit_inode_child(struct inode *parent, > > extern void __audit_seccomp(unsigned long syscall, long signr, int code); > > extern void __audit_ptrace(struct task_struct *t); > > > > +static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) > > +{ > > + task->audit_context = ctx; > > +} > > static inline struct audit_context *audit_context(struct task_struct *task) > > { > > return task->audit_context; > > @@ -472,6 +476,10 @@ static inline bool audit_dummy_context(void) > > { > > return true; > > } > > +static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) > > +{ > > + task->audit_context = ctx; > > +} > > If audit_context is an internal audit value why do we set it when > CONFIG_AUDITSYSCALL is not set? Agreed, that is unnecessary, but harmless since it won't be called, or will be called with a value of NULL. That has been fixed in my dynamic allocation patchset since not even the audit_task_info struct is available to assign the value. It is now an empty function like the rest. > Tobin. - RGB -- Richard Guy Briggs <rgb@redhat.com> Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635
diff --git a/include/linux/audit.h b/include/linux/audit.h index 93e4c61..dba0d45 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -235,6 +235,10 @@ extern void __audit_inode_child(struct inode *parent, extern void __audit_seccomp(unsigned long syscall, long signr, int code); extern void __audit_ptrace(struct task_struct *t); +static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) +{ + task->audit_context = ctx; +} static inline struct audit_context *audit_context(struct task_struct *task) { return task->audit_context; @@ -472,6 +476,10 @@ static inline bool audit_dummy_context(void) { return true; } +static inline void audit_set_context(struct task_struct *task, struct audit_context *ctx) +{ + task->audit_context = ctx; +} static inline struct audit_context *audit_context(struct task_struct *task) { return NULL; diff --git a/kernel/auditsc.c b/kernel/auditsc.c index a4bbdcc..f294e4a 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -865,7 +865,7 @@ static inline struct audit_context *audit_take_context(struct task_struct *tsk, audit_filter_inodes(tsk, context); } - tsk->audit_context = NULL; + audit_set_context(tsk, NULL); return context; } @@ -952,7 +952,7 @@ int audit_alloc(struct task_struct *tsk) } context->filterkey = key; - tsk->audit_context = context; + audit_set_context(tsk, context); set_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT); return 0; } @@ -1590,7 +1590,7 @@ void __audit_syscall_exit(int success, long return_code) kfree(context->filterkey); context->filterkey = NULL; } - tsk->audit_context = context; + audit_set_context(tsk, context); } static inline void handle_one(const struct inode *inode) diff --git a/kernel/fork.c b/kernel/fork.c index 242c8c9..cd18448 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1713,7 +1713,7 @@ static __latent_entropy struct task_struct *copy_process( p->start_time = ktime_get_ns(); p->real_start_time = ktime_get_boot_ns(); p->io_context = NULL; - p->audit_context = NULL; + audit_set_context(p, NULL); cgroup_fork(p); #ifdef CONFIG_NUMA p->mempolicy = mpol_dup(p->mempolicy);
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. Signed-off-by: Richard Guy Briggs <rgb@redhat.com> --- include/linux/audit.h | 8 ++++++++ kernel/auditsc.c | 6 +++--- kernel/fork.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-)