Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=104.30.16.97 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796362566; b=rhlOilnk/jxC+Vcn3RmJUPUzAqJUvQBP4swmPlXpv1uku5tDU2dtc/iDqQECENXQPfH6 WLt4TP832C+CAoZTjg6S6j5xlJVss/mRU/gT4FisEb1GxiQWLF6SFBUGTaGhPJYELVQqM YFO25qfbELBV7gGFMzWHJDv8tJhMhGQ3DAX8D+f5K00JGMgEctYBMsI+MDBh7ar8QSfnp z55Vg1cZ4fPb/0b2WM5ujMxWumBqnDoAsSwCn82GFQdps2VKULeCDOa4JF9BRgxZ7MeCR IzYaQXEDEZEJvU/byoeqtQAC/D1gq6RYDZCygM3DT9wUaXiyc64fdf8UetKP07iDvgQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796362566; h=DMARC-Filter:DKIM2-Signature:Message-Instance:DKIM-Signature: DKIM-Signature:Feedback-ID:From:Message-ID:Date:Subject:To: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=cxcZyshZNHt4GUoSlBZZGPGntgJQpMTuKMsPZTjYnRA=; b=D3fzRYceSnh/egPNN36Qkqp8gtU+HedzEgtF7yueIGLZVvVmwuX5cyiymCNadTIUG2FC 5+Ki8kOIOCIEPCpIYYxoN1WVattes4odmm/VCfJ1lIViGOyu++hnBChUhk+MahIz8cIUQ RP3kSiTgZiaVPZirvt0d4XmPVjyfxFi+iTA5lukflHNX6GFrkx38FS/XxEGZD8W9MsqUa VvbcSw1Jjj+PO0gEo7EZNhsjIIkii19BOIDXrfSG6N8Uw94GEbkCY5gEZWDHEPikctxHB ERSR6KbsiADpvBI1kyrm90SEkoGCpnYcyD23Xiy1TznZNwNcxOkXwq5QFnSxYgFY+Wg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=talkjune.com; spf=pass smtp.mailfrom=cf-bounce.talkjune.com; dkim=pass header.d=talkjune.com header.i=@talkjune.com header.a=rsa-sha256 header.s=cf-bounce header.b="W/aVV/77"; dkim=pass header.d=cloudflare-smtp.net header.i=@cloudflare-smtp.net header.a=rsa-sha256 header.s=cf2024-1 header.b=ZMk49dYA; arc=none smtp.remote-ip=104.30.16.97 Received: from bg-jh.cloudflare-smtp.net (bg-jh.cloudflare-smtp.net [104.30.16.97]) (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 B272C606A322 for ; Fri, 4 Dec 2026 05:36:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B272C606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=talkjune.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cf-bounce.talkjune.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=talkjune.com header.i=@talkjune.com header.a=rsa-sha256 header.s=cf-bounce header.b=W/aVV/77; dkim=pass (2048-bit key, unprotected) header.d=cloudflare-smtp.net header.i=@cloudflare-smtp.net header.a=rsa-sha256 header.s=cf2024-1 header.b=ZMk49dYA DKIM2-Signature: i=1; m=1; t=1796362565; d=talkjune.com; mf=PGIxYXVqeGt3 NnhjaWZkcXd2eTJ5emo1c2d3M3VldXM0ZWlmcWdpZXRmejYzaDM2a2E3ZWFAY2YtYm91bmNl LnRhbGtqdW5lLmNvbT4=; rt=PGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+; s= cf-bounce:rsa-sha256:C9+ypjCe/DsbTXXe46g2d13CVdNDs6zw49jXbq9u4ELBoM3GWQmt ElWVzNrvSvt306YUpLLjgAqwAD51YYBwhQ8Z8WoXwsi/QPFVvBIAPWiGSAO7GS4J4sqq9jmk 4VJJKuYzK1OyUmU+IYrymr+vz2CK6lOD8TbdHtWOq0FN0xaqcpDl7hWw1dP1kkX7drsqABJp iGprBzC8RGM6ZyXgTyIPAaTLML+FtN3ehcraiCOyb+5CRIOnVU0Sb9Spby9rAdfXI/mCuVQk wvIsLVZ/w2IJCgHP3xibH1FQCkz/uvwJON9e7dSwXRm0+fSj6xgQYuh9Zwy5JrB5CqMZafDx Ug==; Message-Instance: m=1; h=sha256:HuxuFC745PihYLcrkw6GjI3oYaGQQtxTm7pMDkwJ hL8=:QCy2TvylDpSaD/IobwMBAMPLsDWLCLcxx4kl4LQ+/aY=; DKIM-Signature: v=1; a=rsa-sha256; s=cf-bounce; d=talkjune.com; c=relaxed/relaxed; h=To:Subject:Date:From:Feedback-ID:from:reply-to:cc:resent-date :resent-from:resent-to:resent-cc:in-reply-to:references:list-id:list-help :list-unsubscribe:list-unsubscribe-post:list-subscribe:list-post :list-owner:list-archive:otp-token:otp-token; t=1796362565; x=1796967365; bh= cxcZyshZNHt4GUoSlBZZGPGntgJQpMTuKMsPZTjYnRA=; b=W/aVV/77EaFwcDzS/fZ9KfnFcot gbLdOncxQoiThSJ8up7UBvDSD3zM2/iZUV6rvYEJioyf16YQMCEH77j5WBq7+b8RrhfOAovdLIQ +3TjNrWZH2UYBCiBZFJK8Q8O8HRyC+nofQ0g6CC2SOTth1USOL7UqCydztYiXbVvHbXWLyH4Fhp 5rmavG59UsQgQVAhOH/CDVo4kSp5LhKaIoqOIehCQ20FDiunRQ6XrFpx9mRIxJdv1wB+WTp97wk 5BYW3Rpx/VzdclVrMeapV79nz2+H700jghaM0kthaV8jY28bkQurBQTc6SLXa/Ez712Gd1fm68j WyQ30O9WxvJ9Fxg==; DKIM-Signature: v=1; a=rsa-sha256; s=cf2024-1; d=cloudflare-smtp.net; c=relaxed/relaxed; h=To:Subject:Date:From:Feedback-ID:from:reply-to:cc:resent-date :resent-from:resent-to:resent-cc:in-reply-to:references:list-id:list-help :list-unsubscribe:list-unsubscribe-post:list-subscribe:list-post :list-owner:list-archive:otp-token:otp-token; t=1796362565; x=1796967365; bh= cxcZyshZNHt4GUoSlBZZGPGntgJQpMTuKMsPZTjYnRA=; b=ZMk49dYAMv8KSqs0GfQAdAn10YK ojci85Z/E4YujhrhHifoISmF2hh+ZRZHUTF6dz2E06rVDJD9OCMqHO6x6VdVjRb0JbKBFtryXdM WcwlKi05aukgNOB9oYPcJGvY/U7Z/QGZyTU4lyfLRNoIlCYHoo49rN9rE6hTGrt/B0FH3Iq4IwG XO3GdSM5IyKAXINmr73gOuMKg/xWAjQK9+UOdusypQlS6gF+ipRkJE2td3kFPlDwh8RCpEZ12ge +3Zfy5OHYl8All47edNbdo1qLqw9N/lLN7lWystCmmjl+akmfhKQm8z1aF+5M+eVcb/2SArqqYD hx+05ZO7BBgeDWg==; Feedback-ID: talkjune.com:5:5:Cloudflare From: "Mar Dominguez" Message-ID: Date: Fri, 04 Dec 2026 05:36:02 +0000 Subject: [PATCH 0/3] hfs: fix writes to b-tree nodes larger than a page To: "Viacheslav Dubeyko" , "John Paul Adrian Glaubitz" , "Yangtao Li" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org 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 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit hfs_btree_open() accepts b-tree node sizes up to 32 KiB, and the read side handles nodes that span several pages, but hfs_bnode_write(), hfs_bnode_clear(), hfs_bnode_copy() and hfs_bnode_move() only use the node's first page. Any change to a catalog or extents tree whose nodes are larger than PAGE_SIZE then writes past that page. Patch 1 makes the four helpers walk the node's pages. Patch 2 rejects node sizes below 512 bytes, as hfsplus does. Patch 3 adds KUnit tests for the four helpers. Patch 1 fixes the write helpers instead of refusing nodes larger than 512 bytes: hfs_btree_open() has accepted them since 2.6.12, and the read and node creation paths already support them. With patch 1 the write helpers do too, as the hfsplus ones do. Tested with x86_64 KASAN builds under QEMU: hfs/for-next (a2c27efbbd43) with CONFIG_DEBUG_VM, and mainline (007722b8211f) without it. The test volumes were made with hformat, with the catalog tree rewritten to use 8 KiB or 32 KiB nodes. Without the series, mkdir and rmdir on them hit the VM_BUG_ON in memcpy_to_page() with CONFIG_DEBUG_VM. Without CONFIG_DEBUG_VM, the volume can't be mounted again after mkdir (8 KiB nodes), and rmdir (32 KiB nodes) crashes init through corrupted memory. With the series, both work and the volume mounts again with the expected directories. A volume with the usual 512-byte nodes behaves the same with and without the series. The hfs KUnit suites pass on UML with KASAN; without patch 1 the four new cases fail. I have not tested on 32-bit HIGHMEM, on architectures with pages larger than 4 KiB, or with volumes written by Mac OS, and I have not run xfstests. Patches 1 and 2 also apply to mainline; patch 3 needs the KUnit setup in hfs/for-next. I can send the test images privately. Found and written with an LLM coding assistant. Mar Dominguez (3): hfs: fix b-tree node writes past the first page hfs: check the b-tree node size range in hfs_btree_open() hfs: add KUnit tests for b-tree node operations fs/hfs/Makefile | 2 +- fs/hfs/bnode.c | 132 ++++++++++++++--- fs/hfs/bnode_test.c | 293 +++++++++++++++++++++++++++++++++++++ fs/hfs/btree.c | 5 +- include/linux/hfs_common.h | 6 +- 5 files changed, 416 insertions(+), 22 deletions(-) create mode 100644 fs/hfs/bnode_test.c base-commit: a2c27efbbd43d2e3756860ebd1bf891d7481f2c5 -- 2.53.0