From nobody Sat Feb 24 01:57:14 2024 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 4ThVPQ6XVQz5BjsR; Sat, 24 Feb 2024 01:57:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ThVPQ5pwPz4bYN; Sat, 24 Feb 2024 01:57:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708739834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/EEopkio0xXXk6dOp96XodGfRKAfE/fRU8HZoc9V30g=; b=Fsx8gbcmxG4vNeq/x1nCC3SRrJKffxSlQANlY+ON/NZnj0BRiho/3qFBWYhuXQZF5N1fvQ Vl8eDMzhCW0qanbXVOeJr7rhO3fSMX210dn+a8aAx07cHkrOAXQlH4/tOueWTG3EInGsp3 8VTScSXeM67NwxJ2sfHW95iJLFBCQs27tBXJuAWWn2zYzFiiKnex+VVdf/QeQVKPWL3eFE KHIFEEoULsuGFEUL2k7GB/5KLte8/DcHGyaGU8mmvIoVhzr9wjBXSsMnEMiRn6yNPV8UEg iewxiyTqPuj6+RujSdTrdDZ96FNP+pZVS9poBLKQ9ucrDRVKOQH9eV3arKCdxA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708739834; a=rsa-sha256; cv=none; b=AopDKfhFfpwRn6nf6fu2DH/KWFOp3o9lZA07AIj8PX0P+xvKRlkqAcyxOsVftV2M7dLBsz rZAXxOdhEoGLR8mTFrgMiiTmMH8u07hgv/ZlVmz1+zB1vTvNH9y5nwwR7j177DBqPgrBQl KM3Fm06ut7rB2NfFoaqcNSnd1E3BnrevL0JRX8fCamwdjQd+2Owgr9vhDrzOew77t7VuMx YmqIebzYuNSPY2/3uuzwnmTRQQ0l0RSwxTxk6GFBIedpe6HJ7lw0rtigLWHq0lMbqmqijb dFYGgFIhBD69zgxzgt1RXOw4fQAUFxSd6pNY3IjG9xtb3BW4LCNhClnEha0CgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708739834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/EEopkio0xXXk6dOp96XodGfRKAfE/fRU8HZoc9V30g=; b=ljKUhlk3PCClQCY79v7aqqRyKAcEbSNqcdFUbakZV9JSZVUuLbi7gnVLXz/2zRGdcWXDz3 N91jA4qzHz9QgwIWn33hX4sHYdtLzo2TbvRduu3l8vtOqgH2I9Zk+iiOcFrJH2ayXjN0oO RpIlLzpikIjtuZCKWcGz01TuY9zyqA8vaBXtb/zeLxhfuremyRAWcypk7BNfrSoxrmFNFt 7bRqYXTSkfILluziXyUNySvg4/IFWBjkejdOt19ZPP6Gf0SxhPtMnmsNM4TJCiB/Qcds/i Eu3hpYmKr0vaf5LHYpUFQeT9KjxaUXQhwBbXnahp2P/J6d+sIdGd+57MyqQcRw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ThVPQ4sV6zgLq; Sat, 24 Feb 2024 01:57:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41O1vECU031415; Sat, 24 Feb 2024 01:57:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41O1vEAk031412; Sat, 24 Feb 2024 01:57:14 GMT (envelope-from git) Date: Sat, 24 Feb 2024 01:57:14 GMT Message-Id: <202402240157.41O1vEAk031412@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 48698ead6ff0 - main - lagg: wrap lagg_port2req() into LAGG_SLOCK() 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=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 48698ead6ff0640098e6aecdd5cbf6ea8f5ac177 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=48698ead6ff0640098e6aecdd5cbf6ea8f5ac177 commit 48698ead6ff0640098e6aecdd5cbf6ea8f5ac177 Author: Gleb Smirnoff AuthorDate: 2024-02-24 01:56:46 +0000 Commit: Gleb Smirnoff CommitDate: 2024-02-24 01:56:46 +0000 lagg: wrap lagg_port2req() into LAGG_SLOCK() Although a port addition is coded in a sequence where first all softc information is fulfilled and only then it is attached to the lagg, we still need a locking primitive to guarantee cache invalidation. Panic observed in the wild shows that lacp_portreq() called via lagg_port_ioctl(SIOCGLAGGPORT) immediately after port creation may see lp->lp_psc as NULL and panic. In the core file we will see valid data all around. A race via lagg_ioctl() wasn't observed but potentially is possible. Differential Revision: https://reviews.freebsd.org/D43501 --- sys/net/if_lagg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 9746d4115bc6..554d8c2c1bcb 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -83,8 +83,10 @@ MODULE_DEPEND(if_lagg, netmap, 1, 1, 1); #define LAGG_SX_DESTROY(_sc) sx_destroy(&(_sc)->sc_sx) #define LAGG_XLOCK(_sc) sx_xlock(&(_sc)->sc_sx) #define LAGG_XUNLOCK(_sc) sx_xunlock(&(_sc)->sc_sx) -#define LAGG_SXLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SA_LOCKED) #define LAGG_XLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SA_XLOCKED) +#define LAGG_SLOCK(_sc) sx_slock(&(_sc)->sc_sx) +#define LAGG_SUNLOCK(_sc) sx_sunlock(&(_sc)->sc_sx) +#define LAGG_SXLOCK_ASSERT(_sc) sx_assert(&(_sc)->sc_sx, SA_LOCKED) /* Special flags we should propagate to the lagg ports. */ static struct { @@ -1044,7 +1046,9 @@ lagg_port_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } + LAGG_SLOCK(sc); lagg_port2req(lp, rp); + LAGG_SUNLOCK(sc); NET_EPOCH_EXIT(et); break; @@ -1581,7 +1585,9 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } + LAGG_SLOCK(sc); lagg_port2req(lp, rp); + LAGG_SUNLOCK(sc); NET_EPOCH_EXIT(et); if_rele(tpif); break;