From: He Zhe <zhe.he@windriver.com>
To: paul@paul-moore.com, eparis@redhat.com, linux-audit@redhat.com,
linux-kernel@vger.kernel.org, zhe.he@windriver.com
Subject: [PATCH 1/2] audit: Add syscall return code handling for compat task
Date: Wed, 14 Apr 2021 16:01:45 +0800 [thread overview]
Message-ID: <20210414080145.17378-1-zhe.he@windriver.com> (raw)
When 32-bit userspace application is running on 64-bit kernel, the 32-bit
syscall return code would be changed from u32 to u64 in regs_return_value
and then changed to s64. Hence the negative return code recorded by audit
would end up being a big positive number like below.
type=SYSCALL msg=audit(1611110715.887:582): arch=40000028 syscall=322
success=yes exit=4294967283
This patch forces the u32->s32->s64 for compat tasks.
Signed-off-by: He Zhe <zhe.he@windriver.com>
---
include/linux/audit.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 82b7c1116a85..32cb853f3029 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -334,7 +334,9 @@ static inline void audit_syscall_exit(void *pt_regs)
{
if (unlikely(audit_context())) {
int success = is_syscall_success(pt_regs);
- long return_code = regs_return_value(pt_regs);
+ long return_code = is_compat_task() ?
+ (s64)(s32)regs_return_value(pt_regs) :
+ regs_return_value(pt_regs);
__audit_syscall_exit(success, return_code);
}
--
2.17.1
next reply other threads:[~2021-04-14 8:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-14 8:01 He Zhe [this message]
2021-04-14 15:35 ` [PATCH 1/2] audit: Add syscall return code handling for compat task David Laight
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=20210414080145.17378-1-zhe.he@windriver.com \
--to=zhe.he@windriver.com \
--cc=eparis@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@paul-moore.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;
as well as URLs for NNTP newsgroup(s).