Commit f7c82d5a authored by John Blackwood's avatar John Blackwood Committed by Jason Wessel

kdb: A fix for kdb command table expansion

When locally adding in some additional kdb commands, I stumbled
across an issue with the dynamic expansion of the kdb command table.
When the number of kdb commands exceeds the size of the statically
allocated kdb_base_commands[] array, additional space is allocated in
the kdb_register_repeat() routine.

The unused portion of the newly allocated array was not being initialized
to zero properly and this would result in segfaults when help '?' was
executed or when a search for a non-existing command would traverse the
command table beyond the end of valid command entries and then attempt
to use the non-zeroed area as actual command entries.
Signed-off-by: default avatarJohn Blackwood <john.blackwood@ccur.com>
Signed-off-by: default avatarJason Wessel <jason.wessel@windriver.com>
parent 19f949f5
...@@ -2739,7 +2739,7 @@ int kdb_register_repeat(char *cmd, ...@@ -2739,7 +2739,7 @@ int kdb_register_repeat(char *cmd,
(kdb_max_commands - KDB_BASE_CMD_MAX) * sizeof(*new)); (kdb_max_commands - KDB_BASE_CMD_MAX) * sizeof(*new));
kfree(kdb_commands); kfree(kdb_commands);
} }
memset(new + kdb_max_commands, 0, memset(new + kdb_max_commands - KDB_BASE_CMD_MAX, 0,
kdb_command_extend * sizeof(*new)); kdb_command_extend * sizeof(*new));
kdb_commands = new; kdb_commands = new;
kp = kdb_commands + kdb_max_commands - KDB_BASE_CMD_MAX; kp = kdb_commands + kdb_max_commands - KDB_BASE_CMD_MAX;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment