From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 484E434CDD for ; Mon, 9 Mar 2026 11:21:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773055301; cv=none; b=TyyP6CqrqSCwtwuY9Owca89sZQgqR6UnD7oYl6nPxtTtHUQV9p82Xl4vmnt4Z4pGiZ0LgvsAjftYSm7DbiEUxtoA0crqA+nzGfwU/KflKJMDFkWv349hG+Z8e2cBlM2dz8kPIDmrTDsVN0fNFJFvYVSbD5hsko4QH3/22+8wHpc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773055301; c=relaxed/simple; bh=K1ls5Y44sheGNRXOMYoKSHkwZ/Tx/vMwW7qNaah3G74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bqmpUtI53rnoM4ZyrsPrO5oNb+x+tEU5vJpM+nyjlV8Tg99+Wn7l1D94/t1mnWPO7hoRPsGFbbRQwnL24e8CTrzKsbdFF97iJETGVSmIJJqAUBo6jb47UrUOP40cbBkXcUdFcGuQI/lCKxQ9z932LNjWmj3G8tppyJlBsXZe6ck= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cZCrw0B7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cZCrw0B7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 435C2C4CEF7; Mon, 9 Mar 2026 11:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773055300; bh=K1ls5Y44sheGNRXOMYoKSHkwZ/Tx/vMwW7qNaah3G74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cZCrw0B7mIDsqzsIH28zGJRTxeMO8vb6ZJYY8Nwy627lI64LbM70wM+cS4McDPQ6Q 8cs5ZwUCxhB93jz/YuGB+yrQDLhKvpf7TPgFal6LVJDbSksNWXEzIBCcNT5l5sK8/O htU7Uh6sOWUmyuG4cTnqJHrRVuw6yBuCcyBWWkjmhjQXix75MXlqPVUBLNWplBcFnZ 3aM15oaD4J9Nk18e//L8rScK2lFtyhqeXuOUbbaDuOonHZlsn9044weemNMbEJItY0 gvdRZeG7YY2Xo1UydqwvrWxkBMNVQ9n+SNSzxg+eGu4+NB2H8ry49FyaJNWyUfJuuJ 8dC0r4rH+WB+w== From: Sasha Levin To: stable@vger.kernel.org Cc: Daniel Hodges , Johannes Berg , Sasha Levin Subject: [PATCH 5.15.y] wifi: libertas: fix use-after-free in lbs_free_adapter() Date: Mon, 9 Mar 2026 07:21:38 -0400 Message-ID: <20260309112138.816064-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026030918-clatter-suggest-d167@gregkh> References: <2026030918-clatter-suggest-d167@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Daniel Hodges [ Upstream commit 03cc8f90d0537fcd4985c3319b4fafbf2e3fb1f0 ] The lbs_free_adapter() function uses timer_delete() (non-synchronous) for both command_timer and tx_lockup_timer before the structure is freed. This is incorrect because timer_delete() does not wait for any running timer callback to complete. If a timer callback is executing when lbs_free_adapter() is called, the callback will access freed memory since lbs_cfg_free() frees the containing structure immediately after lbs_free_adapter() returns. Both timer callbacks (lbs_cmd_timeout_handler and lbs_tx_lockup_handler) access priv->driver_lock, priv->cur_cmd, priv->dev, and other fields, which would all be use-after-free violations. Use timer_delete_sync() instead to ensure any running timer callback has completed before returning. This bug was introduced in commit 8f641d93c38a ("libertas: detect TX lockups and reset hardware") where del_timer() was used instead of del_timer_sync() in the cleanup path. The command_timer has had the same issue since the driver was first written. Fixes: 8f641d93c38a ("libertas: detect TX lockups and reset hardware") Fixes: 954ee164f4f4 ("[PATCH] libertas: reorganize and simplify init sequence") Cc: stable@vger.kernel.org Signed-off-by: Daniel Hodges Link: https://patch.msgid.link/20260206195356.15647-1-git@danielhodges.dev Signed-off-by: Johannes Berg [ del_timer() => timer_delete_sync() ] Signed-off-by: Sasha Levin --- drivers/net/wireless/marvell/libertas/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas/main.c b/drivers/net/wireless/marvell/libertas/main.c index 46877773a36de..a05c83c6608d6 100644 --- a/drivers/net/wireless/marvell/libertas/main.c +++ b/drivers/net/wireless/marvell/libertas/main.c @@ -882,8 +882,8 @@ static void lbs_free_adapter(struct lbs_private *priv) { lbs_free_cmd_buffer(priv); kfifo_free(&priv->event_fifo); - del_timer(&priv->command_timer); - del_timer(&priv->tx_lockup_timer); + timer_delete_sync(&priv->command_timer); + timer_delete_sync(&priv->tx_lockup_timer); del_timer(&priv->auto_deepsleep_timer); } -- 2.51.0