From: Oleg Nesterov <oleg@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: linux-audit@redhat.com, linux-kernel@vger.kernel.org,
Andi Kleen <andi@firstfloor.org>, Steve Grubb <sgrubb@redhat.com>,
Eric Paris <eparis@redhat.com>
Subject: Re: [PATCH v2.1] audit: Only use the syscall slowpath when syscall audit rules exist
Date: Tue, 4 Feb 2014 17:50:15 +0100 [thread overview]
Message-ID: <20140204165015.GA3011@redhat.com> (raw)
In-Reply-To: <377a1c5ce05e25b068cf7576d094885c1396c6bc.1391454589.git.luto@amacapital.net>
On 02/03, Andy Lutomirski wrote:
>
> +void audit_inc_n_rules()
> +{
> + struct task_struct *p, *g;
> + unsigned long flags;
> +
> + read_lock_irqsave(&tasklist_lock, flags);
Confused... read_lock(tasklist) doesn't need to disable irqs.
(ftrace does this for no reason too, perhaps I should resend the patch)
> + if (audit_n_rules++ == 0) {
probably this can be done outside of read_lock?
> + do_each_thread(g, p) {
for_each_process_thread ;) do_each_thread will die, I hope.
> +void audit_dec_n_rules()
> +{
> + struct task_struct *p, *g;
> + unsigned long flags;
> +
> + read_lock_irqsave(&tasklist_lock, flags);
> +
> + --audit_n_rules;
> + BUG_ON(audit_n_rules < 0);
> +
> + if (audit_n_rules == 0) {
> + do_each_thread(g, p) {
> + clear_tsk_thread_flag(p, TIF_SYSCALL_AUDIT);
> + } while_each_thread(g, p);
> + }
The same, and...
On a second thought it seems that audit_dec_n_rules() has a problem.
Note the BUG_ON(context->in_syscall) in __audit_syscall_entry().
Suppose that audit_dec_n_rules() clears TIF_SYSCALL_AUDIT when a task
runs a syscall. In this case (afaics) __audit_syscall_exit() won't be
called. The next audit_inc_n_rules() can set TIF_SYSCALL_AUDIT and
trigger another __audit_syscall_entry() which will hit this BUG_ON().
And in general it doesn't look safe although I know almost nothing
about audit. I mean, currently __audit_syscall_entry() or
__audit_log_bprm_fcaps() assume that __audit_syscall_exit() or
__audit_free() will "cleanup" ->audit_context, perhaps we should not
break the rules?
Once again, I do not pretend I understand this code, this is the
question, not the comment.
But if I am right, then TIF_SYSCALL_AUDIT should be cleared in
__audit_syscall_exit() as you suggested before.
Oleg.
next prev parent reply other threads:[~2014-02-04 16:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-03 19:11 [PATCH v2.1] audit: Only use the syscall slowpath when syscall audit rules exist Andy Lutomirski
2014-02-03 20:35 ` Eric Paris
2014-02-03 21:09 ` Andy Lutomirski
2014-02-04 16:50 ` Oleg Nesterov [this message]
2014-02-04 18:11 ` Andy Lutomirski
2014-02-04 19:11 ` Oleg Nesterov
2014-02-04 19:32 ` Andy Lutomirski
2014-02-05 13:46 ` Eric Paris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140204165015.GA3011@redhat.com \
--to=oleg@redhat.com \
--cc=andi@firstfloor.org \
--cc=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=sgrubb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox