From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 11AAF346FB5 for ; Mon, 30 Mar 2026 21:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774907122; cv=none; b=QJpz9WBCfH60TnZ2KbS0UfYNgZS/E4QMjkexqfsf6YYEZlmoiwPbtYc8gyTp0DW1uRYtWY7hMiTTEXxB0OAeWt8ObSjv/WNhTPaIFErrmWQA3SEjlaTOuZbLcJ5tvk0VcepbaYBogXsDiJv/P09Jzn6bO8W7MJ6+nBFemTbYhmo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774907122; c=relaxed/simple; bh=u5CMhJnDSjk9w+7QYWtL0MZbrITE4DBVIwmC6Nf6O8w=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References: Content-Type:MIME-Version; b=BYxzU5K4roww6f8Z3TyQJcLCHJ5Kt0VJRuin3YEXvRxEK9oq62DjE2ErA9qImbW4ignqtVKM9iVj1q+JJhM30oCmN5hyqEu24UJtOhUr0BLVCJgJaFhwdqSDhJoIjB8VuXqpfDSNYTcHZmbKAB6Erwr0r1s7HRoTR4xyqwStu2c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HU/FVfc4; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=BGFm+WUJ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HU/FVfc4"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="BGFm+WUJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774907120; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4RGzN+VbSyaJFwChFUr/Hnqf6cRBio09qiiLj25Xf/o=; b=HU/FVfc41wQvidOPlWmaKYnQSOQahbCsc4nUwx3qgF0oQqC/saL0w8fMK7wj4i1avHRo0f a79tq9jzRj1A73NoQHsI7+w1XyKRbckGLQz4i2w0kzmYUMi0yIn4oGvUDE7BAHzEpYBXP8 23WT+WIun2HX83rzM6RZlP1YJ5awq+4= Received: from mail-yx1-f69.google.com (mail-yx1-f69.google.com [74.125.224.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-410-9fkCNlA5MY6D4-kQ7JtxmQ-1; Mon, 30 Mar 2026 17:45:18 -0400 X-MC-Unique: 9fkCNlA5MY6D4-kQ7JtxmQ-1 X-Mimecast-MFC-AGG-ID: 9fkCNlA5MY6D4-kQ7JtxmQ_1774907118 Received: by mail-yx1-f69.google.com with SMTP id 956f58d0204a3-649f0d26e5eso11857767d50.0 for ; Mon, 30 Mar 2026 14:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1774907118; x=1775511918; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=4RGzN+VbSyaJFwChFUr/Hnqf6cRBio09qiiLj25Xf/o=; b=BGFm+WUJxvts2BkRkvvunesvG7tCR1t+SxlysuqNtnFAirAyoC3HPSmROr/Mq8YEgC lGx3g38pi885fPzYVQFJPUt9eJrDy3s4bqgZ9LJ/GVYohVTCR39EXpOQjuhNonz1gztW XQe3qG0G6P6dV69LjzWhmoAS+Hl/PvzdPDa5PKh6CcHkelCvav6Fd53hK2PeIov96qGt LIJX8S9NNsmARLAO6t+mRCt5Fe1gEepVYqA6PjiCcdZNiBdFVTPLhQRQmTtUU3tQz1Hm w2y+d0RJ4nRuTkmynh1aisduA5CnHn63i/YfuaHYQvC6Cd0Lz2Hgp6u6Xi3LNEKOC9Nd 5FEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774907118; x=1775511918; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4RGzN+VbSyaJFwChFUr/Hnqf6cRBio09qiiLj25Xf/o=; b=gJTIA7kdVAWYnQMQSMuPT9z3pX4SXazFB+cpN2kUwDT7WKRqpAFRKxQt5gPWiblgkk L48kHCcIM9zgodPHf8DY+jY3HwUaDNtSGrbh4F565RQrq1O9yHDrSu9Q7i1MNMDlYkVo KTVAjqpzAGUNkb8EAWrMSusfT7CwLbydFvL8Cn+vuicRTQ8D09oiwdQIsLocUaRD0LIL g2n1+UUy2VDZx1F7m/h8Tjyd/lLA56vzb3MiartHYKVIn7dd/f4rmEBfXFXk/9Ip4cDS eGXWNcB9/xaRDFsbyAJ/DycR34rlCvW8sCXo+ymtmM/EuUZnXMEQVQeejfMn1e9mDWdO QV7A== X-Forwarded-Encrypted: i=1; AJvYcCXCCvSesDTM1tVxpIozejHdse2Tqw1VWad+OvuJ2pNtTNOu4dol4cJpcCLzQGHYcjwVAniEGeIyukWImN0=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4pP6ecTIUbmcgBj4qnGYhZJhKqT6FVtwqG2koiNMHlf+mVgng f/kpDcjM+nKMvXDVcZ7656UonUeQjk2tbsCnUwoaihkNv5EvniKE30cgep4uDMnemOGV934OExI I0Huq29ymR63FnUf6JTPwIDtMPfS8MJrEfTfNzhJEEGu/+xs2EYCQ/pmDVtHKQWiVVw== X-Gm-Gg: ATEYQzz2gqdyyVDQayJBelvfwOEMPav6+9DTo1hm0+IPcJQTeePowPSOV5UrjMvZI6y lM6FvDP4sYUc/MSbfHR1V7zWJtBbIfqqpblwGcnsGidM5EgctzJt2bUdE9Ypci5V386hXPuEaN5 Jp978u2D1dY9wCZ8Dj233LRoS6mwU/5yle59N1j+WKSUBNepl9wGVbIeT+wbuqDpBt8je0NYako 8nV+wsTWdREEvfH51w7zWYIu2B5tStIf9WlItstaXMie/DT3NICMIlOlX2goVCAQ9wzr7ZLwBm4 zKwUegS2x/AxuVitDZmK49fnpuFGnSqx8zg3rKY3ofGk3pGn7zmMCoc0l9kmZsKPNHGm/A7SRym ykeNkHMTMiGW91ofQ1EynLto83DzA8wjMC+fAlbvxo0jWNVcb1Xw9 X-Received: by 2002:a05:690c:38b:b0:79b:ccb6:a837 with SMTP id 00721157ae682-79bddcbf65bmr139233707b3.5.1774907117860; Mon, 30 Mar 2026 14:45:17 -0700 (PDT) X-Received: by 2002:a05:690c:38b:b0:79b:ccb6:a837 with SMTP id 00721157ae682-79bddcbf65bmr139233397b3.5.1774907117373; Mon, 30 Mar 2026 14:45:17 -0700 (PDT) Received: from li-4c4c4544-0032-4210-804c-c3c04f423534.ibm.com ([2600:1700:6476:1430::29]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-650093816fesm4570921d50.21.2026.03.30.14.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 14:45:16 -0700 (PDT) Message-ID: Subject: Re: [PATCH v5] hfs: update sanity check of the root record From: Viacheslav Dubeyko To: Tetsuo Handa , Andrew Morton , Linus Torvalds , Jan Kara , Leo Stone , Christian Brauner , Viacheslav Dubeyko , John Paul Adrian Glaubitz , George Anthony Vernon , Yangtao Li , linux-fsdevel , LKML Date: Mon, 30 Mar 2026 14:45:15 -0700 In-Reply-To: <21e7ebfd-d35d-4682-b553-6996cc8c3a8e@I-love.SAKURA.ne.jp> References: <21e7ebfd-d35d-4682-b553-6996cc8c3a8e@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43app2) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Sat, 2026-03-28 at 16:12 +0900, Tetsuo Handa wrote: > syzbot is reporting that BUG() in hfs_write_inode() fires upon unmount > operation when the inode number of the record retrieved as a result of > hfs_cat_find_brec(HFS_ROOT_CNID) is not HFS_ROOT_CNID, for the inode > number is assigned using 32bits integer retrieved from relevant offset of > the file system image. >=20 > Since commit b905bafdea21 ("hfs: Sanity check the root record") checks on= ly > the record size and the record type, let's also check the inode number. >=20 > Since hfs_cat_find_brec() is called by only hfs_fill_super() with cnid = =3D=3D > HFS_ROOT_CNID, we could move hfs_bnode_read() and related validations to > inside hfs_cat_find_brec(). But such change is a matter of preference > while this 3+ years old bug is effectively the top crasher for syzbot. > Let me immediately stop wasting syzbot's computation resource. >=20 > Reported-by: syzbot+97e301b4b82ae803d21b@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3D97e301b4b82ae803d21b > Signed-off-by: Tetsuo Handa > --- > George Anthony Vernon is trying to fix this bug without my patch > ( https://lkml.kernel.org/r/20260311211309.27856-1-contact@gvernon.com ). > But it was proven that George's patch cannot fix this bug. Therefore, > I believe that we came to a conclusion that applying my patch is > the way to go. We can apply George's patch as a further improvement. > But unfortunately Viacheslav Dubeyko (the maintainer of HFS) is not > responding. Therefore, I'm sending this patch to more developers who > might accept this patch, instead of waiting for Viacheslav. It's completely not correct. I am reviewing patches in time when I have eno= ugh free time for it.=20 >=20 > fs/hfs/super.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/fs/hfs/super.c b/fs/hfs/super.c > index a4f2a2bfa6d3..2e52acf282b0 100644 > --- a/fs/hfs/super.c > +++ b/fs/hfs/super.c > @@ -361,7 +361,7 @@ static int hfs_fill_super(struct super_block *sb, str= uct fs_context *fc) > goto bail_hfs_find; > } > hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength); > - if (rec.type !=3D HFS_CDR_DIR) > + if (rec.type !=3D HFS_CDR_DIR || rec.dir.DirID !=3D cpu_to_be32(HFS_RO= OT_CNID)) I've already reviewed this patch. And I am not agree with this suggestion. We prepare the key with HFSPLUS_ROOT_CNID [1]: err =3D hfsplus_cat_build_key(sb, fd.search_key, HFSPLUS_ROOT_CNID, &str); The hfs_brec_read() executes the search of the record [2]: res =3D hfs_brec_find(fd); if (res) return res; The hfs_brec_find() should found the record for requested key. And if the f= ound thread record contains not correct CNID, then we can check the found thread record and return error as the result of the search. Thanks, Slava. [1] https://elixir.bootlin.com/linux/v7.0-rc6/source/fs/hfsplus/super.c#L57= 1 [2] https://elixir.bootlin.com/linux/v7.0-rc6/source/fs/hfs/bfind.c#L174