Commit 22b82991 authored by Mao Minkai's avatar Mao Minkai Committed by guzitao
Browse files

sw64: fix syscall sigreturn and rt_sigreturn

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8CCQ5



--------------------------------

Read sp from user input, because it may not be equal to sp in pt_regs
due to the implementation of setcontext in glibc.

Signed-off-by: default avatarMao Minkai <maominkai@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent 38c52459
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -114,16 +114,14 @@ restore_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs)
 * registers and transfer control from userland.
 */

SYSCALL_DEFINE0(sigreturn)
SYSCALL_DEFINE1(sigreturn, struct sigcontext __user *, sc)
{
	struct pt_regs *regs = current_pt_regs();
	struct sigcontext __user *sc;
	sigset_t set;

	/* Always make any pending restarted system calls return -EINTR */
	current->restart_block.fn = do_no_restart_syscall;

	sc = (struct sigcontext __user *)regs->regs[30];
	/* Verify that it's a good sigcontext before using it */
	if (!access_ok(sc, sizeof(*sc)))
		goto give_sigsegv;
@@ -147,16 +145,14 @@ SYSCALL_DEFINE0(sigreturn)
	return 0;
}

SYSCALL_DEFINE0(rt_sigreturn)
SYSCALL_DEFINE1(rt_sigreturn, struct rt_sigframe __user *, frame)
{
	struct pt_regs *regs = current_pt_regs();
	struct rt_sigframe __user *frame;
	sigset_t set;

	/* Always make any pending restarted system calls return -EINTR */
	current->restart_block.fn = do_no_restart_syscall;

	frame = (struct rt_sigframe __user *)regs->regs[30];
	/* Verify that it's a good ucontext_t before using it */
	if (!access_ok(&frame->uc, sizeof(frame->uc)))
		goto give_sigsegv;
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@

	nop
ENTRY(__vdso_rt_sigreturn)
	mov		$sp, $16
	ldi		$0, __NR_rt_sigreturn
	sys_call	HMC_callsys
ENDPROC(__vdso_rt_sigreturn)