[PATCH] user_events: Use alloc_pages instead of kzalloc for register pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



kzalloc virtual addresses do not work with SetPageReserved, use the
actual page virtual addresses instead via alloc_pages.

The issue is reported when booting with user_events and
DEBUG_VM_PGFLAGS=y.

Link: https://lore.kernel.org/linux-trace-devel/CADYN=9+xY5Vku3Ws5E9S60SM5dCFfeGeRBkmDFbcxX0ZMoFing@xxxxxxxxxxxxxx/#R

Reported-by: Anders Roxell <anders.roxell@xxxxxxxxxx>
Signed-off-by: Beau Belgrave <beaub@xxxxxxxxxxxxxxxxxxx>
---
 kernel/trace/trace_events_user.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c
index 2b5e9fdb63a0..59c900789757 100644
--- a/kernel/trace/trace_events_user.c
+++ b/kernel/trace/trace_events_user.c
@@ -1587,16 +1587,20 @@ static void set_page_reservations(bool set)
 static int __init trace_events_user_init(void)
 {
 	int ret;
+	struct page *register_pages;
 
 	/* Zero all bits beside 0 (which is reserved for failures) */
 	bitmap_zero(page_bitmap, MAX_EVENTS);
 	set_bit(0, page_bitmap);
 
-	register_page_data = kzalloc(MAX_EVENTS, GFP_KERNEL);
+	register_pages = alloc_pages(GFP_KERNEL | __GFP_ZERO,
+				     get_order(MAX_EVENTS));
 
-	if (!register_page_data)
+	if (!register_pages)
 		return -ENOMEM;
 
+	register_page_data = page_address(register_pages);
+
 	set_page_reservations(true);
 
 	ret = create_user_tracefs();
@@ -1604,7 +1608,7 @@ static int __init trace_events_user_init(void)
 	if (ret) {
 		pr_warn("user_events could not register with tracefs\n");
 		set_page_reservations(false);
-		kfree(register_page_data);
+		__free_pages(register_pages, get_order(MAX_EVENTS));
 		return ret;
 	}
 

base-commit: 864ea0e10cc90416a01b46f0d47a6f26dc020820
-- 
2.17.1




[Index of Archives]     [Linux Kernel]     [Linux USB Development]     [Yosemite News]     [Linux SCSI]

  Powered by Linux