[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250706193207.39810-2-sj@kernel.org>
Date: Sun, 6 Jul 2025 12:32:02 -0700
From: SeongJae Park <sj@...nel.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: SeongJae Park <sj@...nel.org>,
damon@...ts.linux.dev,
kernel-team@...a.com,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
stable@...r.kernel.org
Subject: [PATCH 1/6] samples/damon/wsse: fix boot time enable handling
If 'enable' parameter of the 'wsse' DAMON sample module is set at boot
time via the kernel command line, memory allocation is tried before the
slab is initialized. As a result kernel NULL pointer dereference BUG
can happen. Fix it by checking the initialization status.
Fixes: b757c6cfc696 ("samples/damon/wsse: start and stop DAMON as the user requests")
Cc: stable@...r.kernel.org
Signed-off-by: SeongJae Park <sj@...nel.org>
---
samples/damon/wsse.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/samples/damon/wsse.c b/samples/damon/wsse.c
index e20238a249e7..15e2683fe5f3 100644
--- a/samples/damon/wsse.c
+++ b/samples/damon/wsse.c
@@ -89,6 +89,8 @@ static void damon_sample_wsse_stop(void)
put_pid(target_pidp);
}
+static bool init_called;
+
static int damon_sample_wsse_enable_store(
const char *val, const struct kernel_param *kp)
{
@@ -103,6 +105,9 @@ static int damon_sample_wsse_enable_store(
return 0;
if (enable) {
+ if (!init_called)
+ return 0;
+
err = damon_sample_wsse_start();
if (err)
enable = false;
@@ -114,7 +119,15 @@ static int damon_sample_wsse_enable_store(
static int __init damon_sample_wsse_init(void)
{
- return 0;
+ int err = 0;
+
+ init_called = true;
+ if (enable) {
+ err = damon_sample_wsse_start();
+ if (err)
+ enable = false;
+ }
+ return err;
}
module_init(damon_sample_wsse_init);
--
2.39.5
Powered by blists - more mailing lists