Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3922845pxb; Mon, 4 Oct 2021 12:44:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcGPcxI7IQHUyR5uZrlNpTWQGg4paG0ccffr+5mY9N2CYVYpPx6MT3UAjr9KtvcnQqAqJ0 X-Received: by 2002:a05:6402:784:: with SMTP id d4mr20645686edy.116.1633376646499; Mon, 04 Oct 2021 12:44:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633376646; cv=none; d=google.com; s=arc-20160816; b=LxLfubd7VgfBO+ciHQ8+VOTKj2BuuhzWy53Z+/B2vdMWQ+gVD9QYh2oIkFvpbdwfok xur0IVEBR3bBDrfyX+mm5IZK5V0sDePu1zSpIpx+m5p1sjpDv6/pG+u+++urEBa5ElfW BYq6ZZhlKs9XjcmPVtSUclARISH9+UnZHlKBHRo59j4r0b5gaDHxpoiSxqXlu20utt/C k6JNuWwcZUdh2HonAR+9mPCLDHQpTiw9v8EjIO1TIqTtl0B9fETsgAeQojknFJWoA9/0 6Fz8hwHitBzghiiqBvjz8+4YhObxkAfPp2ZF73tz+KcBEL3wokh7nBibXpwcpry5pffl EkdA== 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=EQdC8tbAvbbfF8z/qo9+TeEb4C7Ey2pSl41oMTjlKInFoM9Lh1IEc/L1SZJiQqAXs5 0IXS5tuwRrei8vCbAm/P+M+fJh9yn708QleDQecrLz09ggtgGqFBYxuZcnu1PmN+FhUa GFVdYL4mG5vIfkMBNoL7GL98QEbrFCfHZI8tl5K2h5tehgaF0biK03IikoJR2jiY9mTi mAU3EOD9bU3/lHV/HzTY0KCQxAFAJKGkMokeWRsX/UBvgnOE4Yb56+ifsmrHdNJHS5qG vBe/W0zcKapgkIpBvG8edVRD9QlfLM/yTau5oVjcu7LdMuePrZLKD56HTDQDiK4MzOMG Y7Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GASKPZYG; 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 p3si18668155ejy.556.2021.10.04.12.43.42; Mon, 04 Oct 2021 12:44:06 -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=GASKPZYG; 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 S235239AbhJDNK6 (ORCPT + 99 others); Mon, 4 Oct 2021 09:10:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:39478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235607AbhJDNIm (ORCPT ); Mon, 4 Oct 2021 09:08:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9391561501; Mon, 4 Oct 2021 13:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352556; bh=T+RJFP0DSxJst0qW7wvU2PBpr13mJPz/ZE3yRJR1riI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GASKPZYGEqUeePRMpLo7F4LY7qpIz+ncM5fuz4la0tffd4BUxTKP166XtN5HnE2BK ocRuIeC+ILdqg2f2xAJFkQotXkpoFZALnxFSEAIyRTDEjVnrA/oRJH7VGiNvuhIBZC bZv7rJd4bo8R0U2G6mdYhE88cumEF/Nf9RvKF51M= 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.19 33/95] net: macb: fix use after free on rmmod Date: Mon, 4 Oct 2021 14:52:03 +0200 Message-Id: <20211004125034.645427784@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125033.572932188@linuxfoundation.org> References: <20211004125033.572932188@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