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 A0F5E1D89F5; Tue, 15 Oct 2024 11:50:35 +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=1728993035; cv=none; b=nZPloB060tPWaKySNf9s+zly8sNTBk0Kgv7vfcpYKqlY28uCRt19dSNHxh3ZT0WX2nzDe38EfHtyaSqbtTt4a2GsIc5A9dOEpe8zuEaF4/p6BtT75IeSZ0bocDKmn7Ex0GxpsCGVTl2HtpqzMSxNxzONDWj6f3ZbDcxFaM28Am4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728993035; c=relaxed/simple; bh=BwtU1u7MCBdmzsNbAhXUVF1EMD+6ndaJU3tnBQlGeUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=REXGzrFOxuwo0nS6KD+SDj5tS86ZFP9sCcTdt6sUdPZrCsXot1HLPGSw6A1XlxaZ436xKZYPy1y3pOIRud2YIpmuD8eDVeSnKV2d/92xu1dxJWuKvKaS3a0KUkh3hgnv0mmIpQ6nCvRhe9BoU3vDGYgAOz+IYmh5fHjyBQEc2Cw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KS0UTRup; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KS0UTRup" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFD69C4CEC6; Tue, 15 Oct 2024 11:50:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728993035; bh=BwtU1u7MCBdmzsNbAhXUVF1EMD+6ndaJU3tnBQlGeUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KS0UTRupfYCTdjh9yF4gHJtnHnu3Jx2IypsLoyapJmChQrs2RrMnQAgTrMpU8E2Sv Pkc4sPcGWfR/0/tw/LiG5UO/Gnd4UYzNgxLQzL5ZFWDH1ucudBYtX5CYfXDtuTNKho +llIbyZflO2cQZGg6MJvtU+F+H6otYS5FKRjKGwo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kaixin Wang , Paolo Abeni , Sasha Levin Subject: [PATCH 5.15 292/691] net: seeq: Fix use after free vulnerability in ether3 Driver Due to Race Condition Date: Tue, 15 Oct 2024 13:24:00 +0200 Message-ID: <20241015112451.935246025@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241015112440.309539031@linuxfoundation.org> References: <20241015112440.309539031@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kaixin Wang [ Upstream commit b5109b60ee4fcb2f2bb24f589575e10cc5283ad4 ] In the ether3_probe function, a timer is initialized with a callback function ether3_ledoff, bound to &prev(dev)->timer. Once the timer is started, there is a risk of a race condition if the module or device is removed, triggering the ether3_remove function to perform cleanup. The sequence of operations that may lead to a UAF bug is as follows: CPU0 CPU1 | ether3_ledoff ether3_remove | free_netdev(dev); | put_devic | kfree(dev); | | ether3_outw(priv(dev)->regs.config2 |= CFG2_CTRLO, REG_CONFIG2); | // use dev Fix it by ensuring that the timer is canceled before proceeding with the cleanup in ether3_remove. Fixes: 6fd9c53f7186 ("net: seeq: Convert timers to use timer_setup()") Signed-off-by: Kaixin Wang Link: https://patch.msgid.link/20240915144045.451-1-kxwang23@m.fudan.edu.cn Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/ethernet/seeq/ether3.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/seeq/ether3.c b/drivers/net/ethernet/seeq/ether3.c index 16a4cbae93265..6bcb52118c11b 100644 --- a/drivers/net/ethernet/seeq/ether3.c +++ b/drivers/net/ethernet/seeq/ether3.c @@ -845,9 +845,11 @@ static void ether3_remove(struct expansion_card *ec) { struct net_device *dev = ecard_get_drvdata(ec); + ether3_outw(priv(dev)->regs.config2 |= CFG2_CTRLO, REG_CONFIG2); ecard_set_drvdata(ec, NULL); unregister_netdev(dev); + del_timer_sync(&priv(dev)->timer); free_netdev(dev); ecard_release_resources(ec); } -- 2.43.0