From nobody Sat Feb 03 13:54:00 2024 X-Original-To: dev-commits-src-main@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 4TRvJ91CQlz59R1K; Sat, 3 Feb 2024 13:54:01 +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 4TRvJ86lNjz452x; Sat, 3 Feb 2024 13:54:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706968440; 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=O/WMzj9QfR7mwdnIyuFAh/ltCs0gHBmxAg7UKCv8g4Q=; b=fXxBBmOFv5L7oN7MXYp+7GfHTqSsG+oplpQZQK+V46wj4lG9FozZxXB6cxqe9xfh67T+tZ a2IloXVsaj9AznuU7s7e5RiLyh3os+/SrSb8T6/Q81VS7zDq9X9T6VsZYaGVju3Po5ei9x dFYEP2Ib7bnAOhlqoBsRQRXVXjXgGVPYXuI+C9cYcxUnrsp4IV2TYnsz1H4OmKH+JW8yXT BsxwmQrb0TpM7t5y2umQWDiSc5CajBuxW14wxT8RGe5K22ci7JT7bShem3bvQs07z1hirJ 7dDvaZIhYSjomNbqSeO11uOSBL/kO8DD8TYg5ETTO4NETqfe+L865GdGYStWgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706968440; 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=O/WMzj9QfR7mwdnIyuFAh/ltCs0gHBmxAg7UKCv8g4Q=; b=XfHm5NuVXVDZ002kQjb6zID27IYeJEt739XpfRqKEfpC29E+FNdzss9PgEMFHOwprnssNr E057PI78unBgNg4QA+eaiUlnjpsuU9Kwz6FqDJFcMNOa8CKix3Bh0UJAAQhK7VLzxFsZjV cdtXSM+ra2h6BFYyjBKpi+p4Ypa9QcrO2ODcHoyVguR5S3MZfsTjtYNmfooHhsg25B9XjR fEeVoMZmE1tus25rRKt5G/Or1qqNNNsahuXQZsvH3SC6SZx9EpptoYoFBFHYeu1r+/DAEr ii6CpgwRUb1q2PFQH8MQ3uVJriuCpjBBiJG+eRwLCUlJ5blNMKyCgPqZvyKH5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706968440; a=rsa-sha256; cv=none; b=LP86HPdrEwLK5zwUskrIT4FWdeLl+enT3sTrNUlilcgdCZIHId/5xsvWmXrX9EIbL/GGoq LgOb80d2ZPpbqAo3z45WpZzZjezioUE4gc5QOPOzBXkpFtnSiPjFj9yLC4mnS76QaePEH6 2jHJ6jBPgLmDvT0UBkMglbCo5XVCmxy1pSsbjg47FsiliWdmqWC7u76oyMIL0tPbas/PDl CnHHNBVIhmY1tBAFdi64qpt8qTGYpoHNDT/qMoKD6Jh5GFemmm8HB5TPCtJyItlcJA/1u5 OlIk/gmSwSLf8SStWgWnZ3yJhgfGcL/trdXcNlLW7cdHYJ4RnEjJJIXOqtLogA== 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 4TRvJ85nVpzGl7; Sat, 3 Feb 2024 13:54:00 +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 413Ds03x055936; Sat, 3 Feb 2024 13:54:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 413Ds0Ak055934; Sat, 3 Feb 2024 13:54:00 GMT (envelope-from git) Date: Sat, 3 Feb 2024 13:54:00 GMT Message-Id: <202402031354.413Ds0Ak055934@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 8a5a3e3d0436 - main - net80211: fix a NULL deref in ieee80211_sta_join1() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 8a5a3e3d0436a2de9dc5c2c10bd9a471b6338233 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=8a5a3e3d0436a2de9dc5c2c10bd9a471b6338233 commit 8a5a3e3d0436a2de9dc5c2c10bd9a471b6338233 Author: Bjoern A. Zeeb AuthorDate: 2024-01-16 18:53:06 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-02-03 13:52:33 +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(). MFC after: 3 days Reviewed by: adrian, cc Differential Revision: https://reviews.freebsd.org/D43469 --- 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 */ }