Re: [PATCH v3 1/2] ata: pata_falcon: fix IO base selection for Q40

Geert Uytterhoeven
2023-08-22T08:39:57Z

Hi Michael,

On Tue, Aug 22, 2023 at 10:27 AM Michael Schmitz <schmitzmic@gmail.com> wrote:
> Am 21.08.2023 um 19:50 schrieb Geert Uytterhoeven:
> >> + ap->ioaddr.data_addr = (void __iomem *)base_mem_res->start;
> >> +
> >> + if (base_res) { /* only Q40 has IO resources */
> >> + io_offset = 0x10000;
> >> + reg_scale = 1;
> >> + base = (void __iomem *)base_res->start;
> >> + ctl_base = (void __iomem *)ctl_res->start;
> >> +
> >> + ata_port_desc(ap, "cmd %pa ctl %pa",
> >> + &base_res->start,
> >> + &ctl_res->start);
> >
> > This can be moved outside the else, using %px to format base and
> > ctl_base.
>
> I get a checkpatch warning for %px, but not for %pa (used for .
> &ap->ioaddr.data_addr). What gives?
>
> WARNING: Using vsprintf specifier '%px' potentially exposes the kernel
> memory layout, if you don't really need the address please consider
> using '%p'.
> #148: FILE: drivers/ata/pata_falcon.c:194:
> + ata_port_desc(ap, "cmd %px ctl %px data %pa",
> + base, ctl_base, &ap->ioaddr.data_addr);

You can ignore this.
%p prints obfuscated pointer values, so they are useless here.
%px prints an unobfuscated pointer value, which is fine here, as it's
not a pointer to kernel memory that an attacker can use, but just the
virtual address of an I/O device mapped one-to-one.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds