From nobody Sun Dec 19 16:10:54 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 110851906F6F; Sun, 19 Dec 2021 16:11:03 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [162.251.186.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JH74Q5bqrz3NCg; Sun, 19 Dec 2021 16:11:02 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.16.1/8.16.1) with ESMTPS id 1BJGAs0u025828 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 19 Dec 2021 08:10:55 -0800 (PST) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.16.1/8.16.1/Submit) id 1BJGAsiN025827; Sun, 19 Dec 2021 08:10:54 -0800 (PST) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Sun, 19 Dec 2021 08:10:54 -0800 From: Gleb Smirnoff To: Mateusz Guzik Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 71a1539e3783 - main - inet6: fix a LOR between rip and rawinp Message-ID: References: <202112191443.1BJEh9Ss072418@gitrepo.freebsd.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202112191443.1BJEh9Ss072418@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4JH74Q5bqrz3NCg X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Sun, Dec 19, 2021 at 02:43:09PM +0000, Mateusz Guzik wrote: M> commit 71a1539e378310120fede100b867ffa995fd9a7a M> Author: Mateusz Guzik M> AuthorDate: 2021-12-16 14:11:42 +0000 M> Commit: Mateusz Guzik M> CommitDate: 2021-12-19 14:43:04 +0000 M> M> inet6: fix a LOR between rip and rawinp M> M> Running sys/netpfil/pf/fragmentation v6 results in: M> M> lock order reversal: M> 1st 0xfffffe00050429a8 rip (rip, sleep mutex) @ /usr/src/sys/netinet6/raw_ip6.c:803 M> 2nd 0xfffff8009491e1d0 rawinp (rawinp, rw) @ /usr/src/sys/netinet6/raw_ip6.c:804 ... M> --- a/sys/netinet6/raw_ip6.c M> +++ b/sys/netinet6/raw_ip6.c M> @@ -800,24 +800,24 @@ rip6_connect(struct socket *so, struct sockaddr *nam, struct thread *td) M> if ((error = sa6_embedscope(addr, V_ip6_use_defzone)) != 0) M> return (error); M> M> - INP_INFO_WLOCK(&V_ripcbinfo); M> INP_WLOCK(inp); M> + INP_INFO_WLOCK(&V_ripcbinfo); M> /* Source address selection. XXX: need pcblookup? */ M> NET_EPOCH_ENTER(et); M> error = in6_selectsrc_socket(addr, inp->in6p_outputopts, M> inp, so->so_cred, scope_ambiguous, &in6a, NULL); M> NET_EPOCH_EXIT(et); M> if (error) { M> - INP_WUNLOCK(inp); M> INP_INFO_WUNLOCK(&V_ripcbinfo); M> + INP_WUNLOCK(inp); M> return (error); M> } M> M> inp->in6p_faddr = addr->sin6_addr; M> inp->in6p_laddr = in6a; M> soisconnected(so); M> - INP_WUNLOCK(inp); M> INP_INFO_WUNLOCK(&V_ripcbinfo); M> + INP_WUNLOCK(inp); M> return (0); I actually see no reason for INP_INFO_WLOCK() in this function. That's why it was missed by my commit. I'm 99% sure that epoch protection is enough for in6_selectsrc_socket(). But I will leave that to IPv6 experts. -- Gleb Smirnoff