From: Bjorn Helgaas <helgaas@kernel.org>
To: Deepanshu Kartikey <kartikey406@gmail.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+7134530b25073b4ef373@syzkaller.appspotmail.com
Subject: Re: [PATCH] PCI: sysfs: Reject unaligned resource I/O port accesses
Date: Mon, 19 Oct 2026 17:40:15 -0500 [thread overview]
Message-ID: <20261019224015.GA2281064@bhelgaas> (raw)
In-Reply-To: <20260809045946.15638-1-kartikey406@gmail.com>
On Sun, Aug 09, 2026 at 10:29:46AM +0530, Deepanshu Kartikey wrote:
> pci_resource_io() validates that off+count stays within the BAR's
> range but never checks that the resulting port is aligned to the
> access size. A pwrite64()/pread64() on a resourceN file with an odd
> offset and count=2 or count=4 reaches outw()/outl() with a misaligned
> address. On arm64 this becomes a store/load to a Device-memory
> mapping (PCI_IOBASE + port), which architecturally requires natural
> alignment, causing an alignment fault and kernel oops.
>
> Reject misaligned accesses before they reach the low-level accessor.
>
> Reported-by: syzbot+7134530b25073b4ef373@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=7134530b25073b4ef373
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
Applied to pci/sysfs for v7.4, thanks!
Hopefully the last patch for v7.4.
> ---
> drivers/pci/pci-sysfs.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 5ec0b245a69b..72f0404a34e9 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -1175,6 +1175,9 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
> if (port + count - 1 > pci_resource_end(pdev, bar))
> return -EINVAL;
>
> + if (!IS_ALIGNED(port, count))
> + return -EINVAL;
> +
> switch (count) {
> case 1:
> if (write)
> --
> 2.43.0
>
prev parent reply other threads:[~2026-10-19 22:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 4:59 [PATCH] PCI: sysfs: Reject unaligned resource I/O port accesses Deepanshu Kartikey
2026-08-09 5:16 ` sashiko-bot
2026-08-09 7:16 ` Rihyeon Kim
2026-08-21 1:46 ` Deepanshu Kartikey
2026-08-21 16:42 ` Bjorn Helgaas
2026-09-10 11:31 ` Manivannan Sadhasivam
2026-09-23 3:35 ` Deepanshu Kartikey
2026-09-23 20:55 ` Bjorn Helgaas
2026-09-23 21:50 ` David Laight
2026-09-28 12:31 ` Deepanshu Kartikey
2026-10-15 11:40 ` Maciej W. Rozycki
2026-10-19 22:40 ` Bjorn Helgaas [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=20261019224015.GA2281064@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=kartikey406@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=syzbot+7134530b25073b4ef373@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.