Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1409227ybl; Wed, 18 Dec 2019 18:33:18 -0800 (PST) X-Google-Smtp-Source: APXvYqx8P9Fb0hBwAOzgQ1Gu5ZAVurrTIMKmsQXDU6HNEJ+lX3XtfLHk8kj+WlyzjP2GE4ku1g2s X-Received: by 2002:a05:6830:18f1:: with SMTP id d17mr1196841otf.298.1576722798820; Wed, 18 Dec 2019 18:33:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576722798; cv=none; d=google.com; s=arc-20160816; b=R2IP17+RCwBQuGspX/hpnqgFIZDp2YgenH3uyKcUNcUOjr5iJF6j5r6cOX2FLVblVL kQyZcABFxRPM4vt4KGpQg1CRClbbQ8SPNgjORGJq8+WbOcWMJzGSDebd08nSROHKfxsy JkGs6hBBzERGLOICp5vlbYro6rh0EBbryOKZ7qrtH5keOS5vbKFjxm0AHmuDUjsKDXx2 BU4ZMBd6brMuwpD101wrLx83Xl0xPMQ9ZZc9ozk/M+pBCLRfG2SP8zcyonRd+sDr0ORu XTDp5pGgRg1dKu2BJhCelEDqZ7GHU31vUvkusfd2t5CGCToUcmgSOVCzVs7Q4o01zFS2 UO/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=8EZFQxOfL//tqCMEZCkA+NRJmjPQMfyGk5WDlydLVjY=; b=Z+S3JIImQ2fDevDuIcr6ypO3BGIllQy+Qw2VE//Dp8FJta4iR0HDtvSHekKeqV/a+m ZbUJnTj3cAOq70rD3TwnVivItOdAHSurnt3zfrLVDzNCRV7nDkOp5CWqgAnoZdiDOOL9 cTA9c0gsOHget3tofM3DpKhFzddgur00+IWjcsCHV52WxkzE+O4qSP0wlyEpUFwzaBxc BTEhW90Rm6NHmf1gG1smI85Jre/j7Bo5Xt6vx8lPIag1SMlRthXEzghfkJWdN+8oblLF XeEkW6josEDOK1Kn/7aPWaw2MY2fYSzFDwM74NFibf7xyKvHpQLG2ZJnpNfg9Pxzm4Sl bArA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V8qWJZPS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8si2749497otf.76.2019.12.18.18.33.07; Wed, 18 Dec 2019 18:33:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V8qWJZPS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbfLSCc0 (ORCPT + 99 others); Wed, 18 Dec 2019 21:32:26 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44611 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbfLSCc0 (ORCPT ); Wed, 18 Dec 2019 21:32:26 -0500 Received: by mail-pf1-f196.google.com with SMTP id 195so1431497pfw.11 for ; Wed, 18 Dec 2019 18:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=8EZFQxOfL//tqCMEZCkA+NRJmjPQMfyGk5WDlydLVjY=; b=V8qWJZPShBfgpsj9kSAQ/lE5x3lQQegNHXTDsRWig45BKvkSlIgBKTiBRSWHofdUJu J9CptSMNzOdmXVTu/ZGHqhk37V7ZYXOhx/s6csYL37tMSiwbb+HI1MB/aFhwf/LkqmDd RXAa5xG5unpA/5z9t2dENaPpiUAgbOigj416B9NN0auczlEglNq4rVTlim/j8IWvWjib h6H16TuC1OkplXiwV5dlJWP8i+MzEV6qh6kMWzlB9k62h7Z3Z0IWttpo+i4ckmOwbxFI SzVu/uhqyzv5LsDHOpVdVNbnTEoTStezBDtYLpscgPBNOC2EU5HU5ZquAH4AS7+TpKZf KNzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=8EZFQxOfL//tqCMEZCkA+NRJmjPQMfyGk5WDlydLVjY=; b=CrvV+SMXcIWqvsvuVjShgAljq5/qC71tNEXW9emqqZCn35ihRtrefu4b+OrtUWmN92 tB9pXa8fb/t0kUdksf2pxeRN4wCdSRu5NHhYr/w4jXjYa5MuysM62lA2TNj5m8udqBSE zAa7JrWOdoj7HSOWVAy565ir9X1ffyNg7fXLY1M/w86l0zamwdvIw/lIAk0monL6gF1F o8MA7pH2akHamKnTj7vS509q7j1SDyqecSC8v88U049nCk83BIzKKymuNViLRItWQn/M KzyjGAES7ymyxMTAiiigJLa13BO1PorQRQVWMMui7mPxvox/TutTmU/YP7GijKx7k1vJ EiCg== X-Gm-Message-State: APjAAAVK1RbIznJXZB+ICQ0+dEvewMIBV9IFTdOzo9OAWRk5TtWphXqc hMSu4HFIUAx5hXkwM0ubc8E+IyW5DiD52A== X-Received: by 2002:aa7:9d87:: with SMTP id f7mr6718941pfq.138.1576722745170; Wed, 18 Dec 2019 18:32:25 -0800 (PST) Received: from ?IPv6:2402:f000:1:1501:200:5efe:166.111.139.116? ([2402:f000:1:1501:200:5efe:a66f:8b74]) by smtp.gmail.com with ESMTPSA id x4sm5309685pff.143.2019.12.18.18.32.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Dec 2019 18:32:24 -0800 (PST) Subject: Re: [PATCH] mtd: maps: pcmciamtd: fix possible sleep-in-atomic-context bugs in pcmciamtd_set_vpp() To: Dominik Brodowski Cc: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org References: <20191218140552.12249-1-baijiaju1990@gmail.com> <20191218172813.GA338501@light.dominikbrodowski.net> From: Jia-Ju Bai Message-ID: <42939a91-baab-54ad-bb4c-8a77e4418f2f@gmail.com> Date: Thu, 19 Dec 2019 10:32:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <20191218172813.GA338501@light.dominikbrodowski.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/12/19 1:28, Dominik Brodowski wrote: > On Wed, Dec 18, 2019 at 10:05:52PM +0800, Jia-Ju Bai wrote: >> The driver may sleep while holding a spinlock. >> The function call path (from bottom to top) in Linux 4.19 is: >> >> drivers/pcmcia/pcmcia_resource.c, 312: >> mutex_lock in pcmcia_fixup_vpp >> drivers/mtd/maps/pcmciamtd.c, 309: >> pcmcia_fixup_vpp in pcmciamtd_set_vpp >> drivers/mtd/maps/pcmciamtd.c, 306: >> _raw_spin_lock_irqsave in pcmciamtd_set_vpp >> >> drivers/pcmcia/pcmcia_resource.c, 312: >> mutex_lock in pcmcia_fixup_vpp >> drivers/mtd/maps/pcmciamtd.c, 312: >> pcmcia_fixup_vpp in pcmciamtd_set_vpp >> drivers/mtd/maps/pcmciamtd.c, 306: >> _raw_spin_lock_irqsave in pcmciamtd_set_vp >> >> mutex_lock() may sleep at runtime. > Thanks for noticing this issue. > >> To fix these bugs, pcmcia_fixup_vpp() is called without holding the >> spinlock. > I don't think that this is the right approach here -- we lose the protection > against races in calls to pcmcia_fixup_vpp(). Instead, we should change the > spinlock to a mutex, which seems to be sufficient here. Could you prepare > such a patch, please? Okay, thanks for the advice :) I will send a new patch. Best wishes, Jia-Ju Bai