Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp800661imm; Mon, 21 May 2018 14:43:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqXwP1B+7rE10nyBs4ubDlSKeUUDqRJyWNWEg1QJk6bzeKP4oVmEEz24ZGkdeLT9/MMQ1p/ X-Received: by 2002:a62:1549:: with SMTP id 70-v6mr21609339pfv.91.1526939031579; Mon, 21 May 2018 14:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526939031; cv=none; d=google.com; s=arc-20160816; b=xu2FBnoe0FzLkvxIE3r3PMaAD46lwZu1GQOAKtfEp/7DboJ5o3AQiZWBXpT1kEKkjI zfb5U5HgjxxQg3HATC2vw+igh1/LW8MpDagGb57pSSC9PXUiLZsLU31Hkir5g4sgFU3f fUSHedar5ER+5J72iqW8tMG5qbDn56NhvEZP6LYMHVjPQvGAR9rbXdNGcZJ0+a1a2rBy Qxe9Ffvt9l9Q8pFqEStMiir2nZ49wddQaLIIPHRqVzUY0iM+j6//7ncpbTT1IJ1WJJYj owFjZFpKaRMFlqbPr7TvUT+IyJiYdB1i3J1W043ZAE5LMknbGxOY/EECsuXoC0n7F+2n Pk9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Bkq7+KtuVw7YPvT1usmPtSaZubq3XRxetZg94XzoXXs=; b=Nzw4uhIhEaN2NLBUKRsAMFvy4jvP7cFqFe+Qc/UVRRbpAtEroHEXB6UXoptDg2Kl3g glowsZimCruvg55lSbROhW1c/Ao5hrW2eAYM4SkvzkE0t2ryFYQwM8KMbl+tO0fZFSP1 IGZkLK+zchS63CE9kSnXtU/TDzhfVoUM6BJ6cfU1YG17bGv8hCreFqukxHbJbObWEzqH fDJyeXKO5DtneMuv3RMAly6CGaK2B7hsTfrVC49EQxefH2WPEuPhi4QA1XL9r076bIgn tPu1mSqRcFdhD5wfEpuKWRdvTJ2t9d9QWdPIFB5k05k1Z9q07lfjIytORsOee7DPYKco 0PmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Eh53Ja4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9-v6si150672pgn.86.2018.05.21.14.43.37; Mon, 21 May 2018 14:43:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Eh53Ja4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754579AbeEUVmX (ORCPT + 99 others); Mon, 21 May 2018 17:42:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:39342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932275AbeEUVY1 (ORCPT ); Mon, 21 May 2018 17:24:27 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7B2C620873; Mon, 21 May 2018 21:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937867; bh=Axa3vjjXoe3Gk/aQzo00lksRzSsHWTK/Lsch98UxZ4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Eh53Ja4YjDyxwFgKpGWusChpmxUn3TjCyxqBG74/oy9E0YN/gYRnlUHkCXRiGp+h wIyVQqFTKcL7U9Yp/bQAwF+vLFhM9JCTcO5Ang5E6SXOmF970bQKpDIDUmtD3PucN4 Oye3QKtqdimsSlKqTJ4fa/ayKQ8tAsWr/s7vgGwA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Russell King Subject: [PATCH 4.16 054/110] ARM: 8772/1: kprobes: Prohibit kprobes on get_user functions Date: Mon, 21 May 2018 23:11:51 +0200 Message-Id: <20180521210510.230954031@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Masami Hiramatsu commit 0d73c3f8e7f6ee2aab1bb350f60c180f5ae21a2c upstream. Since do_undefinstr() uses get_user to get the undefined instruction, it can be called before kprobes processes recursive check. This can cause an infinit recursive exception. Prohibit probing on get_user functions. Fixes: 24ba613c9d6c ("ARM kprobes: core code") Signed-off-by: Masami Hiramatsu Cc: stable@vger.kernel.org Signed-off-by: Russell King Signed-off-by: Greg Kroah-Hartman --- arch/arm/include/asm/assembler.h | 10 ++++++++++ arch/arm/lib/getuser.S | 10 ++++++++++ 2 files changed, 20 insertions(+) --- a/arch/arm/include/asm/assembler.h +++ b/arch/arm/include/asm/assembler.h @@ -536,4 +536,14 @@ THUMB( orr \reg , \reg , #PSR_T_BIT ) #endif .endm +#ifdef CONFIG_KPROBES +#define _ASM_NOKPROBE(entry) \ + .pushsection "_kprobe_blacklist", "aw" ; \ + .balign 4 ; \ + .long entry; \ + .popsection +#else +#define _ASM_NOKPROBE(entry) +#endif + #endif /* __ASM_ASSEMBLER_H__ */ --- a/arch/arm/lib/getuser.S +++ b/arch/arm/lib/getuser.S @@ -38,6 +38,7 @@ ENTRY(__get_user_1) mov r0, #0 ret lr ENDPROC(__get_user_1) +_ASM_NOKPROBE(__get_user_1) ENTRY(__get_user_2) check_uaccess r0, 2, r1, r2, __get_user_bad @@ -58,6 +59,7 @@ rb .req r0 mov r0, #0 ret lr ENDPROC(__get_user_2) +_ASM_NOKPROBE(__get_user_2) ENTRY(__get_user_4) check_uaccess r0, 4, r1, r2, __get_user_bad @@ -65,6 +67,7 @@ ENTRY(__get_user_4) mov r0, #0 ret lr ENDPROC(__get_user_4) +_ASM_NOKPROBE(__get_user_4) ENTRY(__get_user_8) check_uaccess r0, 8, r1, r2, __get_user_bad8 @@ -78,6 +81,7 @@ ENTRY(__get_user_8) mov r0, #0 ret lr ENDPROC(__get_user_8) +_ASM_NOKPROBE(__get_user_8) #ifdef __ARMEB__ ENTRY(__get_user_32t_8) @@ -91,6 +95,7 @@ ENTRY(__get_user_32t_8) mov r0, #0 ret lr ENDPROC(__get_user_32t_8) +_ASM_NOKPROBE(__get_user_32t_8) ENTRY(__get_user_64t_1) check_uaccess r0, 1, r1, r2, __get_user_bad8 @@ -98,6 +103,7 @@ ENTRY(__get_user_64t_1) mov r0, #0 ret lr ENDPROC(__get_user_64t_1) +_ASM_NOKPROBE(__get_user_64t_1) ENTRY(__get_user_64t_2) check_uaccess r0, 2, r1, r2, __get_user_bad8 @@ -114,6 +120,7 @@ rb .req r0 mov r0, #0 ret lr ENDPROC(__get_user_64t_2) +_ASM_NOKPROBE(__get_user_64t_2) ENTRY(__get_user_64t_4) check_uaccess r0, 4, r1, r2, __get_user_bad8 @@ -121,6 +128,7 @@ ENTRY(__get_user_64t_4) mov r0, #0 ret lr ENDPROC(__get_user_64t_4) +_ASM_NOKPROBE(__get_user_64t_4) #endif __get_user_bad8: @@ -131,6 +139,8 @@ __get_user_bad: ret lr ENDPROC(__get_user_bad) ENDPROC(__get_user_bad8) +_ASM_NOKPROBE(__get_user_bad) +_ASM_NOKPROBE(__get_user_bad8) .pushsection __ex_table, "a" .long 1b, __get_user_bad