[Bug]: libc/net: getifaddrs() drops and leaks secondary IPv6 addresses and leaves dangling ifa_name and uninitialized netmask/dstaddr pointers
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
getifaddrs() and getmutil_ipv6addr() in libs/libc/net/lib_getifaddrs.c have several bugs:
- Secondary IPv6 addresses (
eth0:0,eth0:1, ...) are overwritten and leaked when followed by another network interface:
Ingetifaddrs()(line 350),getmutil_ipv6addr(sockfd, &req, myaddrs)appends secondary IPv6 address nodes tomyaddrs->addrs.ifa_nextand returns the new tail pointer of the linked list. However,getifaddrs()only checksif (getmutil_ipv6addr(sockfd, &req, myaddrs) == NULL)and discards the returned tail pointer, leavingmyaddrspointing to the primary IPv6 node. On the next interface iteration (i + 1),myaddrs->addrs.ifa_next = lib_zalloc(sizeof(*myaddrs));(line 235) overwritesmyaddrs->addrs.ifa_next, detaching and leaking all secondary IPv6 nodes for the previous interface. - Dangling/cross-node
ifa_name, missingsin6_scope_id, and invalidifa_netmask/ifa_dstaddr/ifa_broadaddrpointers ingetmutil_ipv6addr():
Ingetmutil_ipv6addr()(lines 122–130), aftermemcpy(ifaddr->addrs.ifa_next, ifaddr, sizeof(struct myifaddrs)):ifaddr->addrs.ifa_nameis never updated toifaddr->name, so it points into the previous node'snamebuffer.((FAR struct sockaddr_in6 *)&ifaddr->addr)->sin6_scope_idis not set to the interface index.ifaddr->addrs.ifa_netmask,ifa_dstaddr,ifa_broadaddr, andifa_dataare unconditionally set to&ifaddr->netmask,&ifaddr->dstaddr,&ifaddr->broadaddr, and&ifaddr->hwaddreven when the interface has no destination/broadcast/hardware address or a different netmask on the aliaseth0:index, instead of queryingSIOCGLIFNETMASK/SIOCGLIFDSTADDR/SIOCGLIFBRDADDRforreqand only setting pointers that exist.
- Primary IPv6 node after IPv4 node uses
req.lifr_nameafter IPv4 ioctls and does not skip unspecified (0.0.0.0/::) addresses:
When an interface has both IPv4 and IPv6 enabled,myaddrs->nameshould preserve the base interface name across all ioctls, andgetmutil_ipv6addr()should restorereq->lifr_nameor query per-alias netmask/destination addresses cleanly.
Expected Behavior
getifaddrs()should assignmyaddrs = getmutil_ipv6addr(sockfd, &req, myaddrs, i);so subsequent interfaces append to the true tail of the linked list without leaking secondary IPv6 nodes.getmutil_ipv6addr()should setifaddr->addrs.ifa_name = ifaddr->name, setsin6_scope_id = ifindex, querySIOCGLIFNETMASK/SIOCGLIFDSTADDR/SIOCGLIFBRDADDRfor each secondary IPv6 alias, and only populateifa_netmask,ifa_dstaddr/ifa_broadaddr, andifa_datawhen valid.
Steps To Reproduce
- Configure an interface
eth0with multiple IPv6 addresses (CONFIG_NETDEV_MAX_IPv6_ADDR > 1) followed by another interfaceeth1(higherifindex). - Call
getifaddrs(&ifa)->eth1overwriteseth0'sifa_next, losing and leakingeth0's secondary IPv6 addresses.
Relevant log output
getifaddrs(): secondary IPv6 addresses on interface 1 overwritten and leaked when interface 2 is added
Architecture
all
Issue Area
C Library
- Lenguaje dominante
- C
- Estrellas
- 4.1k
- Forks
- 1.8k
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 881
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/nuttx
-
[BUG] libc/time: strptime() numeric_range upper bound is off by one and accepts invalid dates/timesAbiertoArch: all Area: Posix OS: Linux
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
[BUG] libc/stdlib: lib_checkbase() strips "0x" prefix in base 16 even when no hex digit followsAbiertoArch: all Area: Posix OS: Linux
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Please rerun `pre-commit run -a`AbiertoArch: all Arch: arm Area: Build system OS: Linux Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
apache/nuttx#19435 · 9 comentarios ·
Los mantenedores suelen responder en 1 día
-
Arch: all OS: Linux Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apache/nuttx#16249 · 7 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/nuttx
Issues similares
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
389ds/389-ds-base#8251 ·
Los mantenedores suelen responder en 1 día
-
bug data-types
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ClickHouse/clickhouse-cpp#645 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ROCm/hrx-system#3628 ·
Los mantenedores suelen responder en 1 día