From: Lucas Stach <l.stach@pengutronix.de>
To: "Francesco Dolcini" <francesco.dolcini@toradex.com>,
"Richard Zhu" <hongxing.zhu@nxp.com>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"NXP Linux Team" <linux-imx@nxp.com>,
"Jason Liu" <jason.hui.liu@nxp.com>
Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
Shawn Guo <shawnguo@kernel.org>
Subject: Re: [RFC PATCH] PCI: imx6: Handle the abort from user-space
Date: Fri, 28 Jan 2022 10:07:58 +0100 [thread overview]
Message-ID: <dd30b476f0378a4ae4639ffff635e55093bd070c.camel@pengutronix.de> (raw)
In-Reply-To: <20220128082920.591115-1-francesco.dolcini@toradex.com>
Am Freitag, dem 28.01.2022 um 09:29 +0100 schrieb Francesco Dolcini:
> From: Jason Liu <jason.hui.liu@nxp.com>
>
> The driver install one hook to handle the external abort, but issue
> is that if the abort introduced from user space code, the following
> code unsigned long instr = *(unsigned long *)pc; which will created
> another data-abort(page domain fault) if CONFIG_CPU_SW_DOMAIN_PAN.
>
> The patch does not intent to use copy_from_user and then do the hack
> due to the security consideration. In fact, we can just return and
> report the external abort to user-space.
>
I'm not sure how userspace would be able to trigger this abort. Maybe
invalid access to a device cfg space via sysfs?
However the patch seems to do the right thing in that case.
Acked-by: Lucas Stach <l.stach@pengutronix.de>
> Signed-off-by: Jason Liu <jason.hui.liu@nxp.com>
> Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
> ---
> We have this patch from NXP downstream kernel [1] in our kernel branch [2]
> since a long time, to me it would make sense to upstream it. Any concern?
>
> [1] https://source.codeaurora.org/external/imxsupport/linux-imx/commit/?id=62dfb2fb953463dd1b6710567c9e174672a98f24
> [2] https://git.toradex.com/cgit/linux-toradex.git/commit/?id=2b42547cf659f979be2defdff6a99f921b33d0f1
> ---
> drivers/pci/controller/dwc/pci-imx6.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 6974bd5aa116..6b178a29e253 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -27,6 +27,7 @@
> #include <linux/resource.h>
> #include <linux/signal.h>
> #include <linux/types.h>
> +#include <linux/uaccess.h>
> #include <linux/interrupt.h>
> #include <linux/reset.h>
> #include <linux/phy/phy.h>
> @@ -297,8 +298,15 @@ 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 the abort from user-space, just return and report it */
> + if (user_mode(regs))
> + return 1;
> +
> + instr = *(unsigned long *)pc;
> + reg = (instr >> 12) & 15;
>
> /*
> * If the instruction being executed was a read,
next prev parent reply other threads:[~2022-01-28 9:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 8:29 [RFC PATCH] PCI: imx6: Handle the abort from user-space Francesco Dolcini
2022-01-28 9:07 ` Lucas Stach [this message]
2022-01-28 9:25 ` Hongxing Zhu
2022-01-28 10:18 ` (EXT) " Alexander Stein
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd30b476f0378a4ae4639ffff635e55093bd070c.camel@pengutronix.de \
--to=l.stach@pengutronix.de \
--cc=bhelgaas@google.com \
--cc=festevam@gmail.com \
--cc=francesco.dolcini@toradex.com \
--cc=hongxing.zhu@nxp.com \
--cc=jason.hui.liu@nxp.com \
--cc=kernel@pengutronix.de \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).