From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796544124; b=QKZNG6BoNtp+4pRIqcc//qtf+cuqn+yg7fyhvvyJ4d3PJX+I5eg9gh5FFXrNmTKBgQ9s T91y3oQnfjHmKH6iuoOEo6AMBID4DzsdKMEyTule/zyasANphFlQbdhGwEyB6KTgFc9Kp 7DduMx6L5FPsVPjSNH5m9dLftFb1ia5CIxgIuNSVkm1jcJskZbxPbLRWlGl9IH82IcfFI RHqMm+oNqCwjDzi2WdqAGy6rm8ovIjTsPJuQZhXs9fJRpuw2izDvoR8shAxsSvoMld2A1 y46pnxLf83MQJuAd7HegYE4ek73VzQ9ARDHzA1xyvZ5e4C5QBwjqfLMAgGU79LWSPaw== 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-Forwarded-Encrypted: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=iwrhGpK7gftWELv7Q08xoLmjLKAgcIZKQXcBvxHM3KNJm+nFf1AgzN3TVahr+Ychffue xyL5SKu1UWk90I6zcteq4Cln+erDhJnUk1uohjpV7ejSSItIvRZ3gz0nhpt4wK0cdOr7I 2eLF4+9dar/c60MU/ZGEGl681bcLcoeHuOYc4OWqXSI4eBSn0y42OvT6ZxhJ9+EMLRojm 7gA0JtXMbhkJwDovATzMX7hg2uRrQ/82joZsFlvr3gBdbUl9sfW9UPBKGPLZ0qA3pHTRu VfWI1zHKdpTDXSnM0/M7kmy49g/08H7riWKx2EiDIIamDbkX7ougcybMIKIIqTTd8qQ== 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.177 Received: from mail-dy1-f177.google.com (mail-dy1-f177.google.com [74.125.82.177]) (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 DC7AC606A321 for ; Sun, 6 Dec 2026 08:02:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DC7AC606A321 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-f177.google.com with SMTP id 5a478bee46e88-38431138772so3349431eec.1 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=um0Bv/5OMaDlHE5IqwiWtTvzfr+ZeMGzkihBl41ziAHhQZe56ojM990XH3P+5WeLva /HWhinYXDerq8R7mGJR0nJHCsAgRHEdflg/ftQ1F4lQD2Sx9RPg5Nt+w1hYQ4XPtbGr4 mcyljmSyzef0ijof0+LTvFULXILbOVlPCn7I2C4i/G1/N6XKb9zVupR3EYEHfXQPXo21 r+8eC0tyzm8g99WT6VFQffdr6fUFSt1edin/+OsoSMbiH6TIkqhJbiMQJiOzegCBgKNV F/uVZPuUt22VcWd196EaFuIaFuDBHhk2WCeM0K99KcUPXZo3fPfgrtz0+gNW3ZZUbe7F Ps3Q== X-Forwarded-Encrypted: i=1; AL+hErEODA/zDmHMZQni9toWeBAllu1RSk2ZQLbRxkVfw3v11vhI+IODi0aVU1fV8itdf72NB/eAtYA=@vger.kernel.org X-Gm-Message-State: AB4q+uHsus/NWw0eLiYkerWPQqABcjfTRTdkdkSsGwt5DhTyIUnf6mhp RWCsrx7xszKuQpoViVhaLKMIXPfRWQ1GnsF5nrnrYcGBF7rAl4ekReGw X-Gm-Gg: AZFdTZexX5GrMhFdSwLeSVyVPeKyrrSZjfhInKwlur5ZD+tu9z7oKgrqTJebAfqGZgs CudRS/Rc6W6v+pOSS7FLNH+zf76lFaF4B5e5vd9chQJbJfdb66JwC4Tf4uvRtA1bsKmFc0BT+pu VJZ8IaZ0ablHBcOA3F33Ykl0BMDKLl93iiPZsZ7rvl2tfPssBlWubvSKm4SJhQK4WAD7gseqs6Z N8CVP/dvAYGJrJ8J7rh9VaMaFsdnO98FRnA864rWRsw3L4v8nS/U8KvrGkgXZioPJihFGuyTJ6v iQEOmjc4MIjJQhKpa0+QzDAnNBfkFqt6ZA/3/YsZt1rCJZIpbuB7PagEkbXTJg+bHnWaQOF/Nyr /NrzrrXoMzQvqYUnzc/vLgJQ/xNFvMRBr8iJd8KO/FkbGxdvUuqes05hAEFxMHysXV4SANFFKH8 dTWVOQBcbpRwdS7nI63NtoabqMg6ZWkkdOc0KrCq5XDOQte+PEpWv41mVfEdXC3YIsXC+ClrgjJ DNRQFHOT+d6KbUn1JHa6ne5b3e0TWcaj95oTl9zy3y2IC4QLOTGufE6tGkqtFvywnunX3fVCpxT LZihxbL7GkMX/xWNZD4= 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: netdev@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;