Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp91919lqc; Thu, 7 Mar 2024 11:10:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWJNMw+zB8P/viV3/+KafjFLantx7sLAjbaea6/eixQP8ojTUH9IQFrgahgZr+uEfg24GSCVAt9Z/BsHvRSoWzhxDt9nxQT18u+e1EAGQ== X-Google-Smtp-Source: AGHT+IFzZpMOXKnzG8JQdLfUYc3XlVeqzVeM54NKF8k+pSmLxVXqOlLVBcgFlCBVBJkGw97wE2sr X-Received: by 2002:a05:620a:20d4:b0:788:33e6:aac5 with SMTP id f20-20020a05620a20d400b0078833e6aac5mr8998033qka.73.1709838622697; Thu, 07 Mar 2024 11:10:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709838622; cv=pass; d=google.com; s=arc-20160816; b=RSUsyzXvotZuqhpzZYFHOWbhgEZ9QMbYniPclqZTotmO44RWLxEoc4T6tV52sh1mw/ Lk/WWlU7QFYYd9PkO7/vFjLQF9YoWpkcINoqgg4+DD9IHDZpHRyb4RZn95OJUuAjYdP8 GEAlXdqUo/XOIzA0BIH224f98X7QWpnxP3xfHXXBKnmhT5rdeo4RGlbJkqMcOLDhbyAT F4WX140ccgFX/ztdgJsms+aD3H2Q/3EKQWJknMjsY1xX3Z0TtT289vPUld/INYFrQOja nMte7oRXdsr4CsTtVhBKIGNcDkameHzPfCILHsWVOmRycPxv3hhILbCXs1opH63xNoo1 d7Qg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=CAvOEPtPFq6+eIgzAFJWMtkJyr4bIU2xSPDi8uBAnuY=; fh=fC3rwN9xCa0cw7rrSAK1iVzaQAOAJ7Q8YRP4mG0N56k=; b=IT7rvlEOqCykx95ax/8zmYffxc/WoeIWy4rAwhONLn4zn0zP6tKIe4vm6ZNnorD3Kr f+5CLeNuZbFIFMhj5/bMcwrcwGNegQW+KO3q4epFBiPc672CiS0nT1p/r7Md9FfbPKbF r9e9TroLtdG0uxVBecBRlTHV19Nc/k1Ppr2tFJqPUuyG6YsiE5SIJv1/UCarDdF1u1Ri Iq7wvCgC4QSwX6ip0Jbec87MvsD+jFiVr9AuKSjsd6WornnDg7VGoUEPmq2NNwFEq0WH TqZN7Vk0F5vteZIaw9DZgsssxwuT5PaxEIZZYhgZVASpB/Z3C7jnipe74Wg8Mjhw/Oh5 A/Zw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=qWS5xXLl; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-96069-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id de41-20020a05620a372900b0078835be6631si7556800qkb.601.2024.03.07.11.10.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 11:10:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96069-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=qWS5xXLl; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-96069-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96069-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6BC181C215E4 for ; Thu, 7 Mar 2024 19:10:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE6401369A7; Thu, 7 Mar 2024 19:06:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b="qWS5xXLl" Received: from mx1.t-argos.ru (mx1.t-argos.ru [109.73.34.58]) (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 DD4BC136675; Thu, 7 Mar 2024 19:06:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.73.34.58 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709838399; cv=none; b=AOpnAFdKt6oO5xyWnXXulCflS/m67RApz0Xq/XXzPaVDRu4M1MCcMH0FVyt50/HqMvYv4jHgNxqy8On+SzZWFvtBVtphLxecB9XzOyRYp5Qi5wFV5bOL1ZascmQKLSrwrscmsrx9YvjSCC/sQM2g0aWQEjqgbUya4dRqpwFFUcU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709838399; c=relaxed/simple; bh=jF6iduJGIE+O3Bkq9YrSC7eRZxghqOnr34T4ybioEe4=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=m7zxx9YX6JagZPfZ12XHdp4sXt82iFQ0vpRKNwgtm0NJaj7NFZnrGJN13f4kOR4RNFrAOVsBczZ7Jun/VzD49Pc2yVdb/+hNGFcteb6Ia0DRs3qrR2raJORJ99ywi8fXSGYJG4cFkKC/HgdKTbONeIFfqrtCLl9Jq4svxRA5H3g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru; spf=pass smtp.mailfrom=t-argos.ru; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b=qWS5xXLl; arc=none smtp.client-ip=109.73.34.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=t-argos.ru Received: from mx1.t-argos.ru (localhost [127.0.0.1]) by mx1.t-argos.ru (Postfix) with ESMTP id 31C0E100003; Thu, 7 Mar 2024 22:06:15 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=t-argos.ru; s=mail; t=1709838375; bh=CAvOEPtPFq6+eIgzAFJWMtkJyr4bIU2xSPDi8uBAnuY=; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; b=qWS5xXLl/V8vg8BJGHCJyaCIZChoxxuFF7FxrzEvzeFH7qBluOf1TpBh2p61QagHe QFgXChfsedVWvDwmgLQh5zYwXjbeaQ09meG5lx0yPk/8DYTdMtk1U2hQ+4Oclpcux7 vxf8Grtn+KaP5xBq2DQiTw9txrm1YZrrKGYZr63Vay/oaSvok+yMN4e1w9qkCqbzRe we4SS4Yu2ZmKCb1uEOndz5xevCCdxCMdemI4O/1qlE21Nxe+5CAP1pcB1+G+zAnLgX JeVf411fPOff5qZVTzQq+DT/95W4N2qV0GSIU8kAPYDTH/g1Y/p5WjAso/yitCXX5k lFlLRjjnHU0iQ== Received: from mx1.t-argos.ru.ru (mail.t-argos.ru [172.17.13.212]) by mx1.t-argos.ru (Postfix) with ESMTP; Thu, 7 Mar 2024 22:05:33 +0300 (MSK) Received: from [172.17.214.6] (172.17.214.6) by ta-mail-02 (172.17.13.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Thu, 7 Mar 2024 22:05:13 +0300 Message-ID: <98dea36b-41dc-4d2e-aec6-56c849e1d58b@t-argos.ru> Date: Thu, 7 Mar 2024 22:02:56 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mmc: dw_mmc: Fix potential null pointer risk To: Ulf Hansson CC: Jaehoon Chung , Wen Zhiwei , , , References: <20240307085135.16245-1-amishin@t-argos.ru> Content-Language: ru From: Aleksandr Mishin In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: ta-mail-02.ta.t-argos.ru (172.17.13.212) To ta-mail-02 (172.17.13.212) X-KSMG-Rule-ID: 1 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184049 [Mar 07 2024] X-KSMG-AntiSpam-Version: 6.1.0.3 X-KSMG-AntiSpam-Envelope-From: amishin@t-argos.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 9 0.3.9 e923e63e431b6489f12901471775b2d1b59df0ba, {Tracking_from_domain_doesnt_match_to}, mx1.t-argos.ru.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2;t-argos.ru:7.1.1, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean, bases: 2024/03/07 17:51:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2024/03/07 17:21:00 #24036814 X-KSMG-AntiVirus-Status: Clean, skipped 07.03.2024 13:57, Ulf Hansson wrote: > On Thu, 7 Mar 2024 at 09:53, Aleksandr Mishin wrote: >> >> In dw_mci_runtime_resume() 'host->slot' could be null, but check is not cover all corresponding code. >> Fix this bug by changing check place. > > In fact host->slot can never be NULL in dw_mci_runtime_resume() or in > dw_mci_runtime_suspend(). > > A better fix would thus be to remove the redundant checks. > > Kind regards > Uffe > >> >> Found by Linux Verification Center (linuxtesting.org) with SVACE. >> >> Fixes: 4a835afd808a (mmc: dw_mmc: Fix potential null pointer risk) >> Signed-off-by: Aleksandr Mishin >> --- >> drivers/mmc/host/dw_mmc.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c >> index 829af2c98a44..a4f124452abc 100644 >> --- a/drivers/mmc/host/dw_mmc.c >> +++ b/drivers/mmc/host/dw_mmc.c >> @@ -3570,8 +3570,10 @@ int dw_mci_runtime_resume(struct device *dev) >> DW_MCI_ERROR_FLAGS); >> mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); >> >> + if (!host->slot) >> + goto err; >> >> - if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER) >> + if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER) >> dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios); >> >> /* Force setup bus to guarantee available clock output */ >> -- >> 2.30.2 >> >> > At the same time there are few checks such as "if (host->slot)" in dw_mci_runtime_resume() and commit 4a835afd808a3dbbac44bb399a902b822dc7445c message contains: "we previously assumed 'host->slot' could be null, null pointer judgment should be added" and replaces "if (host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)" with "if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)" So where is the truth? -- Kind regadrds Aleksandr