Similar to the recent "dhcpcd: if_learnaddrs: if_addrflags6: Invalid
argument" thread[0].  At least ports/net/openvpn is affected, as
reported by Landry*.  kdump looks like:

  88944 openvpn  CALL  ioctl(4,SIOCGIFNETMASK,0x7f7ffffe8bc0)
  88944 openvpn  RET   ioctl -1 errno 22 Invalid argument

I think at least IPv4 get ioctls should not require sa_len to be set.
The same solution was already used for sys/netinet6/in6.c; I added the
extra "sa" variable to mimic the IPv6 code.

ok?


* the warning in logs looks like "openvpn[94060]: GDG: ioctl #1 failed",
  Landry's setup may have been negatively affected, mine was not.

[0] https://marc.info/?l=openbsd-bugs&m=157399829431423&w=2


Index: netinet/in.c
===================================================================
RCS file: /d/cvs/src/sys/netinet/in.c,v
retrieving revision 1.167
diff -u -p -r1.167 in.c
--- netinet/in.c        28 Nov 2019 00:50:41 -0000      1.167
+++ netinet/in.c        30 Nov 2019 12:24:17 -0000
@@ -557,11 +557,14 @@ in_ioctl_get(u_long cmd, caddr_t data, s
        struct ifreq *ifr = (struct ifreq *)data;
        struct ifaddr *ifa;
        struct in_ifaddr *ia = NULL;
+       struct sockaddr *sa;
        struct sockaddr_in *sin = NULL;
        int error = 0;
 
-       if (ifr->ifr_addr.sa_family == AF_INET) {
-               error = in_sa2sin(&ifr->ifr_addr, &sin);
+       sa = &ifr->ifr_addr;
+       if (sa->sa_family == AF_INET) {
+               sa->sa_len = sizeof(struct sockaddr_in);
+               error = in_sa2sin(sa, &sin);
                if (error)
                        return (error);
        }


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to