Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp891203pxt; Fri, 6 Aug 2021 17:08:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI5OCP2E7eWxDmogdmZMwq7c6bwYzClTF3A4nHSJk0Sx+LwEa16Dw7Wluy+R9QHuHC1NrC X-Received: by 2002:a05:6602:328c:: with SMTP id d12mr1823993ioz.41.1628294935981; Fri, 06 Aug 2021 17:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628294935; cv=none; d=google.com; s=arc-20160816; b=KsdCdVp90mSOWlVOcgQJ7tKHoNQK69Zx6ayvzvncqaqjBFmMZrqlrKIcMC1jFLuyvP rSdSYOutOUe+DyvhNyLl0lXZ8b7n4+grl2cLHzDRfBbI3U0Sswud+D+iTKOAZvh+xW7N S0WE3BFxJtHZE8QHlavHTCZweYr/f9oLloZTKoM47OSSWk+yddt8BzBvPrNLvM9q0VA0 rnn8IQ5GU4y2/ZCFBU/Zj0WY9R6ke/35VaQEi+nFmXfqevH7Qn5eD+HDS97cVUTr98cv 0JUZoOcfZUfe1LH7zmP6w5eY699FYl3BPradRnl1jXjGZ5pYR2X4AGEROrx7kCJW74U+ ZYrw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ii7pAqGipnWR1K957C5q8/+7fvKvuuVr77tc1Q4XKkQ=; b=Q96jDxeZQULEK55Lvo2Mykl8VQQas+f8Xhbfqfnp7sudMKWvxdStglMqkbfNvNy3N4 Cf3fqTrjmupL3ec8mhprrTQ4IzWvEkoXW5ayqKJeAeCSkg+Iq6OW44LwA1BoNiCOUM/H qpNWNvW8fob4fB73MOCLNaVfaIKm+QA5reJBvs71oHytDz6D1UTl02+DUaShI3P352RB H/lHjckszKgkg5S0v3aBEfJ5r+IJTr/FkBGE/mSVBGWg1k3n0jCLcACuentYyRkxmx0U mGIPiYAwChxdwxbO9mkteM8+eD1j14tXfVDISUIhUsI1c+Pko6mGTrgWkr+5f6a/Rw62 olHg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si11707005ilt.138.2021.08.06.17.08.45; Fri, 06 Aug 2021 17:08:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243990AbhHFTqQ (ORCPT + 99 others); Fri, 6 Aug 2021 15:46:16 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:36137 "EHLO relay8-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231362AbhHFTqQ (ORCPT ); Fri, 6 Aug 2021 15:46:16 -0400 Received: (Authenticated sender: miquel.raynal@bootlin.com) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 52BBA1BF203; Fri, 6 Aug 2021 19:45:58 +0000 (UTC) From: Miquel Raynal To: Desmond Cheong Zhi Xi , miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, gregkh@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org, Hillf Danton Subject: Re: [PATCH] mtd: fix lock hierarchy in deregister_mtd_blktrans Date: Fri, 6 Aug 2021 21:45:56 +0200 Message-Id: <20210806194556.392389-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210717100719.728829-1-desmondcheongzx@gmail.com> References: MIME-Version: 1.0 X-linux-mtd-patch-notification: thanks X-linux-mtd-patch-commit: b'b7abb051682263e51866bc78762fd0083d64c5ed' Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2021-07-17 at 10:07:19 UTC, Desmond Cheong Zhi Xi wrote: > There is a lock hierarchy of major_names_lock --> mtd_table_mutex. One > existing chain is as follows: > > 1. major_names_lock --> loop_ctl_mutex (when blk_request_module calls > loop_probe) > > 2. loop_ctl_mutex --> bdev->bd_mutex (when loop_control_ioctl calls > loop_remove, which then calls del_gendisk) > > 3. bdev->bd_mutex --> mtd_table_mutex (when blkdev_get_by_dev calls > __blkdev_get, which then calls blktrans_open) > > Since unregister_blkdev grabs the major_names_lock, we need to call it > outside the critical section for mtd_table_mutex, otherwise we invert > the lock hierarchy. > > Reported-by: Hillf Danton > Signed-off-by: Desmond Cheong Zhi Xi Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks. Miquel