Fixed UAF and double free in network
cover Fixed UAF and double free in network
Fixed UAF and double free issues found by fuzzing.
Lidong Chen (2):
net/bootp: Prevent a UAF in network interface unregister. net/dns: Prevent UAF and double free
grub-core/net/bootp.c | 7 +++++-- grub-core/net/dns.c | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-)
Signature · 7 lines
2.43.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 1/2 net/bootp: Prevent a UAF in network interface unregister.
A UAF occurs in grub_net_network_level_interface_unregister() when inter->name is accessed after being freed in grub_cmd_bootp(). Fix it by deferring grub_free(ifaces[j].name) until after grub_net_network_level_interface_unregister() completes.
--- grub-core/net/bootp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
grub-core/net/bootp.c +5 -2
@@ -901,14 +901,17 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), err =GRUB_ERR_NONE ;for (j =0 ; j < ncards; j++) { -grub_free (ifaces[j].name);if (!ifaces[j].prev) -continue ; + { +grub_free (ifaces[j].name); +continue ; + }grub_error_push ();grub_net_network_level_interface_unregister (&ifaces[j]); err =grub_error (GRUB_ERR_FILE_NOT_FOUND ,N_ ("couldn't autoconfigure %s" ), ifaces[j].card->name); +grub_free (ifaces[j].name); }grub_free (ifaces);
Signature · 7 lines
2.43.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 2/2 net/dns: Prevent UAF and double free
In reply to Lidong Chen via Grub-develIn recv_hook(), *data->addresses is freed without being set to NULL. Since *data->addresses can be cached in dns_cache[h].addresses, this can lead to UAF or double free if dns_cache[h].addresses is accessed or cleared later.
The fix sets *data->addresses to NULL after freeing to avoid dangling pointer.
--- grub-core/net/dns.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
grub-core/net/dns.c +4 -1
@@ -424,7 +424,10 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)),grub_netbuff_free (nb);grub_free (redirect_save);if (!*data->naddresses) -grub_free (*data->addresses); + { +grub_free (*data->addresses); + *data->addresses =NULL ; + }return GRUB_ERR_NONE ; }
Signature · 7 lines
2.43.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 5 lines · Lidong Chen
Fixed UAF and double free issues found by fuzzing.
Lidong Chen (2):
net/bootp: Prevent a UAF in network interface unregister. net/dns: Prevent UAF and double free
For all patches Reviewed-by: Daniel Kiper <[email protected]>...
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel