[Bug 257302] net/syncthing: Panic in in6_getmulti at /usr/src/sys/netinet6/in6_mcast.c:451

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 21 Jul 2021 04:55:14 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257302

--- Comment #4 from Alex Vasylenko <lxv@omut.org> ---
The following golang program reproduces the issue, no root required; it was a
mcast join on ipfw0 after all, but has to be an IPv6 join.

$ cat mcast6_join.go
package main

import (
        "fmt"
        "net"
        "golang.org/x/net/ipv6"
)

func main() {
        addr := "[ff12::8384]:21027"

        gaddr, err := net.ResolveUDPAddr("udp6", addr)
        if err != nil {
                fmt.Println(err)
                return
        }

        conn, err := net.ListenPacket("udp6", addr)
        if err != nil {
                fmt.Println(err)
                return
        }
        defer conn.Close()

        intf, err := net.InterfaceByName("ipfw0")
        if err != nil {
                fmt.Println(err)
                return
        }

        pconn := ipv6.NewPacketConn(conn)

        result := pconn.JoinGroup(intf, &net.UDPAddr{IP: gaddr.IP})
        if result != nil {
                fmt.Println("IPv6 join", intf.Name, "failed:", result)
        } else {
                fmt.Println("IPv6 join", intf.Name, "success")
        }
}

net/syncthing has something like the above in
https://github.com/syncthing/syncthing/blob/main/lib/beacon/multicast.go#L101
(except they perform join on all interfaces in a loop ignoring multicast flag,
but that's beside the point)

A relevant part from vmcore that I failed to include in the original report was
this:
(kgdb) f 14
#14 0xffffffff80c584d6 in sosetopt (so=0xfffff80012986a38,
sopt=0xfffffe005c3cfb98) at /usr/src/sys/kern/uipc_socket.c:2761
2761    error = (*so->so_proto->pr_ctloutput)(so, sopt);
(kgdb) set print pretty
(kgdb) p *sopt
$1 = {
  sopt_dir = SOPT_SET,
  sopt_level = 41,
  sopt_name = 80,
  sopt_val = 0xc000320900,
  sopt_valsize = 136,
  sopt_td = 0xfffff800126f9000
}

optname 80 is MCAST_JOIN_GROUP

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.