From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E7F7C47E48 for ; Thu, 15 Jul 2021 04:27:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 349E761380 for ; Thu, 15 Jul 2021 04:27:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 349E761380 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 817FF8D0048; Thu, 15 Jul 2021 00:27:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7EDCA6B0152; Thu, 15 Jul 2021 00:27:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A89A8D0048; Thu, 15 Jul 2021 00:27:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 48A4D6B0151 for ; Thu, 15 Jul 2021 00:27:04 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 399F71EA20 for ; Thu, 15 Jul 2021 04:27:03 +0000 (UTC) X-FDA: 78363537126.10.E2D7663 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf20.hostedemail.com (Postfix) with ESMTP id E81CBD0000A4 for ; Thu, 15 Jul 2021 04:27:02 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id E827C6128C; Thu, 15 Jul 2021 04:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1626323222; bh=E/hPjciFPdETfzSqNvWxfE+8yg//T/nkcBgjMHae9rk=; h=Date:From:To:Subject:In-Reply-To:From; b=N8I6RWMc37zDgNmp1V+XoHsqIo9L8t687sz7qt+z9WxgDbAkFpOEqMb1Hqfav8K7O qAXBWM8HviPYcrV5RQRWrmPLtzC/GMpNzJdBIqsPBxfSEyN2pPePYNsTcJZXx7ewEz AVicbTHcp/0GPnJTXiRhL07VBMPCfY0pO/SLQ4rY= Date: Wed, 14 Jul 2021 21:27:01 -0700 From: Andrew Morton To: akpm@linux-foundation.org, desmondcheongzx@gmail.com, gregkh@linuxfoundation.org, gustavoars@kernel.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, skhan@linuxfoundation.org, slava@dubeyko.com, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk Subject: [patch 10/13] hfs: add missing clean-up in hfs_fill_super Message-ID: <20210715042701.RIM_Afm8q%akpm@linux-foundation.org> In-Reply-To: <20210714212609.fad116e584ba1194981a6294@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E81CBD0000A4 X-Stat-Signature: 6q9k7f86nuf6skewcmpg15bf75iuoh34 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=N8I6RWMc; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1626323222-667201 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Desmond Cheong Zhi Xi Subject: hfs: add missing clean-up in hfs_fill_super Patch series "hfs: fix various errors", v2. This series ultimately aims to address a lockdep warning in hfs_find_init reported by Syzbot: https://syzkaller.appspot.com/bug?id=f007ef1d7a31a469e3be7aeb0fde0769b18585db The work done for this led to the discovery of another bug, and the Syzkaller repro test also reveals an invalid memory access error after clearing the lockdep warning. Hence, this series is broken up into three patches: 1. Add a missing call to hfs_find_exit for an error path in hfs_fill_super 2. Fix memory mapping in hfs_bnode_read by fixing calls to kmap 3. Add lock nesting notation to tell lockdep that the observed locking hierarchy is safe This patch (of 3): Before exiting hfs_fill_super, the struct hfs_find_data used in hfs_find_init should be passed to hfs_find_exit to be cleaned up, and to release the lock held on the btree. The call to hfs_find_exit is missing from an error path. We add it back in by consolidating calls to hfs_find_exit for error paths. Link: https://lkml.kernel.org/r/20210701030756.58760-1-desmondcheongzx@gmail.com Link: https://lkml.kernel.org/r/20210701030756.58760-2-desmondcheongzx@gmail.com Signed-off-by: Desmond Cheong Zhi Xi Reviewed-by: Viacheslav Dubeyko Cc: Gustavo A. R. Silva Cc: Al Viro Cc: Shuah Khan Cc: Greg Kroah-Hartman Signed-off-by: Andrew Morton --- fs/hfs/super.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/fs/hfs/super.c~hfs-add-missing-clean-up-in-hfs_fill_super +++ a/fs/hfs/super.c @@ -420,14 +420,12 @@ static int hfs_fill_super(struct super_b if (!res) { if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) { res = -EIO; - goto bail; + goto bail_hfs_find; } hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength); } - if (res) { - hfs_find_exit(&fd); - goto bail_no_root; - } + if (res) + goto bail_hfs_find; res = -EINVAL; root_inode = hfs_iget(sb, &fd.search_key->cat, &rec); hfs_find_exit(&fd); @@ -443,6 +441,8 @@ static int hfs_fill_super(struct super_b /* everything's okay */ return 0; +bail_hfs_find: + hfs_find_exit(&fd); bail_no_root: pr_err("get root inode failed\n"); bail: _