mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 16:15:11 +00:00
sh: sanitize the flags on sigreturn
[ Upstream commit 573b22ccb7
]
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>
This commit is contained in:
parent
9519b377f6
commit
3cee5bd222
2 changed files with 4 additions and 0 deletions
|
@ -50,6 +50,7 @@
|
||||||
#define SR_FD 0x00008000
|
#define SR_FD 0x00008000
|
||||||
#define SR_MD 0x40000000
|
#define SR_MD 0x40000000
|
||||||
|
|
||||||
|
#define SR_USER_MASK 0x00000303 // M, Q, S, T bits
|
||||||
/*
|
/*
|
||||||
* DSP structure and data
|
* DSP structure and data
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -115,6 +115,7 @@ static int
|
||||||
restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
|
restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p)
|
||||||
{
|
{
|
||||||
unsigned int err = 0;
|
unsigned int err = 0;
|
||||||
|
unsigned int sr = regs->sr & ~SR_USER_MASK;
|
||||||
|
|
||||||
#define COPY(x) err |= __get_user(regs->x, &sc->sc_##x)
|
#define COPY(x) err |= __get_user(regs->x, &sc->sc_##x)
|
||||||
COPY(regs[1]);
|
COPY(regs[1]);
|
||||||
|
@ -130,6 +131,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *r0_p
|
||||||
COPY(sr); COPY(pc);
|
COPY(sr); COPY(pc);
|
||||||
#undef COPY
|
#undef COPY
|
||||||
|
|
||||||
|
regs->sr = (regs->sr & SR_USER_MASK) | sr;
|
||||||
|
|
||||||
#ifdef CONFIG_SH_FPU
|
#ifdef CONFIG_SH_FPU
|
||||||
if (boot_cpu_data.flags & CPU_HAS_FPU) {
|
if (boot_cpu_data.flags & CPU_HAS_FPU) {
|
||||||
int owned_fp;
|
int owned_fp;
|
||||||
|
|
Loading…
Reference in a new issue