Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2185814pxb; Wed, 9 Feb 2022 12:43:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6Crag5xcr+jbKZtQLKQpvdY0FMRQFrAY7Ju6l+38sczjK1cKBMys+fQ5C1v+NAIAvI4If X-Received: by 2002:a63:338e:: with SMTP id z136mr3356725pgz.510.1644439411068; Wed, 09 Feb 2022 12:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644439411; cv=none; d=google.com; s=arc-20160816; b=DzyIx5kTVQlZOmRNV/SmtTXh0r2pArd1ZXWZn9XA1j+ME8yafL7AaxDRlDQ08e8nIY GzeNMpOj3P+dZ1TnBlsn19F9GlHDasJCgRMaxtq+OLRXupfRN72deTDrTPwrG4d3Oqfx ySjSayY5fMDPXIHBS3bjzPbh857BalS/rrzMoP6f38jej0InUA7WjBVpMRlhABEXCZS/ Pjz81eiJz56/aq13cLsexLDBElrDtdOloVt1gx0Zc1U3sfKwKsrSmPL22Zm/8uYy0kp9 +cfax+uXJT49eK+ra6zX3w0hOFvRESownz8vRxF53+fXXciEZGljS/e8/lLzh+/E+++p S7yg== 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=nwVy3SqlSps8xNndCnIbZsb9/6vqNxkQ6YcQQjqSwVk=; b=LRazFGraXh9vr4apVeMVN6J+oegYel+deFrb9gstE3B92p98hEigGT423Hsy2ThIG2 jfg4bhLe+1OJcdDZIk3z2ZuA2j3J7PNRI8VJE4lMAzQc471IXOdM05PI/yuakHbd1stD p5ZJIdO0pNPsAVrkb5k5TPPS/p9tomMIXFntbPHuAUzVShqCTvaBwg9fm+IBTAbmQa9M fvbThZL2AbExxwnC3Sn3ZdiYH84CAAspvVUpNfo9ov4uBN0OPcfkdE+8+h1aN14EHAVL XPkj9+CBi+HOD0qfNqos6ciCqAc/H6BXlLzY9l3eKB1VPw3rUDIXuOfMLnHqAU349Frd 5VaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kEi4yUF0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j190si2059389pgd.177.2022.02.09.12.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 12:43:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kEi4yUF0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BDC34E02F6E5; Wed, 9 Feb 2022 12:11:05 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234854AbiBIT0d (ORCPT + 99 others); Wed, 9 Feb 2022 14:26:33 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234385AbiBIT0I (ORCPT ); Wed, 9 Feb 2022 14:26:08 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 049D5C102FED; Wed, 9 Feb 2022 11:19:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5C3DEB8238C; Wed, 9 Feb 2022 19:14:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C001C340E7; Wed, 9 Feb 2022 19:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644434092; bh=eoZDwWkV4rsrAJOY5F0LAs5kTxbQ7KPvapYjwLwSSJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kEi4yUF0j+4L2R7nkzZenYZutTMROVoJH+mMSQYop0n9IQFzvo6F2PAOTCsmbOrxf d7Wj+PUuuR3EYo3YlCcJJALAnj10VbXMvVpvCVcW8zg5VelhDKsgpU/+tEQfEfox0f nQO7lcjw4dXIuKbyKihcJegDtcw5kK2pKGMxnxvg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ulf Hansson , Xiyu Yang , Xin Xiong , Xin Tan , Tony Lindgren , Yang Li , linux-mmc@vger.kernel.org, whitehat002 Subject: [PATCH 4.9 2/2] moxart: fix potential use-after-free on remove path Date: Wed, 9 Feb 2022 20:13:33 +0100 Message-Id: <20220209191247.913724368@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220209191247.830371456@linuxfoundation.org> References: <20220209191247.830371456@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman commit bd2db32e7c3e35bd4d9b8bbff689434a50893546 upstream. It was reported that the mmc host structure could be accessed after it was freed in moxart_remove(), so fix this by saving the base register of the device and using it instead of the pointer dereference. Cc: Ulf Hansson Cc: Xiyu Yang Cc: Xin Xiong Cc: Xin Tan Cc: Tony Lindgren Cc: Yang Li Cc: linux-mmc@vger.kernel.org Cc: stable Reported-by: whitehat002 Signed-off-by: Greg Kroah-Hartman Link: https://lore.kernel.org/r/20220127071638.4057899-1-gregkh@linuxfoundation.org Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/moxart-mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mmc/host/moxart-mmc.c +++ b/drivers/mmc/host/moxart-mmc.c @@ -698,12 +698,12 @@ static int moxart_remove(struct platform if (!IS_ERR(host->dma_chan_rx)) dma_release_channel(host->dma_chan_rx); mmc_remove_host(mmc); - mmc_free_host(mmc); writel(0, host->base + REG_INTERRUPT_MASK); writel(0, host->base + REG_POWER_CONTROL); writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF, host->base + REG_CLOCK_CONTROL); + mmc_free_host(mmc); } return 0; }