Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3922931pxb; Mon, 4 Oct 2021 12:44:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUsJ749+UT2LF1UwdM53nAoyOgmycZECXUmJBy/eTdyTLezutkgPvTimjlky89hatdmNSS X-Received: by 2002:a05:6402:510b:: with SMTP id m11mr21359530edd.82.1633376655762; Mon, 04 Oct 2021 12:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633376655; cv=none; d=google.com; s=arc-20160816; b=kazWF56qqOQLStugouUL0pZEdMdhkhW5As3bzhOY1XzAttd9oEJFCPmmewtGIuei4e qyHiTkj70LO80WHeMXrmcq/cexogBAOb8eyh6GUJhjOwf4ZTlc5bOooeLx+IFNiunjFR /HsnMZpUbJ1/N/3+BGsn23JQ5a6BEAAalf27YKfGT3NFVOQ6fU7kj7+D7w5LXCq5yfmq 4/VXsoDXZAgR8CN42XJQVZ54B1554WYvjtvihIFDEcaKOYMhZ/zudpopbp9z3tKf84k3 FP5jICWCLI6eO8JSmVwAlhR8y7LbNRpdRo6QPAKDadFGTVs/YpKhYW6346ELwUU1ykKD oISg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YUOoQZ7PW4REAOVR9YlHAwqF07yfoHz1vd6UyiJBjJo=; b=LWH9x+JNj2ZjXtp85HDRA+RlGPQptwVGnZYgAkQyfbPh6yZlAs0zYrHMQ5Ll3lKVUl jDvhkwAdzhP9ri8eQJl4Eka0nb0Jm78aDxwpsCrTF1XdlZtHZjF1U4H+s4NbUY2gnYNg Ms/rDFaKdibdNizstEAfLeoZk/nWtAmZ3HkANTsY059ZrXUiEWhnlQE0Q9kiol6ZBcJl FGkx0yIv+z9iicgq4gA1692fSEZYvg+v/x8MqR3Wu5gIZNf5S9pZKalYmxqkl/uouR9b AUmq7B2h5WJsRkhXhyxhAvm7Dn3Qic5plPz28egQMd2SGoc3lRRBWgtLWzdfBy0jsrEN qa6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zz8RkMM9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si15851374edt.383.2021.10.04.12.43.51; Mon, 04 Oct 2021 12:44:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zz8RkMM9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234392AbhJDNEB (ORCPT + 99 others); Mon, 4 Oct 2021 09:04:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:60618 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234786AbhJDNCW (ORCPT ); Mon, 4 Oct 2021 09:02:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7B02A61A35; Mon, 4 Oct 2021 12:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352343; bh=T+RJFP0DSxJst0qW7wvU2PBpr13mJPz/ZE3yRJR1riI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zz8RkMM9gM+5RJvMvE+62uTvpx3VJTHbGeYrELt14v26M5o+TFLjRkxInMigNLZp1 mnW2IAAZ+Qkbn3TWtMcCluGm/b0PLYYah8qVkllKK3g/fdCFO30SEx9/xZcOYv8y7K feG+x9em2VJmkkWIV64k/joKXxQead+yc8SdqGYg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Ferre , Tong Zhang , Nicolas Ferre , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 24/75] net: macb: fix use after free on rmmod Date: Mon, 4 Oct 2021 14:51:59 +0200 Message-Id: <20211004125032.319062998@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125031.530773667@linuxfoundation.org> References: <20211004125031.530773667@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tong Zhang [ Upstream commit d82d5303c4c539db86588ffb5dc5b26c3f1513e8 ] plat_dev->dev->platform_data is released by platform_device_unregister(), use of pclk and hclk is a use-after-free. Since device unregister won't need a clk device we adjust the function call sequence to fix this issue. [ 31.261225] BUG: KASAN: use-after-free in macb_remove+0x77/0xc6 [macb_pci] [ 31.275563] Freed by task 306: [ 30.276782] platform_device_release+0x25/0x80 Suggested-by: Nicolas Ferre Signed-off-by: Tong Zhang Acked-by: Nicolas Ferre Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/cadence/macb_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cadence/macb_pci.c b/drivers/net/ethernet/cadence/macb_pci.c index 248a8fc45069..f06fddf9919b 100644 --- a/drivers/net/ethernet/cadence/macb_pci.c +++ b/drivers/net/ethernet/cadence/macb_pci.c @@ -123,9 +123,9 @@ static void macb_remove(struct pci_dev *pdev) struct platform_device *plat_dev = pci_get_drvdata(pdev); struct macb_platform_data *plat_data = dev_get_platdata(&plat_dev->dev); - platform_device_unregister(plat_dev); clk_unregister(plat_data->pclk); clk_unregister(plat_data->hclk); + platform_device_unregister(plat_dev); } static const struct pci_device_id dev_id_table[] = { -- 2.33.0