Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8247223imu; Tue, 4 Dec 2018 05:30:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/Up65BNOkNTxPZLqIrULYONfHmT1CXi444DME5m1Bbdz11hKwgys4h0gLjJkqV6hlhQMJHK X-Received: by 2002:a63:9e58:: with SMTP id r24mr17247133pgo.264.1543930230787; Tue, 04 Dec 2018 05:30:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543930230; cv=none; d=google.com; s=arc-20160816; b=aXg6KxLk976jM2x4pyJn7nZcwQtSdEq3rsSDpU8S5mzvckaaj3atpdiBc465YY7jVu Acb2ovzQcdzz4+FGtP4tNlUjFqv9lweXJwrXKcNlQt+r2YWkMwbw7gnVnGGxBm9x+0cF Ea0wx8b6R6H29XbhUFs/JxayQtl3ymWmDWevJVuOP3vRLxoXZBpi7C5KloYP/+2aqoI1 Rz6kyIamICeb+X644MpcYQbwGNNsJaKPf+YlD3vVGl/ru2KII0AxPiZ8D7SQFIKNA0qu O+McZvtikPuCUDuVjhfbjaJRyLZk/gR7+PngCJHXmuexyiQzfgOaIaMAjldNWIzcIYI+ AN6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=l/NqMlMJK6NCuID2vd75UkjcijsChz0PXtxpAkinb6A=; b=d8qymnhew2941rJqhRGJ2bjvt072K/+SjHQpdFeEjVGyiJXZRgz2IWPml9fJk/W87c ajt9RkrBaNyZgY6rWvDcNoHdGkvn/t3MnRzEI1aIrbMd/zpsY9vo+TU+xYqGxlfzkCBW JZoTxbocFo2gL8SMkZmcEhjpDcr5LKGS5JvYI+KMjVDyUOsPzNLaGXgbfSjWd7ShOJDh yjlei2Ibb+Xa80Y4Z3QoNtWuCrKZA1Z9v7clYiORh13wOYBLiN07bo+gdhvSc0rIwtPj kR3+oneN+6xVupnUZys+P1GI9WIWG+hirmo5AhfYd59QAD3AZnIRMHw9o1ldgb2fYw9d z0+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=Z3VQ61Cd; 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 n30si13123685pgb.406.2018.12.04.05.30.14; Tue, 04 Dec 2018 05:30:30 -0800 (PST) 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=@agner.ch header.s=dkim header.b=Z3VQ61Cd; 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 S1726377AbeLDN1i (ORCPT + 99 others); Tue, 4 Dec 2018 08:27:38 -0500 Received: from mail.kmu-office.ch ([178.209.48.109]:33624 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbeLDN1i (ORCPT ); Tue, 4 Dec 2018 08:27:38 -0500 Received: from trochilidae.toradex.int (unknown [46.140.72.82]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 841245C03A3; Tue, 4 Dec 2018 14:27:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1543930056; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=l/NqMlMJK6NCuID2vd75UkjcijsChz0PXtxpAkinb6A=; b=Z3VQ61CdqWFgxFzEkOjzTmIHpJ5Jv61kLXyp523WCTiAT2fVLCgnemUzqQIYMSf+Amqhfy 7wEWsStTzS9y4ABLxwtVEPxzx8FobRfn6j0WjCGSbwERljOgkaPhpkmtMJMzBQeRmP3o2Z 4QT3l+tHjscUfGZwK35zGspSrtLyZRE= From: Stefan Agner To: hongxing.zhu@nxp.com, l.stach@pengutronix.de Cc: robin.murphy@arm.com, tpiepho@impinj.com, linux@armlinux.org.uk, leonard.crestez@nxp.com, andrew.smirnov@gmail.com, festevam@gmail.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com, stefan@agner.ch, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] pci: imx6: avoid dereferencing program counter from user mode Date: Tue, 4 Dec 2018 14:27:32 +0100 Message-Id: <20181204132733.14422-1-stefan@agner.ch> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The custom fault handler is currently only meant to handle kernel mode bus faults. Exit in case the abort happened in user mode. Signed-off-by: Stefan Agner --- drivers/pci/controller/dwc/pci-imx6.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 69f86234f7c0..54a29e441303 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -270,8 +270,14 @@ static int imx6q_pcie_abort_handler(unsigned long addr, unsigned int fsr, struct pt_regs *regs) { unsigned long pc = instruction_pointer(regs); - unsigned long instr = *(unsigned long *)pc; - int reg = (instr >> 12) & 15; + unsigned long instr; + int reg; + + if (user_mode(regs)) + return 1; + + instr = *(unsigned long *)pc; + reg = (instr >> 12) & 15; /* * If the instruction being executed was a read, -- 2.19.1