Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4e7fa8f authored by Al Viro's avatar Al Viro Committed by Greg Kroah-Hartman
Browse files

sh: sanitize the flags on sigreturn



[ Upstream commit 573b22ccb7ce9ab7f0539a2e11a9d3609a8783f5 ]

We fetch %SR value from sigframe; it might have been modified by signal
handler, so we can't trust it with any bits that are not modifiable in
user mode.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Cc: Rich Felker <dalias@libc.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent bcc029c7
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@
#define SR_FD		0x00008000
#define SR_MD		0x40000000

#define SR_USER_MASK	0x00000303	// M, Q, S, T bits
/*
 * DSP structure and data
 */
+3 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ static int
restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
{
	unsigned int err = 0;
	unsigned int sr = regs->sr & ~SR_USER_MASK;

#define COPY(x)		err |= __get_user(regs->x, &sc->sc_##x)
			COPY(regs[1]);
@@ -131,6 +132,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p
	COPY(sr);	COPY(pc);
#undef COPY

	regs->sr = (regs->sr & SR_USER_MASK) | sr;

#ifdef CONFIG_SH_FPU
	if (boot_cpu_data.flags & CPU_HAS_FPU) {
		int owned_fp;