Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3023863imj; Mon, 11 Feb 2019 12:29:14 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib1IYO9x7hGaST3yYmCJCT+OIeAkEqjszK5egSyx8pvwwwuSYOH5POr7+sQCQWPMJukIp56 X-Received: by 2002:a62:3811:: with SMTP id f17mr69078pfa.206.1549916954832; Mon, 11 Feb 2019 12:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549916954; cv=none; d=google.com; s=arc-20160816; b=QCYhFxkTrmOKypqcAkqfMmNSQNzme59OjLXZUoOBvimV2omlfjBwDbPlGboE+3QUXy h7SiYCyqM+O0YaxcyTqWDLblwyHwVck5d1CGZqgWb+Y7qYnk6UASBWqYjUaxTq5E/58C Irt4GeGl5+vIEqgyFhNd1EeRA9nCphjkKJJ42+dvJ+Bzh9uxTxW/H/59JdEsaDs8ZSUa 95oqsoWrrlVxNc5jmr7GU4HcffVFoGhSDWJoMOvhC/RvOuhm3PX6zAHz+HnxJcbpnOJ2 QkpmmRtc7VsRuGtBkyy++yRacjMsGiUkls5+Dy4hioqKPJNUuvxDVzYnmYlXFDry1zpy kg3g== 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 :references:in-reply-to:date:cc:to:from:subject:message-id; bh=sfgN20xv8C/RIzYjiKEGuQVrIArEelgioZJ/ror6/VQ=; b=OqjXyTMeXsRvouuSllWD5Lq6zOBGjLNBJZ5wkN5wufr/Ksn/G5t85RqA9n4BqhRoZl 6u/Sn89ao2nRfHfx+EnJtfOB8fZ3GOurK6CsLGylUdNxU3bq1DTUd45L0bpbjtB4nISH sER/M7sQ/qwUpSNYL/H311p/jlwPmDOmjPGmFg4VStYJlmP9TMIUQjvDw7uH8Kup9RdU d0rsWdg/7+H7VxXH91hSyQRErbTKsUI6f3QzdpJw9qwLWrifQ153gLHgWqQ3MfFtnatK 4j5ZIlCL+aA3OrZ+l8q+BH9170prTPdiM/ZPMR5c6euHwWge6Nz9aZQxtSPySfuodSK4 jXSQ== 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 q86si9838347pfi.59.2019.02.11.12.28.59; Mon, 11 Feb 2019 12:29:14 -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; 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 S1727828AbfBKQ4S (ORCPT + 99 others); Mon, 11 Feb 2019 11:56:18 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:52011 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbfBKQ4S (ORCPT ); Mon, 11 Feb 2019 11:56:18 -0500 Received: from kresse.hi.pengutronix.de ([2001:67c:670:100:1d::2a]) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1gtEsI-0001OV-SV; Mon, 11 Feb 2019 17:56:06 +0100 Message-ID: <1549904165.2546.14.camel@pengutronix.de> Subject: Re: [PATCH v2 1/2] pci: imx6: avoid dereferencing program counter from user mode From: Lucas Stach To: Stefan Agner , hongxing.zhu@nxp.com 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, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Mon, 11 Feb 2019 17:56:05 +0100 In-Reply-To: <20181204132733.14422-1-stefan@agner.ch> References: <20181204132733.14422-1-stefan@agner.ch> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::2a X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Dienstag, den 04.12.2018, 14:27 +0100 schrieb Stefan Agner: > 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 Reviewed-by: Lucas Stach > --- >  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,