Re: [PATCH] PCI: sysfs: Reject unaligned resource I/O port accesses

From: Maciej W. Rozycki

Date: Thu Oct 15 2026 - 07:43:42 EST


On Mon, 28 Sep 2026, Deepanshu Kartikey wrote:

> > > What do you think of the sashiko comments:
> > > https://lore.kernel.org/all/20260809051652.36BA31F000E9@xxxxxxxxxxxxxxx?
> > >
> >
> > You could just add 'if (port & 1) return -EINVAL;' to the 'case 2:' branch,
> > and a similar '& 3' to the 'case 4:' one.
> >
> > Did it miss that loff_t is (probably) 64bit on 32bit?
> > Or do large offsets get detected earlier?
>
> Thanks David for the suggestion. I have send patch v2

FWIW it seems like overengineering to me and obfuscating the intent. The
call to IS_ALIGNED will correctly reject unaligned addresses for correct
values of `count' and incorrect values of `count' will then be rejected by
falling through the `switch' statement. Also I expect extra machine code
produced with the individual checks.

Maciej