From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Sat, 29 Oct 2016 21:27:30 +0200 (CEST) Received: from mx2.suse.de ([195.135.220.15]:51876 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23992022AbcJ2T1XbDEfh (ORCPT ); Sat, 29 Oct 2016 21:27:23 +0200 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3F466ABFB; Sat, 29 Oct 2016 19:27:21 +0000 (UTC) From: Jiri Slaby To: stable@vger.kernel.org Cc: Marcin Nowakowski , linux-mips@linux-mips.org, Ralf Baechle , Jiri Slaby Subject: [patch added to 3.12-stable] MIPS: ptrace: Fix regs_return_value for kernel context Date: Sat, 29 Oct 2016 21:26:47 +0200 Message-Id: <20161029192706.17971-36-jslaby@suse.cz> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161029192706.17971-1-jslaby@suse.cz> References: <20161029192706.17971-1-jslaby@suse.cz> Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 55592 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: jslaby@suse.cz Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips From: Marcin Nowakowski This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit 74f1077b5b783e7bf4fa3007cefdc8dbd6c07518 upstream. Currently regs_return_value always negates reg[2] if it determines the syscall has failed, but when called in kernel context this check is invalid and may result in returning a wrong value. This fixes errors reported by CONFIG_KPROBES_SANITY_TEST Fixes: d7e7528bcd45 ("Audit: push audit success and retcode into arch ptrace.h") Signed-off-by: Marcin Nowakowski Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14381/ Signed-off-by: Ralf Baechle Signed-off-by: Jiri Slaby --- arch/mips/include/asm/ptrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h index 5e6cd0947393..a288de2199d8 100644 --- a/arch/mips/include/asm/ptrace.h +++ b/arch/mips/include/asm/ptrace.h @@ -73,7 +73,7 @@ static inline int is_syscall_success(struct pt_regs *regs) static inline long regs_return_value(struct pt_regs *regs) { - if (is_syscall_success(regs)) + if (is_syscall_success(regs) || !user_mode(regs)) return regs->regs[2]; else return -regs->regs[2]; -- 2.10.1