The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Rihyeon Kim <rihyeon8648@gmail.com>
To: syzbot+7134530b25073b4ef373@syzkaller.appspotmail.com,
	bhelgaas@google.com, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [pci?] BUG: unable to handle kernel paging request in pci_resource_io
Date: Sun,  9 Aug 2026 10:28:55 +0900	[thread overview]
Message-ID: <20260809012855.109608-1-rihyeon8648@gmail.com> (raw)
In-Reply-To: <6a778f12.b50370da.49fe0.002d.GAE@google.com>

On Sat Aug 8, 2026 at 8:18 PM UTC, syzbot wrote:
> Unable to handle kernel paging request at virtual address ffffffffc0801001
>   FSC = 0x21: alignment fault
> pc : logic_outw+0x58/0x124 lib/logic_pio.c:305
>  pci_resource_io+0x1f4/0x3dc drivers/pci/pci-sysfs.c:1187

I'm interested in this one and had a look at it today.  I can reproduce
it here, with the same faulting address and the same ESR 0x96000061 as
the report.

It seems that pci_resource_io() validates the access width (1, 2 or 4
bytes) and the range against the BAR, but never checks that the port
itself is naturally aligned.  The port is the BAR start plus the sysfs
file offset, so a 2-byte write at an odd offset reaches outw() with an
odd port number.  arm64 has no separate I/O address space, so outw()
becomes the __raw_writew() to PCI_IOBASE + port that the report shows in
the pc line.  The pte in the report has AttrIndx 4, i.e.
MT_DEVICE_nGnRE, so that window is Device memory and the unaligned store
faults.

The registers in the report seem to agree.  x22 and x23 are 0x1001 and
0x101f, which is an offset of 1 into a 32-byte I/O BAR at 0x1000, and
x21 is 0xffbfff, i.e. MMIO_UPPER_LIMIT, so logic_outw() took the _outw()
branch rather than the indirect PIO one.  PCI_IOBASE is 0xffffffffc0800000
there, and adding the 0x1001 port gives the faulting address exactly.

The read path goes through the same helper, and an unaligned pread()
faults the same way in inw().  If anything it is easier to reach, since
pci_read_resource() has no security_locked_down() check.

If I'm reading this correctly, rejecting accesses whose port is not
naturally aligned for the width should be enough, and it would not
affect any aligned access that works today.
I will prepare a patch.

Thanks,
Rihyeon Kim

  reply	other threads:[~2026-08-09  1:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08 20:18 [syzbot] [pci?] BUG: unable to handle kernel paging request in pci_resource_io syzbot
2026-08-09  1:28 ` Rihyeon Kim [this message]
2026-08-09  4:44 ` Forwarded: " syzbot
     [not found] <20260809044355.7856-1-rihyeon8648@gmail.com>
2026-08-09  6:30 ` syzbot

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=20260809012855.109608-1-rihyeon8648@gmail.com \
    --to=rihyeon8648@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=syzbot+7134530b25073b4ef373@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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