From nobody Sat Jul 25 23:05:54 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BCFB2BEC55 for ; Sat, 11 Jul 2026 21:03:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783803789; cv=none; b=grnvZofl7mdctMEl4nr4m72DIjvByuVJOV7zyWEY1JTniXbIdrqVpfC7HgHRrBElCy+5IwjDEVvbq4XFTG/HzLzN57/8Wqsrhq3kjBMkBswHdN23bO6J61DHESW2EyzKkfpFnLFrq3HYqghlwKXTos7R66gaOWDWYIQJ/oDBOnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783803789; c=relaxed/simple; bh=TtM5obUM1rq7yjPXODdVw8cx3/1jpnLe3AZP6T0zsyk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Gj07tFFohx0+mpl6JxwlHVB23MRg9M+8/eOWvaI1LsJjKCD2TQjEUYidUOHa8pma6ws+2QlKSme5kwOXUGyG02rbbA5QXKejd9aZYfdrZeuGFIevvyPyqWLIz60ktmo/Qbq6LSV/9iDpcaf0c6BWWUIE9hmL7VF9LvnGQQ4YF+c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu; spf=pass smtp.mailfrom=asu.edu; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b=TmugTzPb; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.b="TmugTzPb" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-8454160043aso1999212b3a.3 for ; Sat, 11 Jul 2026 14:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu.edu; s=google; t=1783803787; x=1784408587; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=4peY4OdMSUAxRNTuJFTDFx6Yk17ghd0LBWVFX38rS74=; b=TmugTzPbUjZ4AJubOiwYZtLm8jUIQWU0e+uxJlg7zxmEmVwgCPLMgpQo6MZJpKP6ol vi1SjihBaFpY/0TcbtPEFa5Bx6iDcmp1RKzZbNoXl704+j5OH6483dmFfgVEWLAT4shf NovwK1OMiDKPIN9SNrY27UmbMkbkrzDTh6BA0+Rk8rtHYeKU0W2k/ZTl3bazfljlNwmG 3dgS15U96kIooTMVGsvCcEEBbgBcyaFrpXEG4729mq6WsEi4FG2QjjEnPuD7YjH/CgFn UCxZBw6Q+FlvemFWh3YUlqvwVFJ6uR3MDyxiRb1r0/O2S+amptkcZXAxCodxF1JmgxxF NQ/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783803787; x=1784408587; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4peY4OdMSUAxRNTuJFTDFx6Yk17ghd0LBWVFX38rS74=; b=nDUHNpP7iNNzdPcDUacXLES8P4uCs8iGsa9cYIP0rF6YVG/NYvyu+nzmSlhxJy9NfD tNGusIU63zuNP+9DRFU9DjiySdst84e06BNQiKL6pUcUFhvMjmUdfSqcws1dIFfmOoiO cC6wsGKZkGNGBrh58rEnlJ9tlXr+Aj1fMq9USyTchLe7jOayPckB2vWJjsaaJtbwpVYd XOUUsTw+JDCEY+2frOW1dGWDugP9oPvwPePr6NeGgGN7tW3axtB0RlNCDUoKbD3L36WZ VnjSwrDfKtCMbqe/LsSLP/PtQ2A2OAQ4epxNDA9EFEpYQF1nNNJ+uIYvqKM0P44oijXH vY/Q== X-Forwarded-Encrypted: i=1; AHgh+RrMmh1aTp0fJURlcrE7M2afrDjtPpGgAHcKqqWt8adMCMkDKb2zYWioXY5GI8z7VWSh2NLqpQYhLKysNOI=@vger.kernel.org X-Gm-Message-State: AOJu0YztitBxRq0+cZdkHuon2vkTeMRAT2urHiR9062cj69WdKvpnP26 dvEiPx9GrtqD+f0FbpkH8fU5daKsSL4YoALQYQ60AZHWNFgCBva2Oxs2x+J1RcmTZQ== X-Gm-Gg: AfdE7cnN17AW+2C2zGMDOpRXqVv+UjXdUw5c2h104Tka6r6xDbs6oQM1P0a7UTnrBx2 jqpUxdUKv775JZxVhuzd+fXfJGseVDXTAGwLFDI5bs337xPc2SQIUTLgWhp4eOUeQexiTXckqGE +tpbWJcp6MLotAFKZOS6Drt8UoyXMuDa8LcjhtXb+YODf0+mOv8IyHerDZwNyclS9fIrJWVeV/p 3jL31pkzchgjLWuJQ9T6L51IHv7StHX76Ccs/YjXN4/XSpZrfOIQcCjF8TLe5BHS7uxdh1/RuHW AI937oU53RUvDF2TFMxR+8kNXrOycANif2QyAt4uM/5eztdyWhClOKYQ7H1ZuMGT727CMLNqTlK 7Eh3PtbjmN4PF+jxMr+sHthnCFi39hqG+JPE1EAxaqAlKIN5sQ1AIg57muMYS8OhydvJRHLABlg == X-Received: by 2002:a05:6a00:8d5:b0:848:59fd:2f4d with SMTP id d2e1a72fcca58-84889799eb3mr3677687b3a.73.1783803786604; Sat, 11 Jul 2026 14:03:06 -0700 (PDT) Received: from p1.. ([2607:fb90:ec9d:8e39:1e2f:f164:750a:ec94]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-847f6ddc974sm12074248b3a.60.2026.07.11.14.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 14:03:06 -0700 (PDT) From: Xiang Mei To: Johannes Berg Cc: Benjamin Berg , Gregory Greenman , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Weiming Shi , Xiang Mei Subject: [PATCH wireless] wifi: mac80211: tear down new links on vif update error path Date: Sat, 11 Jul 2026 14:03:02 -0700 Message-ID: <20260711210302.2098404-1-xmei5@asu.edu> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When ieee80211_vif_update_links() adds new links it allocates a link container for each and calls ieee80211_link_init() (which registers the per-link debugfs files with file->private_data pointing into the container) and ieee80211_link_setup(). If the subsequent drv_change_vif_links() fails, the error path restores the old pointers and jumps to 'free', which frees the new containers but never removes their debugfs entries or stops the links. The debugfs files survive with file->private_data dangling at the freed container, so a later open()+read() (e.g. link-1/txpower) dereferences freed memory in ieee80211_if_read_link(), a use-after-free. The removal path already dismantles links correctly via ieee80211_tear_down_links(), which removes each link's keys and debugfs entries and calls ieee80211_link_stop(); the add path on the error branch does not. Commit be1ba9ed221f ("wifi: mac80211: avoid weird state in error path") hardened this same error path for the link-removal case (new_links =3D=3D 0) but left the newly-added links' teardown unaddressed. drv_change_vif_links() can fail at runtime on MLO drivers (internal allocation / queue / firmware command failures). Remove the new links' debugfs entries and stop them before freeing. BUG: KASAN: slab-use-after-free in ieee80211_if_read_link (net/mac80211/d= ebugfs_netdev.c:127) Read of size 8 at addr ffff888011290000 by task exploit/145 Call Trace: ... ieee80211_if_read_link (net/mac80211/debugfs_netdev.c:127) short_proxy_read (fs/debugfs/file.c:373) vfs_read (fs/read_write.c:572) ksys_read (fs/read_write.c:716) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) ... Oops: general protection fault, probably for non-canonical address 0xdfff= fc000000000a RIP: 0010:ieee80211_if_read_link (net/mac80211/debugfs_netdev.c:127) Kernel panic - not syncing: Fatal exception Fixes: 170cd6a66d9a ("wifi: mac80211: add netdev per-link debugfs data and = driver hook") Reported-by: Weiming Shi Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Xiang Mei --- net/mac80211/link.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/mac80211/link.c b/net/mac80211/link.c index d0535268962c..dc68144dc363 100644 --- a/net/mac80211/link.c +++ b/net/mac80211/link.c @@ -399,6 +399,10 @@ static int ieee80211_vif_update_links(struct ieee80211= _sub_if_data *sdata, memcpy(sdata->link, old_data, sizeof(old_data)); memcpy(sdata->vif.link_conf, old, sizeof(old)); ieee80211_set_vif_links_bitmaps(sdata, old_links, dormant_links); + for_each_set_bit(link_id, &add, IEEE80211_MLD_MAX_NUM_LINKS) { + ieee80211_link_debugfs_remove(&links[link_id]->data); + ieee80211_link_stop(&links[link_id]->data); + } /* and free (only) the newly allocated links */ memset(to_free, 0, sizeof(links)); goto free; --=20 2.43.0