From nobody Wed Jan 17 00:53:49 2024 X-Original-To: bugs@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 4TF6np0zk1z56Sp8 for ; Wed, 17 Jan 2024 00:53:50 +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 4TF6nn51pnz4YwC for ; Wed, 17 Jan 2024 00:53:49 +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=1705452829; 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=tF9ltC3WPhNPDkC1mNgFeBQkjgev2joVwjje6s+BI5k=; b=GZGLwxkg/+BNmSnZMQyE/695yRIxKR3/udL59ELL26B/H0qQwi71H44qi818LxHAhSpbyv wC7W+XjmwOoOZqw3EYNmaIFGMZ1mkP6u8TaFGQMWGFfHuXHQOtIOfvJddIiK3UYmta6sJx 9QZDqajGMtKLxBROqig+Uk4Vc6BCOPGUCm9VDsjQKq4R9lE10F2VIGLPGIZIFZqW9tFBwa oR9aeIwHXfsGqiLngTWJIpes+Z8OLoyzBMLGNyvhwIhJdJr+pcOUPDt5iTXQZspgXZ/mcP nO4uWHA0FNlde7RYpGIaI2U66pmeVOQSnzY3ISkkKRPuIAY/DMMvKwk0ckeE6A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705452829; a=rsa-sha256; cv=none; b=hbpyxUo/jHVe2RbReh4yeEuZUDzYhcwCFCa9MNxBkysXVvq3sJaj+0/0fwm+l0LCrI8/ie AQX0fd5pq1aooKpyJo8zsnFNFrxpg1cmMFb/3a4YE+j+XQRuKCSNO2ffJHft9ty39vPZDx eKMxZHFNzbOKToz5qKqbKjbUy58bABgtq3wLZ8qniNKmWv9SQg4kBvpoK86BwCVxily3ak q8TFPVKbizSDM8UXYreJZEsQp/yC3La33gKCXubhPhUUNYcS/c5Uz+5eJOslu0JBO23z9v jKeuJ62hKdffBg3MEBG0u8iFtmUeK6FUqtFRIwijqkBODPLrpTRO23Zt2nVnYg== 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 4TF6nn425Tz12Wc for ; Wed, 17 Jan 2024 00:53:49 +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 40H0rn3c020423 for ; Wed, 17 Jan 2024 00:53:49 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 40H0rnXk020422 for bugs@FreeBSD.org; Wed, 17 Jan 2024 00:53:49 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: bugs@FreeBSD.org Subject: [Bug 276392] if_wg: Fix noise_remote_alloc() to acquire 'l_identity_lock' lock Date: Wed, 17 Jan 2024 00:53:49 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new 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: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: 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: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276392 Bug ID: 276392 Summary: if_wg: Fix noise_remote_alloc() to acquire 'l_identity_lock' lock Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: aly@aaronly.me The 'l_identity_lock' lock must be acquired to access 'l_has_identity' and 'l_private' members; i.e., noise_precompute_ss() must be called with the 'l_identity_lock' locked. Fix noise_remote_alloc() to acquire the lock before calling noise_precompute_ss(). Meanwhile, add an assertion to the latter to assert= the required lock is held. Below is my suggested patch: --- 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_wlock(&l->l_identity_lock); noise_precompute_ss(l, r); + rw_wunlock(&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.=