Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 2a4188f

Browse files
Villemoesgregkh
authored andcommitted
PCI/AER: Avoid info leak in __print_tlp_header()
commit a1b7f2f upstream. Commit fab4c25 ("PCI/AER: Add a TLP header print helper") introduced the helper function __print_tlp_header(), but contrary to the intention, the behaviour did change: Since we're taking the address of the parameter t, the first 4 or 8 bytes printed will be the value of the pointer t itself, and the remaining 12 or 8 bytes will be who-knows-what (something from the stack). We want to show the values of the four members of the struct aer_header_log_regs; that can be done without ugly and error-prone casts. On little-endian this should produce the same output as originally intended, and since no-one has complained about getting garbage output so far, I think big-endian should be ok too. Fixes: fab4c25 ("PCI/AER: Add a TLP header print helper") Signed-off-by: Rasmus Villemoes <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Acked-by: Borislav Petkov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 613adac commit 2a4188f

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

drivers/pci/pcie/aer/aerdrv_errprint.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,8 @@ static const char *aer_agent_string[] = {
127127
static void __print_tlp_header(struct pci_dev *dev,
128128
struct aer_header_log_regs *t)
129129
{
130-
unsigned char *tlp = (unsigned char *)&t;
131-
132-
dev_err(&dev->dev, " TLP Header:"
133-
" %02x%02x%02x%02x %02x%02x%02x%02x"
134-
" %02x%02x%02x%02x %02x%02x%02x%02x\n",
135-
*(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
136-
*(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
137-
*(tlp + 11), *(tlp + 10), *(tlp + 9),
138-
*(tlp + 8), *(tlp + 15), *(tlp + 14),
139-
*(tlp + 13), *(tlp + 12));
130+
dev_err(&dev->dev, " TLP Header: %08x %08x %08x %08x\n",
131+
t->dw0, t->dw1, t->dw2, t->dw3);
140132
}
141133

142134
static void __aer_print_error(struct pci_dev *dev,

0 commit comments

Comments
 (0)