Skip to contentSkip to conversation

kdb: Make the internal env 'KDBFLAGS' undefinable

PATCH Superseded Wei Li 2 participants 3 messages May 11, 2020 – May 16, 2020 KGDB / KDB /debug_core

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wei Li

author
#0 lore raw

PATCH 1/1 kdb: Make the internal env 'KDBFLAGS' undefinable

'KDBFLAGS' is an internal variable of kdb, it is combined by 'KDBDEBUG' and state flags. But the user can define an environment variable named 'KDBFLAGS' too, so let's make it undefinable to avoid confusion.

---
 kernel/debug/kdb/kdb_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/debug/kdb/kdb_main.c +2 -1
index 4fc43fb17127..d3d060136821 100644
@@ -423,7 +423,8 @@ int kdb_set(int argc, const char **argv)
 			| (debugflags << KDB_DEBUG_FLAG_SHIFT);
 
 		return 0;
-	}
+	} else if (strcmp(argv[1], "KDBFLAGS") == 0)
+		return KDB_NOPERM;
 
 	/*
 	 * Tokenizer squashed the '=' sign.  argv[1] is variable
Signature · 1 line
2.17.1
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi,

Quoted 15 lines · Wei Li

'KDBFLAGS' is an internal variable of kdb, it is combined by 'KDBDEBUG' and state flags. But the user can define an environment variable named 'KDBFLAGS' too, so let's make it undefinable to avoid confusion.

---
 kernel/debug/kdb/kdb_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/debug/kdb/kdb_main.c +0 -0
index 4fc43fb17127..d3d060136821 100644

kernel/debug/kdb/kdb_main.c int kdb_set(int argc, const char **argv) · line 427

Quoted 6 lines
kernel/debug/kdb/kdb_main.c +2 -1
@@ -423,7 +423,8 @@ int kdb_set(int argc, const char **argv)
                        | (debugflags << KDB_DEBUG_FLAG_SHIFT);
 
                return 0;
-       }
+       } else if (strcmp(argv[1], "KDBFLAGS") == 0)
+               return KDB_NOPERM;

One slight nit is that my personal preference is that if one half of an "if/else" needs braces then both halves should have braces. I don't know what Daniel and Jason's policies are, though. In any case, not that I've ever used the KDBDEBUG functionality, but your change seems sane. Without it if I set "KDBDEBUG" and "KDBFLAGS" and then type "env" I see the flags listed twice, but one is real and one is fake.

-Doug

author
#2 lore raw

Hi Douglas,

Quoted 6 lines · Doug Anderson

kernel/debug/kdb/kdb_main.c int kdb_set(int argc, const char **argv) · line 427

Quoted 3 lines
kernel/debug/kdb/kdb_main.c +2 -1
-       }
+       } else if (strcmp(argv[1], "KDBFLAGS") == 0)
+               return KDB_NOPERM;

One slight nit is that my personal preference is that if one half of an "if/else" needs braces then both halves should have braces. I

Thanks for spotting it. Refer to Documentation/process/coding-style.rst, i will fix it in the v2.

Quoted 10 lines

don't know what Daniel and Jason's policies are, though. In any case, not that I've ever used the KDBDEBUG functionality, but your change seems sane. Without it if I set "KDBDEBUG" and "KDBFLAGS" and then type "env" I see the flags listed twice, but one is real and one is fake.

-Doug

Thanks,
Wei