Linux Input/HID development
 help / color / mirror / Atom feed
From: Preetam Sundar Das <daspreetam4@gmail.com>
To: basavaraj.natikar@amd.com, jikos@kernel.org, bentiss@kernel.org
Cc: sandeep.singh@amd.com, Nehal-bakulchandra.Shah@amd.com,
	skhan@linuxfoundation.org, linux-input@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Preetam Sundar Das <daspreetam4@gmail.com>,
	syzbot+4eadd4dfe9e66522bae8@syzkaller.appspotmail.com
Subject: [PATCH] HID: amd_sfh: Validate BAR 2 as memory-mapped I/O in probe
Date: Sat, 15 Aug 2026 17:49:38 +0530	[thread overview]
Message-ID: <20260815121938.1337631-1-daspreetam4@gmail.com> (raw)

Syzbot reported a page fault in amd_mp2_pci_probe(). The fuzzer creates
a malicious PCI device where BAR 2 is defined as an I/O port rather
than a memory-mapped I/O (MMIO) region.

The driver previously assumed BAR 2 would always be MMIO and blindly
passed the I/O port address to readl(), causing a fatal page fault
when the CPU attempted to read from restricted memory.

Fix this by explicitly checking the PCI resource flags after waking
the device. If BAR 2 is not an IORESOURCE_MEM region, safely reject
the device with -EINVAL to prevent the panic.

Fixes: 4f567b9f8141 ("SFH: PCIe driver to add support of AMD sensor fusion hub")
Reported-by: syzbot+4eadd4dfe9e66522bae8@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?id=227a9acbe565367eb7a1277b47115df8706d9a12

Signed-off-by: Preetam Sundar Das <daspreetam4@gmail.com>
---
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index 4b81cebdc335..aef105a81570 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -451,6 +451,9 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	if (rc)
 		return rc;
 
+	if (!(pci_resource_flags(pdev, 2) & IORESOURCE_MEM))
+		return -EINVAL;
+
 	rc = pcim_iomap_regions(pdev, BIT(2), DRIVER_NAME);
 	if (rc)
 		return rc;
-- 
2.43.0


             reply	other threads:[~2026-08-15 12:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-15 12:19 Preetam Sundar Das [this message]
2026-08-15 12:30 ` [PATCH] HID: amd_sfh: Validate BAR 2 as memory-mapped I/O in probe sashiko-bot

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=20260815121938.1337631-1-daspreetam4@gmail.com \
    --to=daspreetam4@gmail.com \
    --cc=Nehal-bakulchandra.Shah@amd.com \
    --cc=basavaraj.natikar@amd.com \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sandeep.singh@amd.com \
    --cc=skhan@linuxfoundation.org \
    --cc=syzbot+4eadd4dfe9e66522bae8@syzkaller.appspotmail.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