Thread (3 messages) flat view 3 messages, 3 authors, 2021-07-30
STALE1847d

[PATCH] arm64: audit: fix return value high 32bit truncation problem

From: Yuchen Wei <hidden>
Date: 2021-07-22 06:07:17
Also in: lkml
Subsystem: arm64 port (aarch64 architecture), the rest · Maintainers: Catalin Marinas, Will Deacon, Linus Torvalds

From: weiyuchen <redacted>

Add error code judgment in invoke_syscall() to prevent kernel
components such as audit and tracepoint from obtaining incorrect
return values. For example:

type=SYSCALL msg=audit(342.780:69): arch=40000028 syscall=235
success=yes exit=4294967235

The syscall return value is -61, but due to the following process in
invoke_syscall():

	if (is_compat_task())
		ret = lower_32_bits(ret);
	regs->regs[0] = ret;

The return value audit or tracepoint get from regs[0] is 4294967235,
which is an incorrect return value.

Signed-off-by: weiyuchen <redacted>
---
 arch/arm64/kernel/syscall.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c
index 263d6c1a525f..f9f042d9a088 100644
--- a/arch/arm64/kernel/syscall.c
+++ b/arch/arm64/kernel/syscall.c
@@ -54,7 +54,7 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno,
 		ret = do_ni_syscall(regs, scno);
 	}
 
-	if (is_compat_task())
+	if (is_compat_task() && !IS_ERR_VALUE(ret))
 		ret = lower_32_bits(ret);
 
 	regs->regs[0] = ret;
-- 
2.12.3


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help