From nobody Sun Feb 18 21:11:27 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 4TdJJ013MBz5Bm6l; Sun, 18 Feb 2024 21:11:28 +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 4TdJHz49Rgz42WP; Sun, 18 Feb 2024 21:11:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708290687; 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=vqFtkvz0jEmR+prwhPX9HxL7ZEpXcASakVU0AxzfyBI=; b=MDEJfD81NfWT0swO2uv5rNF+1MujOwfEmasy8olj4lXnMtVFoOkylcM8MGYXRlyDoWYfUy l3ClIFWhCkx0BZmxwNmAXXEoHm6sC+Gf1GikwmjFh8xV3MXiRKrYdm7vwC7pOBneSlhFUp 82nGuyisPj76OHotqcL6RDlds67qEGdx+iWakUr7xDaYq+hb1+zVyEE40eRSIMg+l7fJSr TUkg7S+5e/DlmzLqc+JEfNc8L575Dq+QcbZ65BLeuh98Ww7wOGEWewKRPt1VtSnjTxGSXN EmQ1PKpvTDHJTHACgwD4mJa8T1kexU8kBhVzxQTYxIouWsR6+qqCcdlxQebxUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708290687; 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=vqFtkvz0jEmR+prwhPX9HxL7ZEpXcASakVU0AxzfyBI=; b=cQcXsP9GAAZCHwXZtdQOmByPXG8xjFc0/stB7xV5Xb+udSNh4/2yB8BOvqwFnudctlMu+B 3yLl4/eli296ir3HDW/rkZ67YVz42P/Nk/dPWXApgG126kNU6oPnrL1TmsvHbd3ZSvA3+y TzZFt3R5rkmf4EGwy2E1j663VLL2GCrB1r7QfeagSSS2HeEBTZsKkdXeiA+o4oBU844o7y 82Qedj3TbeZmBGk8N6DGGyIlAcWbmdcIw896zBzCJQgRoFHF/6r5d1GiTi0jHndOMWtR9f KX41Up3HfxoFYFrwgc9zR4svNurpuqLCP17hVxv8PjQXo30fpp2KU9P80/NWBg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708290687; a=rsa-sha256; cv=none; b=YCIwivrocK8bfNqach53PpvAgFwluDYZc0nXjDvsftB9h86UgToJjMXKr2whkGWRFfcGFb 6Or52kpw3uGR/PfL27Y+s1NivtuKEqeZat9GyGO3gI/HoN7R/HCeGWW5HcfYEAu07rnoNq exACCbFSFxAHnUFnVfoCp9a6dgUc/zOynyiQeqskjzrBwaFng9ivniQBeJtM391bDL7rM/ 1Bzu9KLZo+UHi03dfCK6Zc6Q59ofgWhszIqfSUv6IwJ0bAESl5EgZlfawY0Fcek0+XwJMM upBKdiN6d9RCeT/yYI3KMf2x1APB4a62Er5h3IkcBPlO1pNQ0zx4Nl3N/T++7A== 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 4TdJHz3DVwz16Z5; Sun, 18 Feb 2024 21:11:27 +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 41ILBR6o015892; Sun, 18 Feb 2024 21:11:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41ILBR2V015889; Sun, 18 Feb 2024 21:11:27 GMT (envelope-from git) Date: Sun, 18 Feb 2024 21:11:27 GMT Message-Id: <202402182111.41ILBR2V015889@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 680fd9feb104 - stable/14 - net80211: fix a NULL deref in ieee80211_sta_join1() 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: bz X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 680fd9feb10457525752841586c2d1c3bd740e23 Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=680fd9feb10457525752841586c2d1c3bd740e23 commit 680fd9feb10457525752841586c2d1c3bd740e23 Author: Bjoern A. Zeeb AuthorDate: 2024-01-16 18:53:06 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-02-18 18:31:16 +0000 net80211: fix a NULL deref in ieee80211_sta_join1() When ieee80211_sta_join1() gets an obss without ni_nt trying to lock that will cause a NULL pointer deref. Check for the table to be valid and deal with the obss node accordingly. This can happen if sta_newstate() calls ieee80211_reset_bss() for nstate == INIT and ostate != INIT. ieee80211_reset_bss() itself calls ieee80211_node_table_reset() which calls node_reclaim() which ends up in ieee80211_del_node_nt() which does remove the node from the table and sets ni_table to NULL. That node (former iv_bss) can then be returned as obss in the (*iv_update_bss)() call in join1(). Reviewed by: adrian, cc Differential Revision: https://reviews.freebsd.org/D43469 (cherry picked from commit 8a5a3e3d0436a2de9dc5c2c10bd9a471b6338233) --- sys/net80211/ieee80211_node.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index 123da34ad3f1..f6bb4245f543 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -867,11 +867,14 @@ ieee80211_sta_join1(struct ieee80211_node *selbs) struct ieee80211_node_table *nt = obss->ni_table; copy_bss(selbs, obss); - ieee80211_node_decref(obss); /* iv_bss reference */ - - IEEE80211_NODE_LOCK(nt); - node_reclaim(nt, obss); /* station table reference */ - IEEE80211_NODE_UNLOCK(nt); + if (nt != NULL) { + ieee80211_node_decref(obss); /* iv_bss reference */ + IEEE80211_NODE_LOCK(nt); + node_reclaim(nt, obss); /* station table reference */ + IEEE80211_NODE_UNLOCK(nt); + } else { + ieee80211_free_node(obss); /* iv_bss reference */ + } obss = NULL; /* NB: guard against later use */ }