lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 15 Jun 2022 09:39:05 +0800
From:   Tiezhu Yang <yangtiezhu@...ngson.cn>
To:     Huacai Chen <chenhuacai@...nel.org>,
        WANG Xuerui <kernel@...0n.name>
Cc:     Xuefeng Li <lixuefeng@...ngson.cn>,
        Jianmin Lv <lvjianmin@...ngson.cn>, Jun Yi <yijun@...ngson.cn>,
        linux-kernel@...r.kernel.org
Subject: [RFC PATCH 2/2] LoongArch: No need to call RESTORE_ALL_AND_RET for all syscalls

In handle_syscall, it is unnecessary to call RESTORE_ALL_AND_RET for all
syscalls, clone and clone3 should call RESTORE_STATIC_SOME_AND_RET, and
the other syscalls should call RESTORE_SOME_AND_RET.

Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
---
 arch/loongarch/include/asm/stackframe.h | 10 ++++++++++
 arch/loongarch/kernel/entry.S           | 12 +++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h
index 4ca9530..9869b39 100644
--- a/arch/loongarch/include/asm/stackframe.h
+++ b/arch/loongarch/include/asm/stackframe.h
@@ -216,4 +216,14 @@
 	RESTORE_SP_AND_RET \docfi
 	.endm
 
+	.macro	RESTORE_STATIC_SOME_AND_RET docfi=0
+	RESTORE_STATIC \docfi
+	RESTORE_SOME \docfi
+	RESTORE_SP_AND_RET \docfi
+	.endm
+
+	.macro	RESTORE_SOME_AND_RET docfi=0
+	RESTORE_SOME \docfi
+	RESTORE_SP_AND_RET \docfi
+	.endm
 #endif /* _ASM_STACKFRAME_H */
diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.S
index 551b6ec..8176094 100644
--- a/arch/loongarch/kernel/entry.S
+++ b/arch/loongarch/kernel/entry.S
@@ -78,7 +78,17 @@ SYM_FUNC_START(handle_syscall)
 	move	a0, sp
 	bl	do_syscall
 
-	RESTORE_ALL_AND_RET
+	/*
+	 * Syscall number held in a7.
+	 * If syscall number is __NR_clone and __NR_clone3, call RESTORE_STATIC_SOME_AND_RET.
+	 */
+	li.w	t3, __NR_clone
+	beq	a7, t3, 3f
+	li.w	t3, __NR_clone3
+	beq	a7, t3, 3f
+	RESTORE_SOME_AND_RET
+3:
+	RESTORE_STATIC_SOME_AND_RET
 SYM_FUNC_END(handle_syscall)
 
 SYM_CODE_START(ret_from_fork)
-- 
2.1.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ