* [PATCH] dmaengine: at_xdmac: Fixed printk format specifier when printing driver information.
@ 2025-03-28 10:56 Alexander Shiyan
2025-04-02 13:42 ` Nathan Lynch
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Shiyan @ 2025-03-28 10:56 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Ludovic Desroches, Vinod Koul, dmaengine, Alexander Shiyan
Use the correct printk specifier to print the address, otherwise
you get weird information:
at_xdmac f0010000.dma-controller: 16 channels, mapped at 0x(ptrval)
at_xdmac f0004000.dma-controller: 16 channels, mapped at 0x(ptrval)
After the change, the information looks much more informative:
at_xdmac f0010000.dma-controller: 16 channels, mapped at 0xc8892000
at_xdmac f0004000.dma-controller: 16 channels, mapped at 0xc8894000
Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
---
drivers/dma/at_xdmac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index ba25c23164e7..a4188046804d 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -2409,7 +2409,7 @@ static int at_xdmac_probe(struct platform_device *pdev)
goto err_dma_unregister;
}
- dev_info(&pdev->dev, "%d channels, mapped at 0x%p\n",
+ dev_info(&pdev->dev, "%d channels, mapped at 0x%px\n",
nr_channels, atxdmac->regs);
at_xdmac_axi_config(pdev);
--
2.39.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dmaengine: at_xdmac: Fixed printk format specifier when printing driver information.
2025-03-28 10:56 [PATCH] dmaengine: at_xdmac: Fixed printk format specifier when printing driver information Alexander Shiyan
@ 2025-04-02 13:42 ` Nathan Lynch
0 siblings, 0 replies; 2+ messages in thread
From: Nathan Lynch @ 2025-04-02 13:42 UTC (permalink / raw)
To: Alexander Shiyan, linux-arm-kernel
Cc: Ludovic Desroches, Vinod Koul, dmaengine, Alexander Shiyan
Hi Alexander,
Alexander Shiyan <eagle.alexander923@gmail.com> writes:
> Use the correct printk specifier to print the address, otherwise
> you get weird information:
> at_xdmac f0010000.dma-controller: 16 channels, mapped at 0x(ptrval)
> at_xdmac f0004000.dma-controller: 16 channels, mapped at 0x(ptrval)
>
> After the change, the information looks much more informative:
> at_xdmac f0010000.dma-controller: 16 channels, mapped at 0xc8892000
> at_xdmac f0004000.dma-controller: 16 channels, mapped at 0xc8894000
>
...
> --- a/drivers/dma/at_xdmac.c
> +++ b/drivers/dma/at_xdmac.c
> @@ -2409,7 +2409,7 @@ static int at_xdmac_probe(struct platform_device *pdev)
> goto err_dma_unregister;
> }
>
> - dev_info(&pdev->dev, "%d channels, mapped at 0x%p\n",
> + dev_info(&pdev->dev, "%d channels, mapped at 0x%px\n",
> nr_channels, atxdmac->regs);
dev_info (i.e. printk) obfuscates kernel pointers by design. This change
would defeat that.
Please refer to the discussion of pointers in
Documentation/core-api/printk-formats.rst for an explanation of the
"(ptrval)" behavior and whether it's appropriate to use %px here:
Before using %px, consider if using %p is sufficient together with
enabling the 'no_hash_pointers' kernel parameter during debugging
sessions.
As well as related discussion in Documentation/process/deprecated.rst:
%p format specifier
-------------------
Traditionally, using "%p" in format strings would lead to regular address
exposure flaws in dmesg, proc, sysfs, etc. Instead of leaving these to
be exploitable, all "%p" uses in the kernel are being printed as a hashed
value, rendering them unusable for addressing. New uses of "%p" should not
be added to the kernel. For text addresses, using "%pS" is likely better,
as it produces the more useful symbol name instead. For nearly everything
else, just do not add "%p" at all.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-02 13:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-28 10:56 [PATCH] dmaengine: at_xdmac: Fixed printk format specifier when printing driver information Alexander Shiyan
2025-04-02 13:42 ` Nathan Lynch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).