From: Daniel Baluta <daniel.baluta@oss.nxp.com>
To: Stefan Ghetu <stefan.ghetu@nxp.com>, linux-pci@vger.kernel.org
Cc: imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Richard Zhu" <hongxing.zhu@nxp.com>,
"Lucas Stach" <l.stach@pengutronix.de>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Sahil Malhotra" <sahil.malhotra@nxp.com>
Subject: Re: [PATCH] PCI: imx6: Fix kernel oops on user-mode external aborts
Date: Tue, 24 Nov 2026 15:23:43 +0200 [thread overview]
Message-ID: <df17c9d7-8ca4-4f51-98ae-5ba4c0f7e406@oss.nxp.com> (raw)
In-Reply-To: <20261124131432.695946-1-stefan.ghetu@nxp.com>
On 11/24/26 15:14, Stefan Ghetu wrote:
> From: Richard Zhu <hongxing.zhu@nxp.com>
>
> When a user-space process (e.g., memtool) accesses an OP-TEE protected
> memory region, the SoC raises an external abort (FSR code 8). The
> imx6q_pcie_abort_handler() registered for this fault code attempts to
> decode the faulting instruction by directly dereferencing the saved PC:
>
> unsigned long instr = *(unsigned long *)pc;
>
> However, for user-mode aborts, the PC points to user-space memory. This
> unchecked dereference from kernel mode triggers a secondary domain fault,
> which is not hooked by any handler. The fault then escalates to an
> "Internal error: Oops" and crashes the kernel:
>
> Unhandled fault: page domain fault (0x01b) at 0x006e3316
> Internal error: : 1b [#1] SMP ARM
> CPU: 0 UID: 0 PID: 1415 Comm: memtool
> PC is at imx6q_pcie_abort_handler+0x4/0x7c
> LR is at do_DataAbort+0x3c/0xb0
>
> The abort handler was designed only for kernel-mode PCIe configuration or
> I/O space accesses and never hardened for user-mode faults.
>
> Fix this by:
>
> 1. Checking if the abort occurred in user mode and returning early to let
> the normal fault path deliver SIGBUS to the faulting task (as already
> specified in the hook_fault_code() registration).
>
> 2. Using get_kernel_nofault() to safely read the instruction for
> kernel-mode aborts, preventing recursive faults if the kernel PC is
> invalid.
>
> This ensures user-mode aborts are handled gracefully without crashing the
> kernel, while preserving the existing fixup behavior for legitimate
> kernel-mode PCIe access faults.
>
> Fixes: 415b6185c541 ("PCI: imx6: Fix config read timeout handling")
> Signed-off-by: Sahil Malhotra <sahil.malhotra@nxp.com>
> Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
> Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
prev parent reply other threads:[~2026-11-24 13:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 13:14 Stefan Ghetu
2026-11-24 13:23 ` Daniel Baluta [this message]
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=df17c9d7-8ca4-4f51-98ae-5ba4c0f7e406@oss.nxp.com \
--to=daniel.baluta@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=bhelgaas@google.com \
--cc=festevam@gmail.com \
--cc=hongxing.zhu@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=kwilczynski@kernel.org \
--cc=l.stach@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=sahil.malhotra@nxp.com \
--cc=stefan.ghetu@nxp.com \
/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
all inboxes | Powered by JetHome®