From nobody Wed Jan 17 23:30:42 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 4TFhvQ2Vglz572dq; Wed, 17 Jan 2024 23:30:42 +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 4TFhvQ22ylz4K5N; Wed, 17 Jan 2024 23:30:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705534242; 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=rubHbPevEt7rxFZHB/2X4LjEh3AXiQBSZtXTo+JuOr0=; b=XlQNX1y0dO9XZn/5JOE/WyrHOYDlWe8kbhui9u2HJchGooALMW4doMNw/BVcFE/WhA6xW8 zGimi9R6ijtK3if3kqPAFaiPdVz7Z/VgQHvTisD4UXX9HpQNN2Doi0iX5McmEiK3hGyUGM 91hL8z36tY7tnQtWPiFFZuFFsq6WZ6al6s5fRf38kMMOyCBgQEpmjlQZXKXqK9bI2F96px 9YOt298PtsxEFmUS16HGPF5JywK6GU8g3dm6j6KC33BXMDzivoCsleuRJlAddUVi/veykV yB30dVrB2KddlAGNV8czIP7WxsjsQV8swCRsauMnwNiVe0spBI7q8t2gi/S0mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705534242; 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=rubHbPevEt7rxFZHB/2X4LjEh3AXiQBSZtXTo+JuOr0=; b=YIi40j1UPSVqwzifQfumKPf6ho0d83cqd9t8ClbMIFAnOp10zI7uacEbUFo6mvatfW3F7n oeCZpiaJert93/DKU6dWXFzutZwCJXWGrv1S/LwJbIF+FcHZWEZzByg+3NP1NV1bKPbYJO gTF8H/UTBBGfD8NfExUaiCXdVGK98OPCAQmqhslgVSLjRaqruq05vU2rcW05kwFuMPzt6l IROdr6P5zHahPACbrvY0mCRdNaf9fd9mCekGB3PVGB/jlVXYJvIILroreYVNXAFgfUU9hb qZvzNOpaWmE7yQ+yahpkT2tW+Ok2BiNymdDEpoT0cz4mvlFSdhPavLOppVwcUw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705534242; a=rsa-sha256; cv=none; b=uya8oQdISZ15QK4mCnWFWrqiIMC9lT+hYTJw4YlVR6MNPViqNf8OGtXfo/ZwaWAL6BhnLj xuPYK40Sv3EqUccCKzLKhQnK+LfmPdUg9pjdPbJp1PEAs4MYiSaH7aarYKu58vpi4rptRd 6FLurZzyKplpvZceIQn8yCJQ0ZCMHGhfCE5DMLQvKhHfKM88SjkQ58idjVL78YJHYYG2mr e6KCSvXfgTvEcGkMBwEPwAjrk0C4BUj65qUhcaLaoRWvVKU2LYiSQ0ikeyU+wp1bDOI4Vt /0/Wi3otrREqTxeq/TaKIiv0ZmpHo2Ej8u+nmzpVEJUVCN8Id0+NPWgG3rmrzA== 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 4TFhvQ188tzjwj; Wed, 17 Jan 2024 23:30:42 +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 40HNUg5H078588; Wed, 17 Jan 2024 23:30:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40HNUg1q078585; Wed, 17 Jan 2024 23:30:42 GMT (envelope-from git) Date: Wed, 17 Jan 2024 23:30:42 GMT Message-Id: <202401172330.40HNUg1q078585@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 7a4d1d1df0b2 - main - if_wg: fix access to noise_local->l_has_identity and l_private 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: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7a4d1d1df0b2e369adcb32aea9ef8c180f885751 Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=7a4d1d1df0b2e369adcb32aea9ef8c180f885751 commit 7a4d1d1df0b2e369adcb32aea9ef8c180f885751 Author: Aaron LI AuthorDate: 2024-01-17 23:29:23 +0000 Commit: Kyle Evans CommitDate: 2024-01-17 23:29:54 +0000 if_wg: fix access to noise_local->l_has_identity and l_private These members are protected by the identity lock, so rlock it in noise_remote_alloc() and then assert that we have it held to some extent in noise_precompute_ss(). PR: 276392 --- sys/dev/wg/wg_noise.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/dev/wg/wg_noise.c b/sys/dev/wg/wg_noise.c index 3db74ac9580f..a727a2f99d15 100644 --- a/sys/dev/wg/wg_noise.c +++ b/sys/dev/wg/wg_noise.c @@ -281,6 +281,7 @@ noise_local_keys(struct noise_local *l, uint8_t public[NOISE_PUBLIC_KEY_LEN], static void noise_precompute_ss(struct noise_local *l, struct noise_remote *r) { + rw_assert(&l->l_identity_lock, RA_LOCKED); rw_wlock(&r->r_handshake_lock); if (!l->l_has_identity || !curve25519(r->r_ss, l->l_private, r->r_public)) @@ -302,7 +303,10 @@ noise_remote_alloc(struct noise_local *l, void *arg, r->r_handshake_state = HANDSHAKE_DEAD; r->r_last_sent = TIMER_RESET; r->r_last_init_recv = TIMER_RESET; + + rw_rlock(&l->l_identity_lock); noise_precompute_ss(l, r); + rw_runlock(&l->l_identity_lock); refcount_init(&r->r_refcnt, 1); r->r_local = noise_local_ref(l);