Skip to contentSkip to conversation

kdb: Make the internal env 'KDBFLAGS' undefinable

PATCH In review Wei Li 2 participants 3 messages May 16, 2020 – May 19, 2020 KGDB / KDB /debug_core

lore
Share & tools
lore

Wei Li

author
#0 lore raw

PATCH v2 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.

---
v1 -> v2:
- Fix lack of braces.

 kernel/debug/kdb/kdb_main.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/debug/kdb/kdb_main.c +2 -0
index 4fc43fb17127..75b798340300 100644
@@ -423,6 +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;
 	}
 
 	/*
Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 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.

I took a quick look at this and find myself thinking of KDBFLAGS as something of a misfeature.

I think I'd rather get kdb_env to show the value we wrote into KDBDEBUG.

Sure this means we cannot use KDBDEBUG to look at the least significant 16-bits but I think anyone who is debugging kdb itself should know enough to use md4c1 kdb_flags to read those anyway.

Daniel.

Quoted 23 lines

---
v1 -> v2:
- Fix lack of braces.

 kernel/debug/kdb/kdb_main.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/debug/kdb/kdb_main.c +2 -0
index 4fc43fb17127..75b798340300 100644
@@ -423,6 +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;
 	}
 
 	/*
Signature · 1 line
2.17.1
author
#2 lore raw

Hi Daniel,

Quoted 11 lines · Daniel Thompson
Quoted 6 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.

I took a quick look at this and find myself thinking of KDBFLAGS as something of a misfeature.

Quoted 8 lines

I think I'd rather get kdb_env to show the value we wrote into KDBDEBUG.

Sure this means we cannot use KDBDEBUG to look at the least significant 16-bits but I think anyone who is debugging kdb itself should know enough to use md4c1 kdb_flags to read those anyway.

Agree. That will be more clear with no confusion. Currently, KDBFLAGS will be shown only when KDBDEBUG is set, that is weird too. So, let's just make it simple.
I can fix it as you suggested in the next post.

Thanks,
Wei