<div dir="ltr"><div><div><div>Rgb/Steve,<br><br></div>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? How is an application supposed to analyse the logs when a single log spans multiple namespaces ? 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?<br></div><div><br></div><div>I agree it can mess up other system calls, but atleast in this case for clone, this issue should be fixed somehow. The audit logs having pid and ppids in different namespace and exit codes in different namespace is just making the log impossible to parse. 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.  <br></div><div><br></div><div>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 ?<br></div><div><br></div>Regards,<br></div>Madzcar<br><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 8, 2018 at 6:23 PM, Richard Guy Briggs <span dir="ltr"><<a href="mailto:rgb@redhat.com" target="_blank">rgb@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2018-01-05 13:07, Steve Grubb wrote:<br>
> On Friday, January 5, 2018 6:00:01 AM EST madz car wrote:<br>
> > Hi Guys,<br>
> ><br>
> > Please refer to the issue details at github :<br>
> > <a href="https://github.com/linux-audit/audit-kernel/issues/68" rel="noreferrer" target="_blank">https://github.com/linux-<wbr>audit/audit-kernel/issues/68</a><br>
> ><br>
> > Here is a patch as suggested by rgb, i can confirm that it works.<br>
><br>
> By hooking this function, doesn't this change the return code for all<br>
> syscalls?<br>
<br>
</span>Yes, you are right, Steve.  This would give bogus return values for all<br>
other syscalls.<br>
<br>
Madzcar, I assume you can confirm that this patch will give incorrect<br>
results for all other syscalls for the "exit" field.<br>
<br>
So, that should be in kernel/fork.c:_do_fork(), or rather, just replace<br>
the pid_vnr() call with pid_nr().  However, this will mess up all<br>
callers (clone(2), fork(2), vfork(2) kernel_thread(), do_fork()), who<br>
expect the return value in the caller's PID namespace, so that won't<br>
work.  The return value is technically correct for the PID namespace<br>
from which it was called and reported correctly in the audit record.<br>
<br>
Madzcar, the way you are trying to interpret the results from the audit<br>
record is clever, but not going to work without another way to translate<br>
that value lifted out of the audit record.<br>
<br>
I don't know if there is a userspace tool or call to translate PIDs<br>
between namespaces.<br>
<span class=""><br>
> -Steve<br>
><br>
> > diff --git a/kernel/auditsc.c b/kernel/auditsc.c<br>
> > index ecc23e2..9a78ecb 100644<br>
> > --- a/kernel/auditsc.c<br>
> > +++ b/kernel/auditsc.c<br>
> > @@ -1557,6 +1557,11 @@ void __audit_syscall_exit(int success, long<br>
> > return_code)<br>
> >  {<br>
> >         struct task_struct *tsk = current;<br>
> >         struct audit_context *context;<br>
> > +<br>
> > +        rcu_read_lock();<br>
> > +        return_code = pid_nr(find_vpid((int) return_code));<br>
> > +        rcu_read_unlock();<br>
> > +<br>
> ><br>
> >         if (success)<br>
> >                 success = AUDITSC_SUCCESS;<br>
> ><br>
> ><br>
> > Kindly review.<br>
> ><br>
> > Regards,<br>
> > Madzcar<br>
<br>
</span>- RGB<br>
<br>
--<br>
Richard Guy Briggs <<a href="mailto:rgb@redhat.com">rgb@redhat.com</a>><br>
Sr. S/W Engineer, Kernel Security, Base Operating Systems<br>
Remote, Ottawa, Red Hat Canada<br>
IRC: rgb, SunRaycer<br>
Voice: <a href="tel:%2B1.647.777.2635" value="+16477772635">+1.647.777.2635</a>, Internal: (81) 32635<br>
<br>
--<br>
Linux-audit mailing list<br>
<a href="mailto:Linux-audit@redhat.com">Linux-audit@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/linux-audit" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/linux-audit</a><br>
</blockquote></div><br></div></div></div></div></div>