Skip to contentSkip to conversation

net: fix null pointer dereference when parsing ICMP6_ROUTER_ADVERTISE messages

PATCH In review Qiumiao Zhang 2 participants 2 messages Apr 16, 2022 – Apr 21, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 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, 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. Actually, in this case, the client obtains the default route through DHCPv6 instead of RA messages. So if orig_inf == NULL and route_inf == null, we should not set the default route.

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 11 lines · Qiumiao Zhang via Grub-devel

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. Actually, in this case, the client obtains the default route through DHCPv6 instead of RA messages. So if orig_inf == NULL and route_inf == null, we should not set the default route.

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

Missing "Signed-off-by: Qiumiao Zhang <[email protected]>" line. May I add it on behalf of you?

Otherwise Reviewed-by: Daniel Kiper <[email protected]>

Daniel