Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2100459rdb; Sun, 24 Dec 2023 17:39:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdgD6vvU4JJblwYxKcEpdKjLWyFO5uGGDkuN5sg48Sxsvl0Af/cDnfIuRRyJYNiildBZax X-Received: by 2002:a05:6808:640f:b0:3bb:a56f:9b80 with SMTP id fg15-20020a056808640f00b003bba56f9b80mr1717556oib.73.1703468356358; Sun, 24 Dec 2023 17:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703468356; cv=none; d=google.com; s=arc-20160816; b=X2RGhCJgzw2sugTZuiAoLqxm7xScHsvsfduF7lqqDwI/hjmonI3YIkORG/XsIg6pfD yuHT16Jj4h+GofhI2a3EaTqAaN+Hu3nY7DN3b8xYSKelGrwd6RdhHrQD8HYWIXRuf6ci d7U8RcqvWJRAxjxIbzdHK5NuEEmvocqowoDfNlSuTEW2bobIMA7jYs1sss56kygcKdNS 7Z1O82Eak8EV6g3jFICQLCnB6UxgaR4ITzv7L6R4R3Q6xVWTYVx95tQIQ9wVhfbGWJzj VgscNcOA2jxaQEReGkrktHzcgxGnQj5+H9SIc3H819vTTmEYRpFBC9zYPAfaT1HyY4OS ZS7g== ARC-Message-Signature: i=1; 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; bh=NV6LfF4bRHgXferWmmQ6tfBQALADwp6sVOjHYuq/Kco=; fh=OFYZRadZ/5jAA3Of4DbgK8fRTSZ3X8k2kFDOD1LPNCA=; b=wMi9IGMgjJRRPftA7ZXxp+RhOFhQtVzACSNM88nkdsR1hxT3picB5jVf/E/djqHBKb c56z2VmwXIcoOQwfNU5VCrw3eCUqysI4Ovog+cxZsHvXocPBpkO/0I3vbXyMAbWyMijL tFsNsg7+yRFSAcbfyWBNwBoxT++gOzZNQBmlJnxPN+Sf4F+AY4klsYp4VlQL+/Tj1ouc SJyLUK4h+pUdkUXZMSK9/GL0jIZuBJkZ0MhbJKS0TX7/QIYzNt8JtW6KM2wlbZflksf7 BvQAJ6W1FnpXZM2Kfr66DNBiR3broCX2Y0YDlfFliPR7tw4EuFOdI+DjZ/J9naAP/yoA D9mQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-565-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-565-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w4-20020a056a0014c400b006d98f4ffb47si4438466pfu.112.2023.12.24.17.39.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 17:39:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-565-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-565-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-565-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 028C12813EB for ; Mon, 25 Dec 2023 01:39:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D76FD806; Mon, 25 Dec 2023 01:39:07 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 8344F63F; Mon, 25 Dec 2023 01:39:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Sz0rv1xKxz29gVZ; Mon, 25 Dec 2023 09:37:35 +0800 (CST) Received: from dggpeml500021.china.huawei.com (unknown [7.185.36.21]) by mail.maildlp.com (Postfix) with ESMTPS id E02DE1400D5; Mon, 25 Dec 2023 09:38:52 +0800 (CST) Received: from [10.174.177.174] (10.174.177.174) by dggpeml500021.china.huawei.com (7.185.36.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 25 Dec 2023 09:38:52 +0800 Message-ID: Date: Mon, 25 Dec 2023 09:38:51 +0800 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH] ext4: fix WARNING in lock_two_nondirectories To: Edward Adam Davis , CC: , , , , , , yangerkun , Baokun Li References: <000000000000e17185060c8caaad@google.com> Content-Language: en-US From: Baokun Li In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500021.china.huawei.com (7.185.36.21) On 2023/12/24 19:53, Edward Adam Davis wrote: > If inode is the ext4 boot loader inode, then when it is a directory, the inode > should also be set to bad inode. > > Reported-and-tested-by: syzbot+2c4a3b922a860084cc7f@syzkaller.appspotmail.com > Signed-off-by: Edward Adam Davis > --- > fs/ext4/inode.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 61277f7f8722..b311f610f008 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -4944,8 +4944,12 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, > inode->i_fop = &ext4_file_operations; > ext4_set_aops(inode); > } else if (S_ISDIR(inode->i_mode)) { > - inode->i_op = &ext4_dir_inode_operations; > - inode->i_fop = &ext4_dir_operations; > + if (ino == EXT4_BOOT_LOADER_INO) > + make_bad_inode(inode); Marking the boot loader inode as a bad inode here is useless, EXT4_IGET_BAD allows us to get a bad boot loader inode. In my opinion, it doesn't make sense to call lock_two_nondirectories() here to determine if the inode is a regular file or not, since the logic for dealing with non-regular files comes after the locking, so calling lock_two_inodes() directly here will suffice. Merry Christmas! Baokun > + else { > + inode->i_op = &ext4_dir_inode_operations; > + inode->i_fop = &ext4_dir_operations; > + } > } else if (S_ISLNK(inode->i_mode)) { > /* VFS does not allow setting these so must be corruption */ > if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) {