public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Paul Moore <paul.moore@hp.com>
To: linux-audit@redhat.com
Subject: Audit not recording the correct syscall return value in Fedora 10?
Date: Tue, 7 Apr 2009 11:34:35 -0400	[thread overview]
Message-ID: <200904071134.35379.paul.moore@hp.com> (raw)

While doing some testing on Fedora 10 using the 2.6.27.5-117.fc10.x86_64 
kernel I stumbled across a rather odd problem: somewhere between the end of 
sys_sendto() and audit_syscall_exit() the syscall's return value was changing 
resulting in incorrect audit records (similar problems with sys_sendmsg()).  
After some head scratching and debugging I determined that the %rax register 
was being altered at some point and if we reloaded the syscall's return value 
from the stack before calling audit_syscall_exit() we could avoid the problem 
(see patch below).

I also tried to reproduce the problem with a vanilla 2.6.29.1 kernel and after 
several hours of testing I have yet to see the problem using the newer, 
upstream kernel.  Taking a look at the entry_64.S files of the two kernels 
there appear to be a number of changes, the most significant are the tracing 
changes but I'm not familiar enough with this chunk of code to identify the 
definitive root cause (although, tracing changes does sound reasonable).

Does anyone have any thoughts?

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index a331ec3..16db517 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -589,8 +589,8 @@ auditsys:
         * masked off.
         */
 sysret_audit:
-       movq %rax,%rsi          /* second arg, syscall return value */
-       cmpq $0,%rax            /* is it < 0? */
+       movq RAX-ARGOFFSET(%rsp),%rsi   /* second arg, syscall return value */
+       cmpq $0,%rsi                    /* is it < 0? */
        setl %al                /* 1 if so, 0 if not */
        movzbl %al,%edi         /* zero-extend that into %edi */
        inc %edi /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */

-- 
paul moore
linux @ hp

             reply	other threads:[~2009-04-07 15:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-07 15:34 Paul Moore [this message]
2009-04-08  2:44 ` Audit not recording the correct syscall return value in Fedora 10? Klaus Heinrich Kiwi
2009-04-08 21:38   ` Paul Moore
2009-05-05 18:15   ` Tony Jones
2009-05-05 18:08 ` Tony Jones
2009-05-05 18:22   ` Paul Moore
2009-05-05 19:07     ` Tony Jones
2009-05-05 19:20       ` Paul Moore
2009-05-05 19:34         ` Tony Jones
2009-05-05 19:50           ` Paul Moore
2009-05-07 23:05             ` Tony Jones
2009-05-08 13:22               ` 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=200904071134.35379.paul.moore@hp.com \
    --to=paul.moore@hp.com \
    --cc=linux-audit@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