mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@kernel.org>
To: "Hans Zhang" <18255117159@163.com>, "Keith Busch" <kbusch@kernel.org>
Cc: "Gerd Bayer" <gbayer@linux.ibm.com>,
	"Manivannan Sadhasivam" <mani@kernel.org>,
	"Hans Zhang" <hans.zhang@cixtech.com>,
	"Bjorn Helgaas" <helgaas@kernel.org>,
	bhelgaas@google.com, "Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	jingoohan1@gmail.com,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-next <linux-next@vger.kernel.org>,
	linux-pci@vger.kernel.org,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Niklas Schnelle" <schnelle@linux.ibm.com>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>
Subject: Re: [PATCH] PCI: Fix endianness issues in pci_bus_read_config()
Date: Sat, 02 Aug 2025 17:40:28 +0200	[thread overview]
Message-ID: <07739ab9-4e34-430c-ac1d-d1f370baccea@app.fastmail.com> (raw)
In-Reply-To: <d2240ab0-5d91-4b41-945f-e29b40f7b7f4@163.com>

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

  reply	other threads:[~2025-08-02 15:41 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-16 16:11 [PATCH v14 0/7] Refactor capability search into common macros Hans Zhang
2025-07-16 16:11 ` [PATCH v14 1/7] PCI: Introduce generic bus config read helper function Hans Zhang
2025-07-16 16:11 ` [PATCH v14 2/7] PCI: Clean up __pci_find_next_cap_ttl() readability Hans Zhang
2025-07-16 16:11 ` [PATCH v14 3/7] PCI: Refactor standard capability search into common macro Hans Zhang
2025-07-16 16:12 ` [PATCH v14 4/7] PCI: Refactor extended " Hans Zhang
2025-07-16 16:12 ` [PATCH v14 5/7] PCI: dwc: Use common PCI host bridge APIs for finding the capabilities Hans Zhang
2025-07-16 16:12 ` [PATCH v14 6/7] PCI: cadence: " Hans Zhang
2025-07-16 16:12 ` [PATCH v14 7/7] PCI: cadence: Use cdns_pcie_find_*capability to avoid hardcode Hans Zhang
2025-07-16 23:11 ` [PATCH v14 0/7] Refactor capability search into common macros Bjorn Helgaas
2025-07-31  7:32   ` [REGRESSION] next/master: suspect endianness issue in common PCI capability search macro Gerd Bayer
2025-07-31 17:38     ` [PATCH] PCI: Fix endianness issues in pci_bus_read_config() Gerd Bayer
2025-07-31 18:39       ` Bjorn Helgaas
2025-07-31 19:01         ` Arnd Bergmann
2025-08-01  8:18           ` Manivannan Sadhasivam
2025-08-01  9:25             ` Hans Zhang
2025-08-01  9:47               ` Manivannan Sadhasivam
2025-08-01 10:06                 ` Hans Zhang
2025-08-01 10:54                   ` Manivannan Sadhasivam
2025-08-01 11:30                     ` Gerd Bayer
2025-08-01 16:54                       ` Hans Zhang
2025-08-01 18:08                         ` Keith Busch
2025-08-02 15:23                           ` Hans Zhang
2025-08-02 15:40                             ` Arnd Bergmann [this message]
2025-08-04  3:06                       ` Hans Zhang
2025-08-04  8:03                         ` Arnd Bergmann
2025-08-04  8:25                           ` Hans Zhang
2025-08-04 10:09                         ` Gerd Bayer
2025-08-12 14:44                           ` Hans Zhang
2025-08-13  7:47                             ` Niklas Schnelle
2025-08-13  7:50                               ` Hans Zhang
2025-08-04 14:33                         ` Bjorn Helgaas
2025-08-04 15:04                           ` Hans Zhang
2025-08-01 16:47                     ` Hans Zhang
2025-07-31 18:53       ` Lukas Wunner
2025-08-01  7:52       ` Geert Uytterhoeven
2025-08-01 13:00   ` [PATCH v14 0/7] Refactor capability search into common macros Bjorn Helgaas

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=07739ab9-4e34-430c-ac1d-d1f370baccea@app.fastmail.com \
    --to=arnd@kernel.org \
    --cc=18255117159@163.com \
    --cc=agordeev@linux.ibm.com \
    --cc=bhelgaas@google.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gbayer@linux.ibm.com \
    --cc=geert@linux-m68k.org \
    --cc=hans.zhang@cixtech.com \
    --cc=helgaas@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jingoohan1@gmail.com \
    --cc=kbusch@kernel.org \
    --cc=kwilczynski@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mani@kernel.org \
    --cc=robh@kernel.org \
    --cc=schnelle@linux.ibm.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

all inboxes | Powered by JetHome®