* [PATCH 1/2] audit: Add syscall return code handling for compat task
@ 2021-04-14 8:01 He Zhe
2021-04-14 15:35 ` David Laight
0 siblings, 1 reply; 2+ messages in thread
From: He Zhe @ 2021-04-14 8:01 UTC (permalink / raw)
To: paul, eparis, linux-audit, linux-kernel, zhe.he
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH 1/2] audit: Add syscall return code handling for compat task
2021-04-14 8:01 [PATCH 1/2] audit: Add syscall return code handling for compat task He Zhe
@ 2021-04-14 15:35 ` David Laight
0 siblings, 0 replies; 2+ messages in thread
From: David Laight @ 2021-04-14 15:35 UTC (permalink / raw)
To: 'He Zhe', paul, eparis, linux-audit, linux-kernel
From: He Zhe
> Sent: 14 April 2021 09:02
>
> 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() ?
Should that be is_compat_syscall() ?
A x86-64 process can make both types of 32bit system calls.
David
> + (s64)(s32)regs_return_value(pt_regs) :
> + regs_return_value(pt_regs);
>
> __audit_syscall_exit(success, return_code);
> }
> --
> 2.17.1
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-04-14 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14 8:01 [PATCH 1/2] audit: Add syscall return code handling for compat task He Zhe
2021-04-14 15:35 ` David Laight
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).