From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410685; b=Wv/gw+dxDpo3J3NhpyChI3KvVsbcU0snb8SOFVryUGabvgkqxC8o+6awCLjm9FclWRQN wyVvJvSJa09noPR7+BUDUS2JqTvZYXczQNxqo0QyCo1l9J9Lelt8GEQUwIwiWNms4FLRS 4UR18B+5JPkS2yC43GwQAS7o3OSAv3xkjtsB0N0OULvOyhQaZPw0rJVLkIliWqBCrJlRZ 7nOdyef6v8UcKa2q57BuPYcjWs9dlYTEMLKurQIT+fC1TvB5Dz0CC1X4gVM+nuL31gdve oRIvdFKfLCnG1AO36/6lzrpGv3Y4Zu+KK34U0FfcdECwd8JudEvwIQc5Sm8TEk5iJkw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796410685; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References:Autocrypt: Content-Type:Content-Transfer-Encoding:User-Agent:MIME-Version; bh=xVJ3oQLoUZIpOAxfsqfXtEwx69CC7lUyZCRlOgojX3U=; b=F0X/fSIdzViRZdVAmOGTS7aYWrbA26zHeNOj91V82NjwjWxBLbHQ4eGTqbcyd0ENOiI0 3qAbBvryfZTCF+dccPaNhAa3IU/gAg1I3emPx0uN5Ow2wcmQfaD9Myd30OY0fBg4bztze uVOnIkpWpkISzle85jKb9HxhdbfckBTH3GX5U0HcF2oLZEyB32oWqwb/dBm6SYu7QbQhL kqseST1j1KTvJRm+DRJjaU2QxgMWyQ4KcWa4xkde9OTiTBKDN6ipFuKfwklFgAc0IEV/C t2Ioop26Ae7crd6y6YD5Xm2Pkt7pl/cJfMUPX1qfgmM3c+g/y1RKvZEVbcO+ufe4ieg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=dubeyko.com; spf=pass smtp.mailfrom=dubeyko.com; dkim=pass header.d=dubeyko-com.20260707.gappssmtp.com header.i=@dubeyko-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=UGnZXjM+; arc=none smtp.remote-ip=74.125.224.42 Received: from mail-yx1-f42.google.com (mail-yx1-f42.google.com [74.125.224.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE2A5606A322 for ; Fri, 4 Dec 2026 18:58:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AE2A5606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=dubeyko.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dubeyko.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=dubeyko-com.20260707.gappssmtp.com header.i=@dubeyko-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=UGnZXjM+ Received: by mail-yx1-f42.google.com with SMTP id 956f58d0204a3-67da7d18f2fso1488034d50.0 for ; Fri, 04 Dec 2026 10:58:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20260707.gappssmtp.com; s=20260707; t=1796410684; x=1797015484; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :from:to:cc:subject:date:message-id:reply-to:content-type; bh=xVJ3oQLoUZIpOAxfsqfXtEwx69CC7lUyZCRlOgojX3U=; b=UGnZXjM+tzbTtD0BL6M0o0CUH4GSJPgkl09huPanxjac19DAThFMnJ+2t87HmqvqkD mgyMNeLSNEv1Cu7a6b/jpWu5Rf3CI2QC1JZgwBJCA7dMDpy4h3tJCe5HfQM9zsQPqh4c j4mK2nrIndbLs30mI2TTahw85HrxogF4qSDfjb+WPvXNjPioQojyDBQI1e5DSw/AtmlY dVy4sreHV+GdkkioPgR19qgvOku0yQKWwJoUTUMIo0je8EHUM70vCLjCF5ljAnkxkOO+ MWa1nLwD5X8LH0EvHs2bAooHTJaiBCwYSYJPaV2bEKu+8g/HAAlTwdx1eCJp9GF++W2c zaxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796410684; x=1797015484; h=mime-version:user-agent:content-transfer-encoding:content-type :autocrypt:references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=xVJ3oQLoUZIpOAxfsqfXtEwx69CC7lUyZCRlOgojX3U=; b=kzCrkQWygtZB7u7QrQ5pgEyrvM7gZXG5curlPoB8hKIT7x9HkiBr/eWMbTnnXVgRo0 nyuPcH65glSXF9ni6J2LkzOsW6kvWHsiNfYBsetbtNSReSJigp9vUhYk5wn1zrrz2Zay 5IHrA50SYzFQpHO1iz6V4qnmJ4zlpc684po+dK0EhWNKP3eD/QZqfSG0CwYLAxqg0E0c gVHBBJcnBZ+QNkBQyBU+9hUvAAmMGGte8337akI+/OA5xcSxxn0mWLKHQA+6VKB3IIr+ 2MjyqHmF73YNv07nCDhl6/uZsHbX5d3n8l+8jAribuXqCeE03Asj5xkBDgxZhgX+6Piz leNg== X-Forwarded-Encrypted: i=1; AL+hErGM+0D8jZlIDZHTk1l/v0kX71wiC4CCOMq3saZIJNOVfTfCv7dhdEax45H1LWJVtoloJ6HxgptFnTIQC2Y=@vger.kernel.org X-Gm-Message-State: AB4q+uGF5yZD8pjQ24+D2Qu5TfvgqxSui/Vwq/PbrNIp6eFRUMdT65XX RYi2D26voggPcrhbHQlxbq9T9M8wNd2/HDkoVfQ3XGjGAgS264aN6oiGjNg57z3kuh+1p74+4Lu Yvh1G5Bs= X-Gm-Gg: AZFdTZeET3LkVvWTjnP6P//m34/46Gg2Bv9MfDIFK1fq3+divFOIsMdDs3nDhQVLZ1T pYU8J7UdOJGGlEVWrVGbmW/LZ/lla5Ah4oAfrUmqrrr70lNSVly38HxTVDeOeIix25xEnh8+A07 op7d3mzhfX8IRN9MbUtdixxqrkyksM+7n0tbVGJ0is6Ye65ScajN4pYf4d6aWEDCumZWK3espUL +sAwIEoVzpNJbiZDSn365ms9UoHQA8+hsEbDTePOSytlZmwHNXC7VAxUBR6sK54y82wuv1dGTh7 LdcM89PcspS7WIKyVhlwmRkwgUCRFwIVQXR32W8N/2sCPTsbZXzoDEQmNsix2g4Js5lFNbDUvBp 3dE6Z8hPww4DQ091L9tDy0AUEynrjzZNlvIo4HS7FfZgRiKVhrFWvIK+Nenv1H+hOgvlJeNvVug MTKpLAYdmDviXhVCUYPvyDE+xx18qLsZK6RhHETeuW/MgetYmIqGlETfbQley3gIfNA1i+Y82S+ Mg46dlUj8KRpd5fDLXGXAmbD6rH1jZC1OAbJNVT3O3Wm+2HpeGKCREgLqSRuM8H1fmOA0vYavai QIAXUCFpgVFMfu8ZV47qlJLXF5//qw6iZyutEWRKMQVD47e1CK4/5avGwKZDrbAkJJS5PC6SqMc MQzHjCLE+vFIkdE9Vc7wFCO6mDEXAIt1uA3t9KPFG7YPO84eb4KbmXfPJT6uV64IbDlXm8AuIXt 8gm+GhTTMY5fwIh3i8JIYS+QxWRDJjYZME5lyXwEkD X-Received: by 2002:a05:690e:c88:b0:67d:ab84:3bd6 with SMTP id 956f58d0204a3-67f6a3a0dfbmr1365344d50.1.1796410683487; Fri, 04 Dec 2026 10:58:03 -0800 (PST) Received: from ?IPv6:2600:1700:6476:1430:8a82:9efd:4df6:308d? ([2600:1700:6476:1430:8a82:9efd:4df6:308d]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67f0c08875bsm1409316d50.5.2026.12.04.10.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 10:58:03 -0800 (PST) Message-ID: <9e74ec2518e493ffbf4a5d94443825e95099e428.camel@dubeyko.com> Subject: Re: [PATCH] hfsplus: keep a volume with a corrupted b-tree map read-only on remount From: Viacheslav Dubeyko To: Song jeonghak Cc: John Paul Adrian Glaubitz , Yangtao Li , Shardul Bankar , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+2bf21610eea63cb2ce93@syzkaller.appspotmail.com Date: Fri, 04 Dec 2026 10:58:01 -0800 In-Reply-To: <20261204043815.368179-1-thdwjdgkr123@gmail.com> References: <20261204043815.368179-1-thdwjdgkr123@gmail.com> Autocrypt: addr=slava@dubeyko.com; prefer-encrypt=mutual; keydata=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 NFdvziOa4FgUBC4X71upsZIoZJeii2V/Jtc3B4g== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-9 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Fri, 2026-12-04 at 13:38 +0900, Song jeonghak wrote: > Since commit 8ad2c6a36ac4 ("hfsplus: validate b-tree node 0 bitmap at > mount time"), hfs_btree_open() mounts the volume read-only when the > map > record of a b-tree does not mark the header node (node 0) as used. > Keeping the volume read-only stops the b-tree allocator, which looks > in > the map for free nodes, from using a map that is known to be wrong. >=20 > That decision is only kept in SB_RDONLY. On "mount -o remount,rw", > reconfigure_super() calls hfsplus_reconfigure() and then copies the > flags requested in fc->sb_flags into sb->s_flags, so SB_RDONLY is > cleared unless hfsplus_reconfigure() sets it in fc->sb_flags again. > hfsplus_reconfigure() only does that for the conditions it checks > from > the volume header: a volume that was not cleanly unmounted, and a > locked > or journaled volume without the force option. Nothing records that a > b-tree map was found corrupted at mount time, so > hfsplus_reconfigure() > returns 0 and the volume becomes writable again. >=20 > The allocator then finds node 0 free in the map, hands it out as a > new > node and hfs_bnode_create() hits the header node that is still > hashed. > With the syzbot reproducer, the mount reports "Catalog File (cnid > 0x4) > map record invalid or bitmap corruption detected, forcing read-only", > the reproducer remounts read-write and calls mknod(): >=20 > =C2=A0 hfsplus: new node 0 already hashed? > =C2=A0 WARNING: fs/hfsplus/bnode.c:642 at hfsplus_bnode_create+0xa8/0x2d0 > =C2=A0=C2=A0 hfsplus_bmap_alloc+0x45d/0x4b0 > =C2=A0=C2=A0 hfs_bnode_split+0x4e/0x4c0 > =C2=A0=C2=A0 hfsplus_brec_insert+0x104/0x500 > =C2=A0=C2=A0 hfsplus_create_cat+0x212/0x6b0 > =C2=A0=C2=A0 hfsplus_mknod+0xea/0x1f0 >=20 > In the test below, fsck.hfsplus reported "Invalid map node" for the > damaged image before it was used, and "Invalid B-tree header" after > it > had been written to read-write. >=20 > Remember the corruption in a new HFSPLUS_SB_BAD_BTREE_MAP flag when > hfs_btree_open() forces the volume read-only, and check it in > hfsplus_reconfigure() like the other conditions that keep a volume > read-only. The check comes before the force option, as for a volume > that > was not cleanly unmounted: force only skips the checks for journaled > and > locked volumes, and this is damaged metadata like an unclean unmount. > As > for those other conditions, the remount succeeds and the volume stays > read-only with a warning. Reading files is not affected, since the > map > record is only used to allocate and free b-tree nodes, so the data > can > still be copied off before running fsck.hfsplus. >=20 > Tested in QEMU (x86_64): >=20 > - On next-20261130 with the syzbot C reproducer: the warning above > =C2=A0 showed up in 3 of 3 runs before the change. After it, the remount > =C2=A0 leaves the volume read-only, mknod() fails with EROFS and there wa= s > no > =C2=A0 warning in 5 of 5 runs, two of them with slub_debug=3DFZPU. >=20 > - On the hfs tree's for-next branch the syzbot image is now rejected > at > =C2=A0 mount for an unrelated reason, the size of its attributes file. So > I > =C2=A0 also used a freshly created volume with 301 files in which only th= e > =C2=A0 node 0 bit of one b-tree map record was cleared. With the catalog, > the > =C2=A0 extents or the attributes tree damaged that way, "remount,rw" and = a > =C2=A0 remount after "mount -o ro" made the volume writable before the > =C2=A0 change, and the catalog case hit the warning above. After the > change > =C2=A0 the volume stays read-only for those and for "remount,rw,force", > the > =C2=A0 image is byte for byte unchanged and all 301 files read back with > the > =C2=A0 right checksums. >=20 > - An undamaged volume can still be remounted read-write, written to > and > =C2=A0 remounted read-only, and fsck.hfsplus reports it as OK afterwards. > =C2=A0 After fsck.hfsplus repairs one of the damaged images, it mounts an= d > =C2=A0 remounts read-write normally again. >=20 > checkpatch.pl --strict and sparse report nothing for the changed > files. >=20 > Claude (Anthropic) was used for the root cause analysis, the test > images > and scripts, and drafting this changelog. >=20 > Fixes: 8ad2c6a36ac4 ("hfsplus: validate b-tree node 0 bitmap at mount > time") > Reported-by: syzbot+2bf21610eea63cb2ce93@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=3D2bf21610eea63cb2ce93 > Signed-off-by: Song jeonghak > --- > This is based on the for-next branch of the hfs tree (a2c27efbbd43). > On > linux-next, commit 6998f4bc12f2 ("hfsplus: don't set SB_RDONLY when > creating the attributes tree") from Christian Brauner's series moves > the > node 0 check into hfsplus_btree_check_map(), and > hfsplus_reconfigure() > is older there. The same three changes apply in those places; that > version is what I tested with the syzbot reproducer on next-20261130. >=20 > On for-next, commit d4821af67733 ("hfsplus: reject special files > larger > than their allocation at mount") rejects the syzbot image because its > attributes file size is also corrupted, so the reproducer no longer > gets > to the remount there. A volume whose only damage is the cleared node > 0 > bit still mounts read-only and could be remounted read-write before > this > change. >=20 > The earlier patches for this report changed the allocator ("[PATCH > 2/2] > hfs/hfsplus: stop btree allocators from reusing node 0") and removed > the > WARN_ON() ("[PATCH] hfs, hfsplus: remove WARN_ON when new bnode > already > hashed"). The allocator change was declined because the mount-time > check > already makes the volume read-only, and removing the WARN_ON() > because > it would hide the problem. This patch keeps that check as the place > where the corruption is handled and closes the remount that undoes > it. >=20 > It only covers what the mount-time check detects, i.e. a cleared node > 0 > bit. Other damage to a b-tree map that the check does not see may > still > make the allocator hand out a node that is in use; I have not tested > that. >=20 > To reproduce without the syzbot image: create an HFS+ volume with > mkfs.hfsplus, add some files, then clear the most significant bit of > the > first byte of the map record (record 2) in the header node of the > catalog file. Mount it, remount it read-write and create a few > hundred > files. Thanks a lot for the patch and for the very careful analysis and testing. You are right: hfs_btree_open() is the only place that forces the read-only state at mount time without hfsplus_reconfigure() checking the same condition again, so remount,rw silently undoes the protection added by 8ad2c6a36ac4. The fix looks correct to me, and I agree that the check should go before the force option. I have several comments, though. >=20 > =C2=A0fs/hfsplus/btree.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 1 + > =C2=A0fs/hfsplus/hfsplus_fs.h | 1 + > =C2=A0fs/hfsplus/super.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 4 ++++ > =C2=A03 files changed, 6 insertions(+) >=20 > diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c > index 0a9b32d5c5bf..9c30bc77cd40 100644 > --- a/fs/hfsplus/btree.c > +++ b/fs/hfsplus/btree.c > @@ -412,6 +412,7 @@ struct hfs_btree *hfs_btree_open(struct > super_block *sb, u32 id) > =C2=A0 sb->s_id, hfs_btree_name(id), id); > =C2=A0 pr_warn("Run fsck.hfsplus to repair.\n"); > =C2=A0 sb->s_flags |=3D SB_RDONLY; > + set_bit(HFSPLUS_SB_BAD_BTREE_MAP, &HFSPLUS_SB(sb)- > >flags); > =C2=A0 } > =C2=A0 > =C2=A0 hfs_bnode_put(node); > diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h > index dd8f7179431a..049d79380518 100644 > --- a/fs/hfsplus/hfsplus_fs.h > +++ b/fs/hfsplus/hfsplus_fs.h > @@ -187,6 +187,7 @@ struct hfsplus_sb_info { > =C2=A0#define HFSPLUS_SB_NOBARRIER 5 > =C2=A0#define HFSPLUS_SB_UID 6 > =C2=A0#define HFSPLUS_SB_GID 7 > +#define HFSPLUS_SB_BAD_BTREE_MAP 8 /* a b-tree map > record is corrupted */ Basically, this flag means "metadata corruption has been detected at mount time, keep the volume read-only". I expect that we will need the same for other mount-time checks in the future. What do you think about a more generic name (for example, HFSPLUS_SB_CORRUPTED) and a more generic message in hfsplus_reconfigure()? > =C2=A0 > =C2=A0static inline struct hfsplus_sb_info *HFSPLUS_SB(struct super_block > *sb) > =C2=A0{ > diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c > index 71ca14cef3c4..64ace4eda5cb 100644 > --- a/fs/hfsplus/super.c > +++ b/fs/hfsplus/super.c > @@ -566,6 +566,10 @@ static int hfsplus_reconfigure(struct fs_context > *fc) > =C2=A0 pr_warn("filesystem was not cleanly unmounted, > running fsck.hfsplus is recommended.=C2=A0 leaving read-only.\n"); > =C2=A0 sb->s_flags |=3D SB_RDONLY; > =C2=A0 fc->sb_flags |=3D SB_RDONLY; > + } else if (test_bit(HFSPLUS_SB_BAD_BTREE_MAP, &sbi->flags)) > { > + pr_warn("filesystem has a corrupted b-tree map, > running fsck.hfsplus is recommended.=C2=A0 leaving read-only.\n"); > + sb->s_flags |=3D SB_RDONLY; > + fc->sb_flags |=3D SB_RDONLY; > =C2=A0 } else if (test_bit(HFSPLUS_SB_FORCE, &sbi->flags)) { > =C2=A0 /* nothing */ > =C2=A0 } else if (vhdr->attributes & HFS has exactly the same issue. fs/hfs/btree.c has the same node 0 check, and hfs_mdb_get() forces read-only mode for invalid CNID counts and for a corrupted primary or alternate MDB. But hfs_reconfigure() re-checks only the "not cleanly unmounted" and "locked" states, so remount,rw makes such volumes writable again. Could you please add a patch for HFS too (with a HFS_FLG_* bit in HFS_SB(sb)->flags), so that we have a two-patch series? Also, the commit message is pretty long. I think the detailed test description would be better placed below the "---" line, keeping the root cause, the fix, and the syzbot trace in the commit message itself. Regarding commit 6998f4bc12f2 ("hfsplus: don't set SB_RDONLY when creating the attributes tree") from Christian's series: I am going to take your patch through the HFS tree, so please keep v2 based on the for-next branch. Thanks, Slava.