From: Dave Martin Date: Mon, 27 Mar 2017 14:10:57 +0000 (+0100) Subject: metag/ptrace: Reject partial NT_METAG_RPIPE writes X-Git-Tag: v4.9.20~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=21c95eca627bf63fa56dc19f5fb5fb2a770dadc0;p=platform%2Fkernel%2Flinux-amlogic.git metag/ptrace: Reject partial NT_METAG_RPIPE writes commit 7195ee3120d878259e8d94a5d9f808116f34d5ea upstream. It's not clear what behaviour is sensible when doing partial write of NT_METAG_RPIPE, so just don't bother. This patch assumes that userspace will never rely on a partial SETREGSET in this case, since it's not clear what should happen anyway. Signed-off-by: Dave Martin Acked-by: James Hogan Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/arch/metag/kernel/ptrace.c b/arch/metag/kernel/ptrace.c index 2e4dfc1..5e2dc7d 100644 --- a/arch/metag/kernel/ptrace.c +++ b/arch/metag/kernel/ptrace.c @@ -253,6 +253,8 @@ int metag_rp_state_copyin(struct pt_regs *regs, unsigned long long *ptr; int ret, i; + if (count < 4*13) + return -EINVAL; /* Read the entire pipeline before making any changes */ ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &rp, 0, 4*13);