Date: Wed, 17 Jan 2024 21:54:57 +0000 From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 276392] if_wg: Fix noise_remote_alloc() to acquire 'l_identity_lock' lock Message-ID: <bug-276392-7501-uZYadzKXWI@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-276392-7501@https.bugs.freebsd.org/bugzilla/> References: <bug-276392-7501@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276392 --- Comment #2 from Aaron LI <aly@aaronly.me> --- 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.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-276392-7501-uZYadzKXWI>