mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup
@ 2026-06-29  9:30 Martin Weiss
  2026-06-29  9:30 ` [PATCH 2/4] selftests: filesystems: fix spelling mistake in statmount test Martin Weiss
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Martin Weiss @ 2026-06-29  9:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: Martin Weiss, Andrew Morton, Jason Baron, Jim Cromie

kstrdup(saved_command_line, GFP_KERNEL) may return NULL under memory
pressure. Add a check to avoid NULL pointer dereference during boot-time
dynamic debug parameter parsing.

Signed-off-by: Martin Weiss <Martin.weiss2410@gmail.com>
---
 lib/dynamic_debug.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 18a71a9108d3..59a04057b509 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -1479,6 +1479,8 @@ static int __init dynamic_debug_init(void)
 	 * slightly noisy if verbose, but harmless.
 	 */
 	cmdline = kstrdup(saved_command_line, GFP_KERNEL);
+	if (!cmdline)
+		return 0; /* prevents a boot-time NULL deref */
 	parse_args("dyndbg params", cmdline, NULL,
 		   0, 0, 0, NULL, &ddebug_dyndbg_boot_param_cb);
 	kfree(cmdline);
-- 
2.54.0


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

* [PATCH 2/4] selftests: filesystems: fix spelling mistake in statmount test
  2026-06-29  9:30 [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup Martin Weiss
@ 2026-06-29  9:30 ` Martin Weiss
  2026-06-29  9:30 ` [PATCH 3/4] selftests: powerpc: fix spelling mistake Martin Weiss
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Weiss @ 2026-06-29  9:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Martin Weiss, Shuah Khan, Christian Brauner, Bala-Vignesh-Reddy,
	Andrei Vagin, Wei Yang, Bhavik Sachdev, linux-kselftest

Signed-off-by: Martin Weiss <Martin.weiss2410@gmail.com>
---
 tools/testing/selftests/filesystems/statmount/statmount_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/filesystems/statmount/statmount_test.c b/tools/testing/selftests/filesystems/statmount/statmount_test.c
index 8dc018d47a93..9d963e09e510 100644
--- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
+++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
@@ -515,7 +515,7 @@ static void test_statmount_mnt_opts(void)
 		return;
 	}
 
-	ksft_test_result_fail("didnt't find mount entry\n");
+	ksft_test_result_fail("didn't find mount entry\n");
 	free(sm);
 	free(line);
 }
-- 
2.54.0


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

* [PATCH 3/4] selftests: powerpc: fix spelling mistake
  2026-06-29  9:30 [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup Martin Weiss
  2026-06-29  9:30 ` [PATCH 2/4] selftests: filesystems: fix spelling mistake in statmount test Martin Weiss
@ 2026-06-29  9:30 ` Martin Weiss
  2026-06-29  9:30 ` [PATCH 4/4] tools/build: fix spelling mistake in documentation Martin Weiss
  2026-06-29 23:51 ` [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup Andrew Morton
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Weiss @ 2026-06-29  9:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Martin Weiss, Madhavan Srinivasan, Michael Ellerman,
	Nicholas Piggin, Christophe Leroy (CS GROUP),
	Shuah Khan, linuxppc-dev, linux-kselftest

Signed-off-by: Martin Weiss <Martin.weiss2410@gmail.com>
---
 tools/testing/selftests/powerpc/tm/tm-tar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/powerpc/tm/tm-tar.c b/tools/testing/selftests/powerpc/tm/tm-tar.c
index f2a9137f3c1e..ea420caa3961 100644
--- a/tools/testing/selftests/powerpc/tm/tm-tar.c
+++ b/tools/testing/selftests/powerpc/tm/tm-tar.c
@@ -50,7 +50,7 @@ int test_tar(void)
 			"bne	2b;"
 			"tend.;"
 
-			/* Transaction sucess! TAR should be 3 */
+			/* Transaction success! TAR should be 3 */
 			"mfspr  7, %[tar];"
 			"ori	%[res], 7, 4;"  // res = 3|4 = 7
 			"b	4f;"
-- 
2.54.0


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

* [PATCH 4/4] tools/build: fix spelling mistake in documentation
  2026-06-29  9:30 [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup Martin Weiss
  2026-06-29  9:30 ` [PATCH 2/4] selftests: filesystems: fix spelling mistake in statmount test Martin Weiss
  2026-06-29  9:30 ` [PATCH 3/4] selftests: powerpc: fix spelling mistake Martin Weiss
@ 2026-06-29  9:30 ` Martin Weiss
  2026-06-29 23:51 ` [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup Andrew Morton
  3 siblings, 0 replies; 5+ messages in thread
From: Martin Weiss @ 2026-06-29  9:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: Martin Weiss

Signed-off-by: Martin Weiss <Martin.weiss2410@gmail.com>
---
 tools/build/Documentation/Build.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/build/Documentation/Build.txt b/tools/build/Documentation/Build.txt
index a22587475dbe..da037299dfd1 100644
--- a/tools/build/Documentation/Build.txt
+++ b/tools/build/Documentation/Build.txt
@@ -102,7 +102,7 @@ Makefile.include
 ----------------
 
 The tools/build/Makefile.include makefile could be included
-via user makefiles to get usefull definitions.
+via user makefiles to get useful definitions.
 
 It defines following interface:
 
-- 
2.54.0


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

* Re: [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup
  2026-06-29  9:30 [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup Martin Weiss
                   ` (2 preceding siblings ...)
  2026-06-29  9:30 ` [PATCH 4/4] tools/build: fix spelling mistake in documentation Martin Weiss
@ 2026-06-29 23:51 ` Andrew Morton
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2026-06-29 23:51 UTC (permalink / raw)
  To: Martin Weiss; +Cc: linux-kernel, Martin Weiss, Jason Baron, Jim Cromie

On Mon, 29 Jun 2026 16:30:51 +0700 Martin Weiss <martin.githubacc@gmail.com> wrote:

> kstrdup(saved_command_line, GFP_KERNEL) may return NULL under memory
> pressure. Add a check to avoid NULL pointer dereference during boot-time
> dynamic debug parameter parsing.
> 

Thanks.

> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -1479,6 +1479,8 @@ static int __init dynamic_debug_init(void)
>  	 * slightly noisy if verbose, but harmless.
>  	 */
>  	cmdline = kstrdup(saved_command_line, GFP_KERNEL);
> +	if (!cmdline)
> +		return 0; /* prevents a boot-time NULL deref */
>  	parse_args("dyndbg params", cmdline, NULL,
>  		   0, 0, 0, NULL, &ddebug_dyndbg_boot_param_cb);
>  	kfree(cmdline);

We conventionally assume that memory allocations at __init time cannot
fail.  Sashiko explains why ;)

	https://sashiko.dev/#/patchset/20260629093056.591498-1-Martin.weiss2410@gmail.com

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

end of thread, other threads:[~2026-06-29 23:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-29  9:30 [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup Martin Weiss
2026-06-29  9:30 ` [PATCH 2/4] selftests: filesystems: fix spelling mistake in statmount test Martin Weiss
2026-06-29  9:30 ` [PATCH 3/4] selftests: powerpc: fix spelling mistake Martin Weiss
2026-06-29  9:30 ` [PATCH 4/4] tools/build: fix spelling mistake in documentation Martin Weiss
2026-06-29 23:51 ` [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup Andrew Morton

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