lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <90858b515127a99d0bcb989a16b5d88829abfce2.1657047672.git.christophe.jaillet@wanadoo.fr>
Date:   Tue,  5 Jul 2022 21:01:33 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        linux-perf-users@...r.kernel.org
Subject: [PATCH] uprobes: Use the bitmap API to allocate bitmaps

Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Out of curiosity, is it normal to have __free_page() in the error handling
path of __create_xol_area() and put_page() in uprobe_clear_state()?

uprobe_clear_state() seems to release the resources allocated in
__create_xol_area(), but the implementation of __free_page() and of
put_page() look quite different.

This is maybe perfectly correct, but looks odd to me.
---
 kernel/events/uprobes.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 401bc2d24ce0..83fb62eed9c6 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1485,8 +1485,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 	if (unlikely(!area))
 		goto out;
 
-	area->bitmap = kcalloc(BITS_TO_LONGS(UINSNS_PER_PAGE), sizeof(long),
-			       GFP_KERNEL);
+	area->bitmap = bitmap_zalloc(UINSNS_PER_PAGE, GFP_KERNEL);
 	if (!area->bitmap)
 		goto free_area;
 
@@ -1510,7 +1509,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
 
 	__free_page(area->pages[0]);
  free_bitmap:
-	kfree(area->bitmap);
+	bitmap_free(area->bitmap);
  free_area:
 	kfree(area);
  out:
@@ -1551,7 +1550,7 @@ void uprobe_clear_state(struct mm_struct *mm)
 		return;
 
 	put_page(area->pages[0]);
-	kfree(area->bitmap);
+	bitmap_free(area->bitmap);
 	kfree(area);
 }
 
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ