All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Grubb <sgrubb@redhat.com>
To: madz car <madzcar@gmail.com>
Cc: Richard Guy Briggs <rgb@redhat.com>, linux-audit@redhat.com
Subject: Re: patch suggested by rgb for fixing auditd logs for clone syscall shows exit code as container namespace pid of child process instead of host namespace
Date: Mon, 08 Jan 2018 14:03:14 -0500	[thread overview]
Message-ID: <4772470.tDBtJTPdY8@x2> (raw)
In-Reply-To: <CAEcbJGE=Z1_+VkBZk3rK6Ziyhg5uDBonrLCcR3nzokhxMv0u4Q@mail.gmail.com>

Hello,

On Monday, January 8, 2018 12:49:48 PM EST madz car wrote:
> Appreciate your response on this issue. However, if you would notice the
> pid and ppid values in the same log is in the initial namespace, while the
> exit code is in a different namespace. Doesnt this make the audit log
> inconsistent?

I would think that pid and ppid should be from the caller/parent's pov. The 
exit code, on a successful call, should be the pid that the new process knows 
itself by. However, that alone is not enough.


> How is an application supposed to analyse the logs when a single log spans
> multiple namespaces ? 

That very problem is being worked on. Richard has circulated several drafts 
of how the audit subsystem will track processes through namespaces. He is 
revising another draft and should circulate it again in the near future. 


> How does an application parsing the logs get to know if its actually a
> different pid namespace other than relying on audit to provide consistent
> information in the log?

There needs to be a tracker ID added to audit records.

 
> I agree it can mess up other system calls, but at least in this case for
> clone, this issue should be fixed somehow. 

I think everyone agrees on this. But the details of how it should be done are 
still being pinned down.


> The audit logs having pid and ppids in different namespace and exit codes
> in different namespace is just making the log impossible to parse.

I think you're trying to do something that we're currently not capable of 
doing. When all stakeholders are in agreement with the specification, I am 
sure that if anyone has free time to code up the specification or parts of it 
so that it lands in the upstream kernel sooner than later, it would be 
greatly appreciated.


> Some of these connections(ssh etc) can be extremely shortlived and as such
> audit logs are the only way to track such events which is not possible
> without fixing this issue.

Right. But the fix is much bigger. The last draft was aired here:
https://www.redhat.com/archives/linux-audit/2017-October/msg00037.html

But a v3 draft should be out at some point.

-Steve

> Shouldnt we use one namespace in the log and as such all pid, ppids and
> exit codes should be translated to that namespace for the log ?
> 
> Regards,
> Madzcar
> 
> On Mon, Jan 8, 2018 at 6:23 PM, Richard Guy Briggs <rgb@redhat.com> wrote:
> > On 2018-01-05 13:07, Steve Grubb wrote:
> > > On Friday, January 5, 2018 6:00:01 AM EST madz car wrote:
> > > > Hi Guys,
> > > > 
> > > > Please refer to the issue details at github :
> > > > https://github.com/linux-audit/audit-kernel/issues/68
> > > > 
> > > > Here is a patch as suggested by rgb, i can confirm that it works.
> > > 
> > > By hooking this function, doesn't this change the return code for all
> > > syscalls?
> > 
> > Yes, you are right, Steve.  This would give bogus return values for all
> > other syscalls.
> > 
> > Madzcar, I assume you can confirm that this patch will give incorrect
> > results for all other syscalls for the "exit" field.
> > 
> > So, that should be in kernel/fork.c:_do_fork(), or rather, just replace
> > the pid_vnr() call with pid_nr().  However, this will mess up all
> > callers (clone(2), fork(2), vfork(2) kernel_thread(), do_fork()), who
> > expect the return value in the caller's PID namespace, so that won't
> > work.  The return value is technically correct for the PID namespace
> > from which it was called and reported correctly in the audit record.
> > 
> > Madzcar, the way you are trying to interpret the results from the audit
> > record is clever, but not going to work without another way to translate
> > that value lifted out of the audit record.
> > 
> > I don't know if there is a userspace tool or call to translate PIDs
> > between namespaces.
> > 
> > > -Steve
> > > 
> > > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > > > index ecc23e2..9a78ecb 100644
> > > > --- a/kernel/auditsc.c
> > > > +++ b/kernel/auditsc.c
> > > > @@ -1557,6 +1557,11 @@ void __audit_syscall_exit(int success, long
> > > > return_code)
> > > > 
> > > >  {
> > > >  
> > > >         struct task_struct *tsk = current;
> > > >         struct audit_context *context;
> > > > 
> > > > +
> > > > +        rcu_read_lock();
> > > > +        return_code = pid_nr(find_vpid((int) return_code));
> > > > +        rcu_read_unlock();
> > > > +
> > > > 
> > > >         if (success)
> > > >         
> > > >                 success = AUDITSC_SUCCESS;
> > > > 
> > > > Kindly review.
> > > > 
> > > > Regards,
> > > > Madzcar
> > 
> > - 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
> > 
> > --
> > Linux-audit mailing list
> > Linux-audit@redhat.com
> > https://www.redhat.com/mailman/listinfo/linux-audit

  reply	other threads:[~2018-01-08 19:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-05 11:00 patch suggested by rgb for fixing auditd logs for clone syscall shows exit code as container namespace pid of child process instead of host namespace madz car
2018-01-05 18:07 ` Steve Grubb
2018-01-08 12:53   ` Richard Guy Briggs
2018-01-08 17:49     ` madz car
2018-01-08 19:03       ` Steve Grubb [this message]
2018-01-09  6:01         ` Richard Guy Briggs
2018-01-09  9:54           ` Richard Guy Briggs
2018-01-10 16:19     ` Paul Moore

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=4772470.tDBtJTPdY8@x2 \
    --to=sgrubb@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=madzcar@gmail.com \
    --cc=rgb@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.