Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1597510imj; Fri, 8 Feb 2019 04:15:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IbG5QqMbFwVeRXAri2oLM97n2roM+nt8tHK+TSrg9s9ZCakwVrLrN18ImSUYToKVGVOI1dD X-Received: by 2002:a62:f5da:: with SMTP id b87mr22237930pfm.253.1549628133435; Fri, 08 Feb 2019 04:15:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549628133; cv=none; d=google.com; s=arc-20160816; b=vbn8JEEr4DhLuTPGXr5iaIEy8HCDNganrjXjOB99wC75LAHXPYxjM0sRx8vNg0o/Gl NKShcW9zbkPOieEpFl30ILvECgU2NjSi9PUDaLDeTg/hzTv/6O029utjwYwI+H+6yLKg GyeAvGtPz0DfMHxfwckX6mA3hXJc03mx0Q+ArKUTI4E77tipxD1H5cIZSjfovVjGzxKr tpT7vkX8KQ7MlY6s/ucJZdGpdFQ9iUHwy5NUPVknhtbNnKNGQWxr+/tVoIOzCOMknDjx mg/pSnhGS1I7ByyjY1+6Q8ymR39vAoQJIOwbe500d36m96i/vrT0TIjAgpvWFVrR7wXv 02ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=foHBOrirH+QLo8YbrGGiOKYiiBg79QEdMrVccX6Whgk=; b=r8wr82V/TLAVKCt0zysX7SvMb7ShNqylbW+70LNK9Mv/6zQPpWqQZxJuQrzJz9EScX reeMM+sT1RC3TvU5+lTU0+yY43hYkhuTv8Ei5l8jpbptusIRr1dtwkYypTQCuleKlosh 2q6gpJR0bFYUPoFgYT/ajJxLxlSJ00NmySQ0hNNHpmYaH/4eA+Qc6h/3lWCCBQaYroo+ sJeo70i97L2FRIz1u4irGDhwhP1a7aAcUF6F3gUfQ0w3rtysvErNbfYBAoQ/7fla1pED IbKDmIgBWXn39DOdD3zttkm3l86oE6kVcIXJPgkeHEPXdHBve0TBaxUsiXz6b0E/KozE KYuQ== 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 f4si1926993pgo.41.2019.02.08.04.15.16; Fri, 08 Feb 2019 04:15:33 -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 S1726747AbfBHMNr (ORCPT + 99 others); Fri, 8 Feb 2019 07:13:47 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49932 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbfBHMNr (ORCPT ); Fri, 8 Feb 2019 07:13:47 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0B1C21596; Fri, 8 Feb 2019 04:13:47 -0800 (PST) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.197.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C831D3F719; Fri, 8 Feb 2019 04:13:44 -0800 (PST) Date: Fri, 8 Feb 2019 12:13:41 +0000 From: Lorenzo Pieralisi To: Stefan Agner Cc: hongxing.zhu@nxp.com, l.stach@pengutronix.de, robin.murphy@arm.com, tpiepho@impinj.com, linux@armlinux.org.uk, leonard.crestez@nxp.com, andrew.smirnov@gmail.com, festevam@gmail.com, bhelgaas@google.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] pci: imx6: avoid dereferencing program counter from user mode Message-ID: <20190208121341.GD13009@e107981-ln.cambridge.arm.com> References: <20181204132733.14422-1-stefan@agner.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181204132733.14422-1-stefan@agner.ch> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 04, 2018 at 02:27:32PM +0100, Stefan Agner wrote: > 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(-) If this series is still aimed at mainline I need Lucas' ACK to merge it. Lorenzo > 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 >