diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2023-03-06 01:20:30 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-04-05 11:16:40 +0200 |
commit | 299a309b98df4e349acaffca23cff72105f1c0a5 (patch) | |
tree | 0c58a2658d94b38ef32adbc9601dfd20ea01d919 /arch/sh | |
parent | f4c610f6ca1303dcc896a12c85a15b787731739e (diff) | |
download | linux-stable-299a309b98df4e349acaffca23cff72105f1c0a5.tar.gz linux-stable-299a309b98df4e349acaffca23cff72105f1c0a5.tar.bz2 linux-stable-299a309b98df4e349acaffca23cff72105f1c0a5.zip |
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: Al Viro <viro@zeniv.linux.org.uk>
Cc: Rich Felker <dalias@libc.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/include/asm/processor_32.h | 1 | ||||
-rw-r--r-- | arch/sh/kernel/signal_32.c | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/arch/sh/include/asm/processor_32.h b/arch/sh/include/asm/processor_32.h index 0e0ecc0132e3..58ae979798fa 100644 --- a/arch/sh/include/asm/processor_32.h +++ b/arch/sh/include/asm/processor_32.h @@ -51,6 +51,7 @@ #define SR_FD 0x00008000 #define SR_MD 0x40000000 +#define SR_USER_MASK 0x00000303 // M, Q, S, T bits /* * DSP structure and data */ diff --git a/arch/sh/kernel/signal_32.c b/arch/sh/kernel/signal_32.c index 24473fa6c3b6..f6e1a47ad7ca 100644 --- a/arch/sh/kernel/signal_32.c +++ b/arch/sh/kernel/signal_32.c @@ -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; |