linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/cma: change print format of pointer in pr_debug() With %p, the pointer will be hashed and print (____ptrval____) instead.
@ 2023-12-27  6:18 Xiaobing Luo
  2023-12-27  9:56 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaobing Luo @ 2023-12-27  6:18 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Xiaobing Luo, linux-mm, linux-kernel

 [    0.070467] cma: cma_alloc(cma (____ptrval____), count 256, align 8)
 [    0.073003] cma: cma_alloc(): returned (____ptrval____)

Use 0x%px instead of %p to print the pointer. Then the print will be like:

 [    0.054963] cma: cma_alloc(cma 0xffffffde9ad42a60, count 256, align 8)
 [    0.057385] cma: cma_alloc(): returned 0xfffffffe003b0000

Signed-off-by: Xiaobing Luo <luoxiaobing0926@gmail.com>
---
 mm/cma.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/cma.c b/mm/cma.c
index 2b2494fd6b59..4559f903df8f 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -440,7 +440,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
 	if (!cma || !cma->count || !cma->bitmap)
 		goto out;
 
-	pr_debug("%s(cma %p, name: %s, count %lu, align %d)\n", __func__,
+	pr_debug("%s(cma 0x%px, name: %s, count %lu, align %d)\n", __func__,
 		(void *)cma, cma->name, count, align);
 
 	if (!count)
@@ -487,7 +487,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
 		if (ret != -EBUSY)
 			break;
 
-		pr_debug("%s(): memory range at pfn 0x%lx %p is busy, retrying\n",
+		pr_debug("%s(): memory range at pfn 0x%lx 0x%px is busy, retrying\n",
 			 __func__, pfn, pfn_to_page(pfn));
 
 		trace_cma_alloc_busy_retry(cma->name, pfn, pfn_to_page(pfn),
@@ -514,7 +514,7 @@ struct page *cma_alloc(struct cma *cma, unsigned long count,
 		cma_debug_show_areas(cma);
 	}
 
-	pr_debug("%s(): returned %p\n", __func__, page);
+	pr_debug("%s(): returned 0x%px\n", __func__, page);
 out:
 	if (page) {
 		count_vm_event(CMA_ALLOC_SUCCESS);
@@ -539,7 +539,7 @@ bool cma_pages_valid(struct cma *cma, const struct page *pages,
 	pfn = page_to_pfn(pages);
 
 	if (pfn < cma->base_pfn || pfn >= cma->base_pfn + cma->count) {
-		pr_debug("%s(page %p, count %lu)\n", __func__,
+		pr_debug("%s(page 0x%px, count %lu)\n", __func__,
 						(void *)pages, count);
 		return false;
 	}
@@ -565,7 +565,7 @@ bool cma_release(struct cma *cma, const struct page *pages,
 	if (!cma_pages_valid(cma, pages, count))
 		return false;
 
-	pr_debug("%s(page %p, count %lu)\n", __func__, (void *)pages, count);
+	pr_debug("%s(page 0x%px, count %lu)\n", __func__, (void *)pages, count);
 
 	pfn = page_to_pfn(pages);
 
-- 
2.34.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/cma: change print format of pointer in pr_debug() With %p, the pointer will be hashed and print (____ptrval____) instead.
  2023-12-27  6:18 [PATCH] mm/cma: change print format of pointer in pr_debug() With %p, the pointer will be hashed and print (____ptrval____) instead Xiaobing Luo
@ 2023-12-27  9:56 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2023-12-27  9:56 UTC (permalink / raw)
  To: Xiaobing Luo; +Cc: Andrew Morton, linux-mm, linux-kernel

On Wed, Dec 27, 2023 at 06:18:25AM +0000, Xiaobing Luo wrote:
>  [    0.070467] cma: cma_alloc(cma (____ptrval____), count 256, align 8)
>  [    0.073003] cma: cma_alloc(): returned (____ptrval____)
> 
> Use 0x%px instead of %p to print the pointer. Then the print will be like:
> 
>  [    0.054963] cma: cma_alloc(cma 0xffffffde9ad42a60, count 256, align 8)
>  [    0.057385] cma: cma_alloc(): returned 0xfffffffe003b0000

Please explain why we should leak this information to userspace,
making it easy for an attacker?


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-27  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-27  6:18 [PATCH] mm/cma: change print format of pointer in pr_debug() With %p, the pointer will be hashed and print (____ptrval____) instead Xiaobing Luo
2023-12-27  9:56 ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox