From nobody Wed Jan 17 21:54:57 2024 X-Original-To: net@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 4TFfmy3pTdz56q7t for ; Wed, 17 Jan 2024 21:54:58 +0000 (UTC) (envelope-from bugzilla-noreply@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 4TFfmy2lgMz43py for ; Wed, 17 Jan 2024 21:54:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705528498; 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: in-reply-to:in-reply-to:references:references; bh=fVx0e43x7Dd0lx3CNXhILotlSVlTJYE9hb8NDY4oDWk=; b=nfP1+7LxF65aqclMYvkqBco+vL/LRMpJ+T0ex9yXG64DLGkF+im29grgOJDHBY5I3F4jHY 7mtR6s4XFTVyov9DvpSb55uTf7cDfGC8r70U11KDK498UShR2xTHI7RDCB7ZEYY03t2qfY eqANueASG1QO9Rpe32icX/1342g6YoqmKal3KfZvVBGvR0GNzSXG02JCvnm8JpBGEBqySf /VWl2iJ6QG4tvk5pOUF4qEOGQtE7kXNM2LfxnVirqxHTsbQPx7WdIFXos4eKjNMt5XyCIr cJJJP/PHExQyTwhSED4ZHnoILJZ0ERqNGIeyv7yEwNt0tY1HEi0e+23GOaIiog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705528498; a=rsa-sha256; cv=none; b=EYFVEabPW4xiIP9kOZKMtutA0eNYpcFVu+y2dCodmC67fXX1fhSNBjLr6w+r4q+idsF9Eu N7gsZXmXpgpryas9WAKh0ZXwDT1skbkk0u1sfMbmZklL1gwTwKS2cqUfnfanRnX+PE5N6C OlQ28i+XNigndGJXLhD1hGgT7fF0q44Nb61SMEhJyYVCY8LDBo6kexL9oMTJGtfYhgEbTI tZ69oncijettPG0hpm1TZzuj/oymKTR0A/OKxxrxSMK2ExZBYbazMlZHGMu2mNcXKoaRN8 vFfweX78+QcJMYRUHDzOX0/82YKnvE1deMB8z5gTtfp6abk92/wgc2kEi/AWAQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 4TFfmy1ppXzglq for ; Wed, 17 Jan 2024 21:54:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 40HLsw26041523 for ; Wed, 17 Jan 2024 21:54:58 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 40HLswgZ041521 for net@FreeBSD.org; Wed, 17 Jan 2024 21:54:58 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 276392] if_wg: Fix noise_remote_alloc() to acquire 'l_identity_lock' lock Date: Wed, 17 Jan 2024 21:54:57 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: aly@aaronly.me X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: net@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Networking and TCP/IP with FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-net List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-net@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276392 --- Comment #2 from Aaron LI --- Yes, it should be a read lock, and that=E2=80=99s why I use RA_LOCKED in th= e added rw_assert(). I made a typo in the previous patch. Thanks. --- wg_noise.c.orig 2024-01-16 22:53:33.518906792 +0800 +++ wg_noise.c 2024-01-16 23:21:16.069687841 +0800 @@ -281,6 +281,8 @@ noise_local_keys(struct noise_local *l, 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 +304,10 @@ noise_remote_alloc(struct noise_local *l r->r_handshake_state =3D HANDSHAKE_DEAD; r->r_last_sent =3D TIMER_RESET; r->r_last_init_recv =3D 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 =3D noise_local_ref(l); --=20 You are receiving this mail because: You are the assignee for the bug.=