Received: by 10.192.165.156 with SMTP id m28csp1083839imm; Wed, 11 Apr 2018 12:06:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx49arM2i578xgaMLARDMcVcwdjSsxyR8bARj7qmQaifkWc5ophUrRyyLWA0KYzRW30K4KQRr X-Received: by 10.98.220.218 with SMTP id c87mr5115730pfl.198.1523473600957; Wed, 11 Apr 2018 12:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523473600; cv=none; d=google.com; s=arc-20160816; b=HON6yPTCn6eGioJuIb/bPl3UNQIIAwaDfbIs4EQY2Nhhzg2rnve31X1RIiXp9lzX3p yuLOVAkrmPFDkC7AcGRJkyuWfJbo3vLiQd+lvbDvjEWDNTp9+WQpEfqnpEth5uH5Vk32 Af/Tcjuk0tv8t8I7Jv5V51Blw0b3xTszn48e5PZwT5dZJeKSovp8mGe36VEgn1r583tz 4xNmISncjN8TyzaaQJ/hSoQKrG4otX7GiNcLM4E8d2ktU7M5DOhwMTO5NrPnV1krFE3L 7xFp+FyYL/4HwVyEk9sVRNREsV99ALi+JOozoLW4WMyCf94SSumvJqavbRA2MwIWfVW6 yF6g== 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 :arc-authentication-results; bh=SUj5NZ6HG/IyVxE46WEEC9AMDTCpznZramJeCHqfIbA=; b=Ay8mUnK840vuLybcC9+2e+RfIeLQLBzEzoItMv2nuSdxeCxYkHtZitakSwpIy5lwgs j3yqS3uYBmv1JWx6eqvjDTlNJ4qW+HcJyPXnt6mEDFPjXo2dZib4IKEy2FhXmlNa0h6X 6jKoadKG9Cunr2AN2ck6NAbeRnAX14Txqo4TddX8flc0hCFJ60meqck4/Ug9AmFu0LFW OrFbVX53WT6t0ObNiH52xvhYsv3/1ltEwFQNoDXEtnO9YFhA1wsAMrU8j2R5aG1J8w3g F7RmSx82Cv7U896COsMRGN+Jsk4+OzIr6Ey3svXzdMVIOWqQ/lCOVbmbzdbgCaBMTMWf 2SBg== ARC-Authentication-Results: i=1; mx.google.com; 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 l4-v6si1663656plb.741.2018.04.11.12.06.04; Wed, 11 Apr 2018 12:06:40 -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; 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 S934537AbeDKTCn (ORCPT + 99 others); Wed, 11 Apr 2018 15:02:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38614 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933692AbeDKTCj (ORCPT ); Wed, 11 Apr 2018 15:02:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3179BDAC; Wed, 11 Apr 2018 19:02:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marcin Nowakowski , linux-mips@linux-mips.org, Ralf Baechle , Sasha Levin Subject: [PATCH 4.9 220/310] MIPS: kprobes: flush_insn_slot should flush only if probe initialised Date: Wed, 11 Apr 2018 20:35:59 +0200 Message-Id: <20180411183632.010909466@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marcin Nowakowski [ Upstream commit 698b851073ddf5a894910d63ca04605e0473414e ] When ftrace is used with kprobes, it is possible for a kprobe to contain an invalid location (ie. only initialised to 0 and not to a specific location in the code). Trying to perform a cache flush on such location leads to a crash r4k_flush_icache_range(). Fixes: c1bf207d6ee1 ("MIPS: kprobe: Add support.") Signed-off-by: Marcin Nowakowski Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/16296/ Signed-off-by: Ralf Baechle Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/mips/include/asm/kprobes.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/mips/include/asm/kprobes.h +++ b/arch/mips/include/asm/kprobes.h @@ -40,7 +40,8 @@ typedef union mips_instruction kprobe_op #define flush_insn_slot(p) \ do { \ - flush_icache_range((unsigned long)p->addr, \ + if (p->addr) \ + flush_icache_range((unsigned long)p->addr, \ (unsigned long)p->addr + \ (MAX_INSN_SIZE * sizeof(kprobe_opcode_t))); \ } while (0)