From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796544124; b=Qs3NCvYPKUxhC/u4tw3WGnhA2YHXT9E3B1ozTdPAgRl6JYwdr/nL9xEx1WNsl+qr+56D tcJZG8ot/SMsn7N9SST0HanomO5KRvQ2WAl/h6kb8lPncVURfzZnbl15TmOEerlCQjDTg M52eWjlHn0ICvFgWX8iwZu6VvYK7ulzpZf+dYgkHhuW0hzoJci/3CcFPb4/xt07L2b9DZ oZOrbhbEq08OiXiTq33JoP9F7a4PJe5rhcB5H+AVFZIaCI0rqoGpvYMWx3ZKffwcSuLhp 8Z/aFseExexjqR4l1jMsqXK5ez6mF32EAEVOm4uBeLAPci6X78WlsegDsfZWt3XcniA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796544124; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=MJRh2ihIMWQ6I1BqyhaD3fMbHaouQQwU6lmnP//dxwk=; b=qiUsf/rAa+DF4KmzaUQ1UynTM5PBBSeGtk4jBmDLXVGRn9cC5XzrAikmg0ocFcsWW5Z1 d0E5A5SanHu3sWXQItfIuOrsrQuAciL3+qc0Gl3mmFYeVkmQCUNoVZmpuGCqv7FsKxOHl Hknv0Yopuzp+G0+Vqu3keS4nWQvTMDli9lrOkwnDiL0cVafleFbXjPXgviNmGtrGo3Low 8/HRY0PyqgOB0Te8pk2YkYmAUNt6rqop8G4aXWMq7xMvVC35Jam6nrHJcT4a1Q8trl3Mm 8JcsGk59VS9kq4u3H8bO1wy5PiUsgvzrOyyZsragkyJ0hgxa+UFaCyCUrQ9LHNPWWRQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=gl5kVEgd; arc=none smtp.remote-ip=74.125.82.172 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7751606A31F for ; Sun, 6 Dec 2026 08:02:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D7751606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=gl5kVEgd Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-386c71feeeaso2997265eec.0 for ; Sun, 06 Dec 2026 00:02:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796544123; x=1797148923; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=MJRh2ihIMWQ6I1BqyhaD3fMbHaouQQwU6lmnP//dxwk=; b=gl5kVEgd9q5RgcVxC1cend5yYh7raHgk2FEK+0fvWmN7OOc7UGjp5z5OitkkkLhZvf 2Wm4VWxD/rExKHkg+qnsMKPvHy0yrDwacL2h2TUXZ29hYTc6XB6ZGltJkHoTUg5P22vs ginCBRv9GQYFayQKQCexji9++tIRadDSJcfBteraLWmo1r2VL/oMSyvxaDZQ2nOC1ZJE 9aoLkmeNSboTBm/nzwRDpxgxSOp73RgX00oqiUxmxfYSjhsGisZXL71ThPZIrpqa2k+n EBNsRO0iQELN8S29/jqWzXim04+VpxyKqjYim7SEoOzZAO4AA4goDZ1fDM2zljDEKX8J DIlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796544123; x=1797148923; h=content-transfer-encoding:mime-version:references:in-reply-to :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=MJRh2ihIMWQ6I1BqyhaD3fMbHaouQQwU6lmnP//dxwk=; b=BhKHG6Wb4qTtZsgcK9NT7xlSTSrm40VOWXS5072S7YgpQoyxCaGpt5dsdj9s+M2EpF b4gzJNOvKcxHOdQEea/yr4i0SiFzJZ9Ua19CS7DNq3dD89UqXk4nqmBKxI5XfeAQtzLm IaqtQMrTSYVZyLWXyuLUPhnErJO+fM01b2j98FKYMzeve3orpJerUfLj3Dmu1JjyAjgD 9GZ5A8EfKATxJDIm/5fLc6sueZ7XK928fk0v9Nv9hnrdbIEfCvznt53qV+50KQYFgXUf Qkh4ZcPvKURdz/SnO00+uWvkrefT1dJ/sAjJU/Cki2Eh73PAlGrvZVrI2a5AGCsZWNQ1 heyw== X-Gm-Message-State: AB4q+uEA72JkRNB/Zwh6EDm93q61DjSprPDAj0eaFAL2T1mbHYN81DZC ZpBmla087Si1LO18W7YSAfY1ebe262IRoOxO7gG/JS2mW5aOIaDAenKIsPWPC0L4ouHn7w== X-Gm-Gg: AZFdTZc/lTqDAfdGwcXEMeqnP/fFYK16BYNCdw2V93Kk7hUBMlUXbxiNhNmclhjGayq XqFcxURjNTOM5vclDfdy6fU9koX4j139Bo5sdYxvyO8rfQZ9pXddekQbdm2DGeATlXlAUySOFJF 5Kca6F9gEJBbbcMhk83eIxOYbdl0YMWsgfiyj47OgPRsPWGLNVpD/m6RV4y+PzDdMYlI/QpA0sP KfYiGNKt5HA4DBI9WGQrZ2Ym4YDM9MM4EusLcnhoBOPsyACvyCYbAsqgCeM5FxHZUF9SK+hYFXf xB+43OdV8iJ+HSPXa8lq0KDidEX7B5VWTRbHQsvzQRGAfpNDBeYTELCKJ5QVvXiBwDGLMvKpud2 zjWJOxY/dexu95Oi+mFsI7duf5cNbyMRIB/w6anlclU96aZyxaDnzOmVeOfW6WROXw9wVFdzePX LJHWqasrxWXRS9Nr0oba/mPlDTiDx8J65nDU2wm2Xe+mZKsbYUX79kRxb1OCIzsGt3fd0T4vkUZ EhOaWd29Wp7bJYT0IVFqVnsxeHQkjzwS1v736OO1618witgucO8Vr+ql4MVin+w8dXsJHDiM1Tb LIeSv6Qc5SyysVnUohI= X-Received: by 2002:a05:7300:72ce:b0:36f:202c:48 with SMTP id 5a478bee46e88-38752155739mr9994680eec.14.1796544122731; Sun, 06 Dec 2026 00:02:02 -0800 (PST) Received: from fox.. ([43.242.224.196]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875218c602sm38935351eec.7.2026.12.06.00.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Dec 2026 00:02:02 -0800 (PST) From: Roshan Kumar To: linux-wpan@vger.kernel.org, netdev@vger.kernel.org, Miquel Raynal Cc: Alexander Aring , Stefan Schmidt , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yousef Alhouseen , Sashiko Subject: [PATCH net v2 2/2] ieee802154: hwsim: free the current PIB on registration failure Date: Sun, 6 Dec 2026 13:30:36 +0530 Message-ID: <20261206080036.2769662-3-roshaen09@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261206080036.2769662-1-roshaen09@gmail.com> References: <20261206080036.2769662-1-roshaen09@gmail.com> X-Mailing-List: linux-wpan@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit hwsim_add_one() stores the initial PIB locally before publishing it through phy->pib. ieee802154_register_hw() publishes the PHY before creating its default interface. A concurrent request using NL802154_CMD_SET_CHANNEL can replace phy->pib before registration fails and queue the initial object for RCU freeing. The err_subscribe path can also replace the PIB through callbacks run by ieee802154_unregister_hw(). Both paths then reach err_reg, which frees the stale initial pointer instead of the final published PIB. This can free an object already queued for RCU freeing and leak the current PIB. At err_reg, either registration has failed or a successfully registered PHY has been unregistered. Fetch the final published PIB and queue that object for RCU freeing instead. Sashiko found the issue while reviewing another submission for the teardown bug. The analysis and fix were prepared with OpenAI Codex assistance. Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb") Reported-by: Sashiko Link: https://lore.kernel.org/r/179492373789.3136.2399679338709401263@kernel.org Cc: stable@vger.kernel.org Signed-off-by: Roshan Kumar --- New in v2. The fault-injection test used a temporary, unsubmitted module parameter to pause the second probe after PHY publication. Both interfaces were opened to replace their PIBs before task-filtered failslab forced hwsim_alloc_edge() to fail. An RCU barrier drained all deferred frees after every round. Patch 1 only: - one deterministic fault-injection round reproduced the KASAN double-free in hwsim_add_one() Patch 1 plus patch 2: - 100 deterministic fault-injection rounds, with no sanitizer findings Sashiko report: https://lore.kernel.org/r/179492373789.3136.2399679338709401263@kernel.org/ drivers/net/ieee802154/mac802154_hwsim.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c index fc2b7415afec..056e64b31b91 100644 --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c @@ -988,7 +988,8 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev, err_subscribe: ieee802154_unregister_hw(phy->hw); err_reg: - kfree(pib); + pib = rcu_access_pointer(phy->pib); + kfree_rcu(pib, rcu); err_pib: ieee802154_free_hw(phy->hw); return err;