2013-09-15 17:16:55

by Oleg Nesterov

[permalink] [raw]
Subject: [PATCH v2 1/1] audit_alloc: clear TIF_SYSCALL_AUDIT if !audit_context

Hello,

v2:
- update the changelog

- add the ack from Steve

Oleg.


2013-09-15 17:17:27

by Oleg Nesterov

[permalink] [raw]
Subject: [PATCH v2 1/1] audit_alloc: clear TIF_SYSCALL_AUDIT if !audit_context

If audit_filter_task() nacks the new thread it makes sense
to clear TIF_SYSCALL_AUDIT which can be copied from parent
by dup_task_struct().

A wrong TIF_SYSCALL_AUDIT is not really bad but it triggers
the "slow" audit paths in entry.S to ensure the task can not
miss audit_syscall_*() calls, this is pointless if the task
has no ->audit_context.

Signed-off-by: Oleg Nesterov <[email protected]>
Acked-by: Steve Grubb <[email protected]>
---
kernel/auditsc.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 9845cb3..95293ab 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -943,8 +943,10 @@ int audit_alloc(struct task_struct *tsk)
return 0; /* Return if not auditing. */

state = audit_filter_task(tsk, &key);
- if (state == AUDIT_DISABLED)
+ if (state == AUDIT_DISABLED) {
+ clear_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT);
return 0;
+ }

if (!(context = audit_alloc_context(state))) {
kfree(key);
--
1.5.5.1

2013-09-20 16:08:21

by Eric Paris

[permalink] [raw]
Subject: Re: [PATCH v2 1/1] audit_alloc: clear TIF_SYSCALL_AUDIT if !audit_context

On Sun, 2013-09-15 at 19:11 +0200, Oleg Nesterov wrote:
> If audit_filter_task() nacks the new thread it makes sense
> to clear TIF_SYSCALL_AUDIT which can be copied from parent
> by dup_task_struct().
>
> A wrong TIF_SYSCALL_AUDIT is not really bad but it triggers
> the "slow" audit paths in entry.S to ensure the task can not
> miss audit_syscall_*() calls, this is pointless if the task
> has no ->audit_context.
>
> Signed-off-by: Oleg Nesterov <[email protected]>
> Acked-by: Steve Grubb <[email protected]>

Acked-by: Eric Paris <[email protected]>

Richard, please pick this up into your tree.

> ---
> kernel/auditsc.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 9845cb3..95293ab 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -943,8 +943,10 @@ int audit_alloc(struct task_struct *tsk)
> return 0; /* Return if not auditing. */
>
> state = audit_filter_task(tsk, &key);
> - if (state == AUDIT_DISABLED)
> + if (state == AUDIT_DISABLED) {
> + clear_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT);
> return 0;
> + }
>
> if (!(context = audit_alloc_context(state))) {
> kfree(key);

2013-09-23 21:55:24

by Richard Guy Briggs

[permalink] [raw]
Subject: Re: [PATCH v2 1/1] audit_alloc: clear TIF_SYSCALL_AUDIT if !audit_context

On Fri, Sep 20, 2013 at 12:08:02PM -0400, Eric Paris wrote:
> On Sun, 2013-09-15 at 19:11 +0200, Oleg Nesterov wrote:
> > If audit_filter_task() nacks the new thread it makes sense
> > to clear TIF_SYSCALL_AUDIT which can be copied from parent
> > by dup_task_struct().
> >
> > A wrong TIF_SYSCALL_AUDIT is not really bad but it triggers
> > the "slow" audit paths in entry.S to ensure the task can not
> > miss audit_syscall_*() calls, this is pointless if the task
> > has no ->audit_context.
> >
> > Signed-off-by: Oleg Nesterov <[email protected]>
> > Acked-by: Steve Grubb <[email protected]>
>
> Acked-by: Eric Paris <[email protected]>
>
> Richard, please pick this up into your tree.

Ack.

> > ---
> > kernel/auditsc.c | 4 +++-
> > 1 files changed, 3 insertions(+), 1 deletions(-)
> >
> > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > index 9845cb3..95293ab 100644
> > --- a/kernel/auditsc.c
> > +++ b/kernel/auditsc.c
> > @@ -943,8 +943,10 @@ int audit_alloc(struct task_struct *tsk)
> > return 0; /* Return if not auditing. */
> >
> > state = audit_filter_task(tsk, &key);
> > - if (state == AUDIT_DISABLED)
> > + if (state == AUDIT_DISABLED) {
> > + clear_tsk_thread_flag(tsk, TIF_SYSCALL_AUDIT);
> > return 0;
> > + }
> >
> > if (!(context = audit_alloc_context(state))) {
> > kfree(key);

- RGB

--
Richard Guy Briggs <[email protected]>
Senior Software Engineer
Kernel Security
AMER ENG Base Operating Systems
Remote, Ottawa, Canada
Voice: +1.647.777.2635
Internal: (81) 32635
Alt: +1.613.693.0684x3545