[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <07739ab9-4e34-430c-ac1d-d1f370baccea@app.fastmail.com>
Date: Sat, 02 Aug 2025 17:40:28 +0200
From: "Arnd Bergmann" <arnd@...nel.org>
To: "Hans Zhang" <18255117159@....com>, "Keith Busch" <kbusch@...nel.org>
Cc: "Gerd Bayer" <gbayer@...ux.ibm.com>,
"Manivannan Sadhasivam" <mani@...nel.org>,
"Hans Zhang" <hans.zhang@...tech.com>, "Bjorn Helgaas" <helgaas@...nel.org>,
bhelgaas@...gle.com, "Alexander Gordeev" <agordeev@...ux.ibm.com>,
"Christian Borntraeger" <borntraeger@...ux.ibm.com>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
jingoohan1@...il.com,
Krzysztof Wilczyński <kwilczynski@...nel.org>,
linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org,
linux-next <linux-next@...r.kernel.org>, linux-pci@...r.kernel.org,
"Lorenzo Pieralisi" <lpieralisi@...nel.org>, "Rob Herring" <robh@...nel.org>,
"Niklas Schnelle" <schnelle@...ux.ibm.com>,
"Geert Uytterhoeven" <geert@...ux-m68k.org>
Subject: Re: [PATCH] PCI: Fix endianness issues in pci_bus_read_config()
On Sat, Aug 2, 2025, at 17:23, Hans Zhang wrote:
> On 2025/8/2 02:08, Keith Busch wrote:
>> On Sat, Aug 02, 2025 at 12:54:27AM +0800, Hans Zhang wrote:
>>>
>>> *value = (type)data; \
>>>
>>> And this function. Could it be that I misunderstood something?
>>
>> The above macro retains the caller's type for "value". If the caller
>> passes a "u8 *", the value is deferenced as a u8.
>
> In this macro definition, bus->ops->read needs to ensure the byte order
> of the read, as Lukas mentioned; otherwise, there is also a big-endian
> issue at this location.
No, there is no endianness problem here, the problem with casting
the pointer type like
u32 *value;
*(type *)value = data;
or any variation of that is is that it only writes to the first
few bytes of *value, and that introduces both the observed endianess
problem and possibly worse uninitialized data usage or out-of-bounds
stack access.
Arnd
Powered by blists - more mailing lists