command/extcmd: perform explicit NULL check in both the unregister helpers
PATCH v3 1/1 command/extcmd: perform explicit NULL check in both the unregister helpers
During command registration, grub_register_command_prio returns a 0 when there is a failure in memory allocation. In such a situation, calls to grub_unregister_{command(), extcmd()} during command unregistration will result in dereferencing a NULL pointer.
Perform explicit NULL check in both the unregister helpers to prevent undefined behaviour due to a NULL pointer dereference.
--- grub-core/commands/extcmd.c | 3 +++ grub-core/kern/command.c | 3 +++ 2 files changed, 6 insertions(+)
grub-core/commands/extcmd.c +3 -0
@@ -139,6 +139,9 @@ grub_register_extcmd_lockdown (const char *name, grub_extcmd_func_t func,void grub_unregister_extcmd (grub_extcmd_t ext) { +if (ext ==NULL ) +return ; +grub_unregister_command (ext->cmd);grub_free (ext); }
grub-core/kern/command.c +3 -0
@@ -104,6 +104,9 @@ grub_register_command_lockdown (const char *name,void grub_unregister_command (grub_command_t cmd) { +if (cmd ==NULL ) +return ; +if ((cmd->prio &GRUB_COMMAND_FLAG_ACTIVE ) && (cmd->next)) cmd->next->prio |=GRUB_COMMAND_FLAG_ACTIVE ;grub_list_remove (GRUB_AS_LIST (cmd));
Signature · 6 lines
2.51.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Looks good to me, thank you.
Quoted 49 lines · Srish Srinivasan
During command registration,
grub_register_command_prioreturns a 0 when there is a failure in memory allocation. In such a situation, calls to grub_unregister_{command(),extcmd()} during command unregistration will result in dereferencing a NULL pointer.Perform explicit NULL check in both the unregister helpers to prevent undefined behaviour due to a NULL pointer dereference.
Signed-off-by Srish Srinivasan <[email protected]>Reviewed-by Sudhakar Kuppusamy <[email protected]>Reviewed-by Stefan Berger <[email protected]>--- grub-core/commands/extcmd.c | 3 +++ grub-core/kern/command.c | 3 +++ 2 files changed, 6 insertions(+)grub-core/commands/extcmd.c +3
-0@@ -139,6 +139,9 @@ grub_register_extcmd_lockdown (const char *name, grub_extcmd_func_t func,void grub_unregister_extcmd (grub_extcmd_t ext) { +if (ext ==NULL ) +return ; +grub_unregister_command (ext->cmd);grub_free (ext); }grub-core/kern/command.c +3
-1@@ -104,6 +104,9 @@ grub_register_command_lockdown (const char *name,void grub_unregister_command (grub_command_t cmd) { +if (cmd ==NULL ) +return ; +if ((cmd->prio &GRUB_COMMAND_FLAG_ACTIVE ) && (cmd->next)) cmd->next->prio |=GRUB_COMMAND_FLAG_ACTIVE ;grub_list_remove (GRUB_AS_LIST (cmd)); --2.51.0
Quoted 4 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 6 lines · Srish Srinivasan
During command registration,
grub_register_command_prioreturns a 0 when there is a failure in memory allocation. In such a situation, calls to grub_unregister_{command(),extcmd()} during command unregistration will result in dereferencing a NULL pointer.
Quoted 6 lines
Perform explicit NULL check in both the unregister helpers to prevent undefined behaviour due to a NULL pointer dereference.
Signed-off-by Srish Srinivasan <[email protected]>Reviewed-by Sudhakar Kuppusamy <[email protected]>Reviewed-by Stefan Berger <[email protected]>
Patch LGTM to me but it does not seem to be posted earlier to the grub-devel. So, I cannot accept Sudhakar's and Stefan's RBs until they are confirmed here.
Though Reviewed-by: Daniel Kiper <[email protected]>...
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 13 lines · Daniel Kiper
Quoted 6 lines · Srish Srinivasan
During command registration,
grub_register_command_prioreturns a 0 when there is a failure in memory allocation. In such a situation, calls to grub_unregister_{command(),extcmd()} during command unregistration will result in dereferencing a NULL pointer.Quoted 6 lines
Perform explicit NULL check in both the unregister helpers to prevent undefined behaviour due to a NULL pointer dereference.
Signed-off-by Srish Srinivasan <[email protected]>Reviewed-by Sudhakar Kuppusamy <[email protected]>Reviewed-by Stefan Berger <[email protected]>
Quoted 7 lines
Patch LGTM to me but it does not seem to be posted earlier to the grub-devel. So, I cannot accept Sudhakar's and Stefan's RBs until they are confirmed here.
Though Reviewed-by: Daniel Kiper <[email protected]>...
Daniel
Hi Daniel,
thank you for the reviewed-by.
And, here are the links to v2 for the same patch where I got reviews from Sudhakar and Stefan.
Sudhakar's reviewed-by: https://lists.gnu.org/archive/html/grub-devel/2025-09/msg00087.html
Stefan's reviewed-by: https://lists.gnu.org/archive/html/grub-devel/2025-09/msg00113.html
And, here is the link to v1 for the same patch just for your reference.
https://lists.gnu.org/archive/html/grub-devel/2025-09/msg00072.html
Hope this helps.
Thank You.
Quoted 5 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 32 lines · Srish Srinivasan
Quoted 13 lines · Daniel Kiper
Quoted 6 lines · Srish Srinivasan
During command registration,
grub_register_command_prioreturns a 0 when there is a failure in memory allocation. In such a situation, calls to grub_unregister_{command(),extcmd()} during command unregistration will result in dereferencing a NULL pointer.Quoted 6 lines
Perform explicit NULL check in both the unregister helpers to prevent undefined behaviour due to a NULL pointer dereference.
Signed-off-by Srish Srinivasan <[email protected]>Reviewed-by Sudhakar Kuppusamy <[email protected]>Reviewed-by Stefan Berger <[email protected]>Quoted 7 lines
Patch LGTM to me but it does not seem to be posted earlier to the grub-devel. So, I cannot accept Sudhakar's and Stefan's RBs until they are confirmed here.
Though Reviewed-by: Daniel Kiper <[email protected]>...
Daniel
Hi Daniel,
thank you for the reviewed-by.And, here are the links to v2 for the same patch where I got reviews from Sudhakar and Stefan.
Sudhakar's reviewed-by:
https://lists.gnu.org/archive/html/grub-devel/2025-09/msg00087.html
Stefan's reviewed-by:
https://lists.gnu.org/archive/html/grub-devel/2025-09/msg00113.html
Quoted 5 lines
And, here is the link to v1 for the same patch just for your reference.
https://lists.gnu.org/archive/html/grub-devel/2025-09/msg00072.html
Hope this helps.
Sorry, I missed both emails due to subject change. I will get Sudhakar's and Stefan's RBs then.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel