[Crash-utility] [PATCH] Fixed the segment fault when ikconfig passed nonstandard values

Jackie Liu liuyun01 at tj.kylinos.cn
Thu Dec 31 01:17:02 UTC 2020


From: Jackie Liu <liuyun01 at kylinos.cn>

Some strange reasons may cause kcore to collect some strange
entries of ikconfig, such as CONFIG_SECU+[some hex data] causes
the 'val' to be NULL, and then crashes when strdup.

Signed-off-by: Jackie Liu <liuyun01 at kylinos.cn>
---
 kernel.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel.c b/kernel.c
index 9871637..aa86f0d 100644
--- a/kernel.c
+++ b/kernel.c
@@ -10244,6 +10244,9 @@ static void add_ikconfig_entry(char *line, struct ikconfig_list *ent)
 	sscanf(name, "CONFIG_%s", name);
 	val = strtok_r(NULL, "", &tokptr);
 
+	if (!val)
+		return;
+
 	ent->name = strdup(name);
 	ent->val = strdup(val);
 }
-- 
2.17.1






More information about the Crash-utility mailing list