On 9/11/25 12:29 PM, Avnish Chouhan wrote:
On 2025-09-10 18:27, [email protected] wrote:
----------------------------------------------------------------------
Message: 1
Date: Tue, 9 Sep 2025 11:09:55 -0400
From: Stefan Berger <[email protected]>
To: Sudhakar Kuppusamy <[email protected]>, Srish Srinivasan
<[email protected]>
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected]
Subject: Re: [PATCH v2] kern: perform NULL check in unregister paths
(command/extcmd)
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8; format=flowed
On 9/9/25 4:22 AM, Sudhakar Kuppusamy wrote:
On 9 Sep 2025, at 12:25 PM, Srish Srinivasan <[email protected]>
wrote:
Many modules call grub_unregister_{command(), extcmd()} from
GRUB_MOD_FINI() without checking for a failure in registration.
This could lead to a NULL pointer dereference in unregistration.
Perform explicit NULL check in both the unregister helpers.
Signed-off-by: Srish Srinivasan <[email protected]>
Reviewed-by: Sudhakar Kuppusamy <[email protected]>
Reviewed-by: Stefan Berger <[email protected]>
Hi Srish,
Thank you so much for the patch!
A failure in registration will anyways returns NULL. Re checking it
might not make a sense. Do you have any specific scenario for this?
Thank you!
Regards,
Avnish Chouhan
Hi Avnish,
During module registration, if there is a failure in memory allocation
then a NULL is returned.
https://github.com/olafhering/grub/blob/master/grub-core/kern/command.c#L40
But during unregistration, not all modules check for this NULL.
here is an example where NULL is checked.
https://github.com/olafhering/grub/blob/master/grub-core/disk/diskfilter.c#L1491
But for example in
https://github.com/olafhering/grub/blob/master/grub-core/commands/efi/efitextmode.c#L151
there is no explicit check done before unregistration. And there are
many such instances.
Thanks,
Srish
_______________________________________________
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