Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2039361imm; Thu, 24 May 2018 04:58:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrsEeAcbbUaX9327+8btvLBHuLvQgTKQcX5W58YH+qBF7/41jiSSu1Bcd6kD26ErWqXoY1K X-Received: by 2002:a62:1a4e:: with SMTP id a75-v6mr6925781pfa.84.1527163107144; Thu, 24 May 2018 04:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163107; cv=none; d=google.com; s=arc-20160816; b=llM5ykkSM3v1TPCf/9EuE7zIo5sNQ45pBLO0BNGPgpqCtO7LDPABpFxDh+8XM7ski4 ZUB0Fp+WE89QZIGt+36LOblT8DK4yOVPVBaKLqOt0V4c66d9kYfP0VrdKkT0HzXJ3Bzf AjgAPlCP8IdB/EIxso64zcMHfDHEAZoZuaY+Z/LqA9OO0Jx4lmHP9vqQOThDvStdX9Xx Yxs0fV9pDnFF2zioh+uFerCHHFnDZ2BYyRCUx7pZ7UmPHDMeozwnBCsWBId+CFKPiO1E rLYXThg0d0UpiYkgL+OceNlJlKbikfbVma05oT5Qkvz2y4tP0XZBjiMliw0MDF58PtJt pjUQ== 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=2gs+vtUz/tFGDvpbB9niHl5oeOkLhviokCPj2QqpaJ8=; b=qKW3PFEXKSS9HNKPQzNsQ2HIflJemSa/wrtwsXBMlz5MHVcEKbfmtYrLndZlm1mivC 7XDFKSI2VSwdj0d/ZHjJCP8qBeyDE4pQBBy8hF+89MouYLvQeurfcJs6mYaSXbHWFReu tXh/1MG1PUIy6DGJcv/t6PYUftPCevAJyk5uGytCF6KXXDpH5MQxeFLhoVthWXz/iXpm c8lU9AM9nRWJpTS7afRqRAqC9KDFDmwmgFDpfeV/S2vbh7dRfcL1i3wVfN77Wi2kJ6pX zQpkbnF/NjK486J+zaVwrP5NuZCi2LezcMxsYvE9mdtrpgoaDHkvHX6RNV7PbVwLHvQ6 xvgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XoCHJEcD; 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 a23-v6si20504369pfe.364.2018.05.24.04.58.12; Thu, 24 May 2018 04:58:27 -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=XoCHJEcD; 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 S969464AbeEXL5f (ORCPT + 99 others); Thu, 24 May 2018 07:57:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:56752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966806AbeEXJpe (ORCPT ); Thu, 24 May 2018 05:45:34 -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 CF09D20897; Thu, 24 May 2018 09:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155134; bh=Crh2oWA3uYI0JbnaWSebvnbxJsLTcIFgkApiNNaS6NI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XoCHJEcDN3hpzUr6O0KkyhT+lGIvW4OTngH0trE4M3x0Z8PQTJBX8hybv60HeOjDu AvwxIQpMu6zsoJgVZmjXyDorpyPg2MTMjYjOIJQ0dQ7z5UAxWEHJf0k10/NPWDmZK6 F2EfLKanBWL68ZFZ3RSw8HVaaxojQosE4Cpui/TA= 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.4 67/92] ARM: 8772/1: kprobes: Prohibit kprobes on get_user functions Date: Thu, 24 May 2018 11:38:44 +0200 Message-Id: <20180524093205.725821745@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@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.4-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 @@ -530,4 +530,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