Skip to contentSkip to conversation

net: fix null pointer dereference when parsing ICMP6_ROUTER_ADVERTISE messages

PATCH Superseded Qiumiao Zhang 4 participants 4 messages Feb 17, 2022 – Mar 9, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: fix null pointer dereference when parsing ICMP6_ROUTER_ADVERTISE messages

During UEFI PXE boot in IPv6 network, if the DHCP server adopts stateful automatic configuration, when the client receives the ICMP6_ROUTER_ADVERTISE message multicast from the server, it will cause the problem of dereference null pointer and cause the grub2 program to crash.

Fixes bug: https://savannah.gnu.org/bugs/index.php?62072

---
 grub-core/net/icmp6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/net/icmp6.c +1 -1
index 2cbd95d..264fc4a 100644
@@ -477,7 +477,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
 
 	    /* May not have gotten slaac info, find a global address on this
 	      card.  */
-	    if (route_inf == NULL)
+	    if (route_inf == NULL && orig_inf != NULL)
 	      {
 		FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
 		{
Signature · 1 line
2.19.1
#1 lore raw
Quoted 4 lines · On Thu, 17 Feb 2022 21:48:58 +0800 Qiumiao Zhang via Grub-devel…

During UEFI PXE boot in IPv6 network, if the DHCP server adopts stateful automatic configuration, when the client receives the ICMP6_ROUTER_ADVERTISE message multicast from the server, it will cause the problem of dereference null
pointer and cause the grub2 program to crash.

This commit message could be more clear. Maybe have something like:

During UEFI PXE boot in IPv6 network, if the DHCP server adopts stateful automatic configuration, then the client receives a ICMP6_ROUTER_ADVERTISE multicast message from the server. This may be received without the interfaced having a configured network address, so orig_inf will be null, which can lead to a null dereference when creating the default route.

Of course, assuming that the above is in fact correct.

Quoted 11 lines

Fixes bug: https://savannah.gnu.org/bugs/index.php?62072

---
 grub-core/net/icmp6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/net/icmp6.c +0 -0
index 2cbd95d..264fc4a 100644

grub-core/net/icmp6.c grub_net_recv_icmp6_packet (struct grub_net_buff *nb, · line 480

Quoted 5 lines
grub-core/net/icmp6.c +1 -1
@@ -477,7 +477,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
 
 	    /* May not have gotten slaac info, find a global address on this
 	      card.  */
-	    if (route_inf == NULL)
+	    if (route_inf == NULL && orig_inf != NULL)

So if orig_inf == NULL and route_inf == NULL here, we do not set a default route. Does this have any implications to be concerned about?

In this case, can we still find a good route interface and setup a default route?

Glenn

Quoted 3 lines
grub-core/net/icmp6.c +0 -0
 	      {
 		FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
 		{
#2 lore raw
Quoted 39 lines · Glenn Washburn
Quoted 4 lines · On Thu, 17 Feb 2022 21:48:58 +0800 Qiumiao Zhang via Grub-devel…

During UEFI PXE boot in IPv6 network, if the DHCP server adopts stateful automatic configuration, when the client receives the ICMP6_ROUTER_ADVERTISE message multicast from the server, it will cause the problem of dereference null
pointer and cause the grub2 program to crash.

This commit message could be more clear. Maybe have something like:

During UEFI PXE boot in IPv6 network, if the DHCP server adopts stateful automatic configuration, then the client receives a ICMP6_ROUTER_ADVERTISE multicast message from the server. This may be received without the interfaced having a configured network address, so orig_inf will be null, which can lead to a null dereference when creating the default route.

Of course, assuming that the above is in fact correct.

Quoted 11 lines

Fixes bug: https://savannah.gnu.org/bugs/index.php?62072

---
 grub-core/net/icmp6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/net/icmp6.c +0 -0
index 2cbd95d..264fc4a 100644

grub-core/net/icmp6.c grub_net_recv_icmp6_packet (struct grub_net_buff *nb, · line 480

Quoted 5 lines
grub-core/net/icmp6.c +1 -1
@@ -477,7 +477,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
 
 	    /* May not have gotten slaac info, find a global address on this
 	      card.  */
-	    if (route_inf == NULL)
+	    if (route_inf == NULL && orig_inf != NULL)

So if orig_inf == NULL and route_inf == NULL here, we do not set a default route. Does this have any implications to be concerned about?

Quoted 2 lines

In this case, can we still find a good route interface and setup a default route?

Qiumiao, I am happy to take this patch but before that please address Glenn's concerns.

Daniel

Reviewed-by on v1 1/1
#3 lore raw
In reply to Qiumiao Zhang

Hi,

I tested this against grub-emu and it fixed the crash I had observed.

net_ls_addr reports an address as expected now also.

Kind regards,
Daniel

Quoted 31 lines · Qiumiao Zhang via Grub-devel

During UEFI PXE boot in IPv6 network, if the DHCP server adopts stateful automatic configuration, when the client receives the ICMP6_ROUTER_ADVERTISE message multicast from the server, it will cause the problem of dereference null pointer and cause the grub2 program to crash.

Fixes bug: https://savannah.gnu.org/bugs/index.php?62072

---
 grub-core/net/icmp6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
grub-core/net/icmp6.c +1 -1
index 2cbd95d..264fc4a 100644
@@ -477,7 +477,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb,
 
 	    /* May not have gotten slaac info, find a global address on this
 	      card.  */
-	    if (route_inf == NULL)
+	    if (route_inf == NULL && orig_inf != NULL)
 	      {
 		FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
 		{
Signature · 7 lines
2.19.1


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel