Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796079317; b=hbdDTs9D/nTtrbHgqgfu+5YsjnTYotdNrMPJP/xmUg4X1qaOAV8iBNsEzhxvX0R7OsdR DcMbM+OjaG102+xIwCs/wWbK8EawDHhRVDa8SJO8sgNFT1zmDyzxJzKH16RZSDFU77aDU bRY7qY7jWrwEEVHQRAx2D6BJurE1Dxbu//HJrAkRmIqpm+XR+4bmw3IKngXrAA2oxMbmX PqFHwh2WzRQFLs/MsBI+zirTfGZofFAYHhn2xbVsl/gt0a4ZO48cx81fHhqCWmOLKUn8F WaLOZUvqJEkHy8mMYfaNIov0GWhgiWabsuG4zSGO7aCDZnUAZ9aNq9oDJP2iNnGRP5A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796079317; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: 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=rMMT1ePC3sk9hR1OsERQfkWSI0LyYoAsjJozSw5gRv8=; b=BI8GjB8MQMRHgLNIqGT1gBq3T/sRvy5WhCcnrJco+msUP0yYvSo9N6OYDeVJ9+JUqEWc 5uEN5ZplEwtAwQQheh20Fz6iT07s1/fR3y9yDQGCl86QG3JiOjiFurmdCGg5L5KsOvbuw T6t3m16T5qv/pAu1Mbh8KyRRCv+qODwAG401sjNipJ/NFtJLVBC2QnqX2NRe8qZ6zV50R S1SL520Ifyv4I8c5afKDZX0lbBrfzbiPT+Sg6djlhy0NBKopFfnXCqr3AwJ4VMvkIXUvg LH0KOk/ML9U+TY5EjVoFkAdTCn7bAznLH0KJJLP+VZLmHcvru/RBeoRreheA7A6aNXA== 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=kbDQNBIR; arc=none smtp.remote-ip=209.85.128.169 Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) (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 6B4CC606A320 for ; Mon, 30 Nov 2026 22:55:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6B4CC606A320 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) header.d=dubeyko-com.20260707.gappssmtp.com header.i=@dubeyko-com.20260707.gappssmtp.com header.a=rsa-sha256 header.s=20260707 header.b=kbDQNBIR Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-8b4d86f5328so74257767b3.0 for ; Mon, 30 Nov 2026 14:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20260707.gappssmtp.com; s=20260707; t=1796079316; x=1796684116; 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=rMMT1ePC3sk9hR1OsERQfkWSI0LyYoAsjJozSw5gRv8=; b=kbDQNBIRM+j3CVotxxQ8Ww2b3czphlhpfz1fIEkOXxnhCryBZhtY7kaXSq7BrAf2Fn 73CXNxMaRo5oT/QD1bCy6/DpVpOkVKl2vmCuG6LjZISwFm0BAy6LuNFnrUZyOXpOwhFA 2Y088jUaZVj87AsN4FArGcimHQ62P4AVYsRgIiuyZLNFFzu77GK/B+SLnnQwqw1J2m68 4epNnqgwfnu4FAzEOOxcF50RWH/b0Y7VrSwj9qdOv0eLvdZfz8IfXW6k3Om5JLDdjU/j zxkjeHAEdGU3JhOTxIdLh4fL2p2Wpf1BIDPfXB4069lcEyhlanLpdEyq8nNz0u8rPQ3r 9LAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796079316; x=1796684116; 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=rMMT1ePC3sk9hR1OsERQfkWSI0LyYoAsjJozSw5gRv8=; b=SQsypTTJI4m0i++2HQj2bPxQf4jpBDZZFlQjebq1G33w/MOMYzURbDTosXG+cQzMyW SRAqTt5k2r0gIMCfiykKibplyKHvooFx/3pOtZAuRthFbZZMkvkcGRNi8IKAGdK+QqZ3 9XHZsUW5VvbJHcwK9y098e2g4mW5PvueidyUkYoqZ01rP/Qu9euMk4qRdmHphkrKb21D Bcmx1F/qhvT4ZpCMmKdA+pYvUSvl9M2wYOwG+WMOb8nQfhfbOMe1CXQzKB/W2AnesS4f 9uHBpEYH0aTTB+Or1k3T+uvX8UOCtgXrsHalRFfThHzoxK0I0xUvtt3uSVAYxFbO8AZr X40Q== X-Gm-Message-State: APuU4Z/2b4LcFEZx+n6aNYdhO89n7/LEioM8xMrqsH6PXDmayfMTKnNU Xj6f175jilITfOSpjw41hnv3GG680AR/Tmf4MNc8W7ADQhMtoLJXBIoRJraVx1neDfs= X-Gm-Gg: AZFdTZenv4P1OvX2Rv3pu9bgtkMJnJJ4N53Wf8PpQBqLbvLEXMzP5sJ66hsvAfUV+o7 yr+kCJPUb+iNsePZ7pZPwWF3ZVf7Je31E5e3IrSV6XuRdzpjMF5QpOsi/+X1DxupqREY+8xn+GD Sgv0ih+yvEgg2xU1oJJnh5xjZAjoiTxcQgVuVvJ2qfO7XMGt4VJD6Y5/grvxj/V/KXIRgnSm73J BchXE9AT6Do03UN4XRCdtiWawDsMyMapLGP29uVOq42XN17rF5wxR73PKJQXu5XhCp280E8wNT8 e+F2G+S2FXJJv3spR1cGVbobn3zUuCxsSdmQV9lIrfpp3x0JyibUOOzOFAa+y9MptK9SpvZHnl3 P72KiuNev8dU6ktivv+wMoFvG3hT62S9jWymt4Pgfn+ryaaRrDx/AqDBFtnxeSR0fzlTgDNzVNf Pjja5M3I7At6IHs9Dd03bMmvq/CdtWVsXUXPXpfbunaeODxgsFyhtfz6o9esKnikH3ZUZnAFrSX 3WovBlWmX9pG4uhMo2WAUbKGm3+y9LRa4WMVMTO65lZEvBVxiHf9xr3f+MPAU6/vmTviliD6lmB i8mKXENQaRIQoNdgimJEnRieGiZ9vVO28Rla1Ga8/D+OX8lRtP24lyv8YmNn25maSLRbF8QLgYj EpCV0N9JW1iy9VXml3pjQ30dmjUraryTwWX/pjU1Aqnjol0AMHvm1GEMtvpIkDO9HPOHR X-Received: by 2002:a05:690c:2a87:b0:8b4:f46c:cc71 with SMTP id 00721157ae682-8b5204a0cfdmr158371647b3.33.1796079316516; Mon, 30 Nov 2026 14:55:16 -0800 (PST) Received: from system76-laptop.attlocal.net ([2600:1700:6476:1430:6296:81e6:c:6227]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b5201b8cdbsm133085207b3.1.2026.11.30.14.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 14:55:16 -0800 (PST) Message-ID: Subject: Re: [PATCH v4 2/3] hfs: pass the key buffer size to hfs_bnode_read_key() From: Viacheslav Dubeyko To: Ozgun Kultekin , glaubitz@physik.fu-berlin.de, frank.li@vivo.com Cc: linux-fsdevel@vger.kernel.org, yangguikun19@qq.com, stable@vger.kernel.org Date: Mon, 30 Nov 2026 14:55:14 -0800 In-Reply-To: <20261127045416.1160-3-ozgunkultekin@gmail.com> References: <20261119005943.37851-1-ozgunkultekin@gmail.com> <20261127045416.1160-1-ozgunkultekin@gmail.com> <20261127045416.1160-3-ozgunkultekin@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-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Thu, 2026-11-26 at 20:54 -0800, Ozgun Kultekin wrote: > hfs_bnode_read_key() reads the key length of leaf records (and of all > records of variable-key trees) from disk and only checks it against > sizeof(hfs_btree_key). The destination is always one of the two key > buffers hfs_find_init() allocates, each tree->max_key_len + 2 bytes > long: max_key_len in the b-tree header record does not count the key > length field, as hfs_btree_open() checks (HFS_MAX_EXT_KEYLEN is > sizeof(struct hfs_ext_key) - sizeof(u8)). For the extents tree > max_key_len is 7, so the whole allocation is 18 bytes and a crafted > leaf > key writes up to 256 bytes from the image past it. The error path > clears sizeof(hfs_btree_key) bytes of the same buffer. >=20 > hfs_brec_insert() and hfs_brec_update_parent() reach this with keys > that were never validated, the same way as in hfsplus. >=20 > Store the capacity of each key buffer in struct hfs_find_data as > key_capacity in hfs_find_init(), allocate the two buffers from it, > and > pass it to every hfs_bnode_read_key() call. Keys longer than the > buffer > are rejected as before, and the error path clears only the buffer. >=20 > The allocation size does not change: max_key_len * 2 + 4 is now > written > as HFS_FIND_KEY_BUFS * (max_key_len + HFS_KEY_LEN_MAX_SIZE), where > HFS_KEY_LEN_MAX_SIZE is the 16-bit key length of HFS_TREE_BIGKEYS > trees. key_capacity goes after bnode, where it pairs with record, so > struct hfs_find_data stays 56 bytes on 64-bit. >=20 > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Fixes: bb5e07cb9277 ("hfs/hfsplus: fix slab-out-of-bounds in > hfs_bnode_read_key") > Reported-by: Guikun Yang > Closes: > https://lore.kernel.org/all/tencent_F85118A9AFDF9B230D4E8FA672510A3E2F08@= qq.com/ > Suggested-by: Viacheslav Dubeyko > Cc: stable@vger.kernel.org > Signed-off-by: Ozgun Kultekin > --- > v4: now 2/3 so it applies to stable trees without the cleanup; uses > =C2=A0=C2=A0=C2=A0 the literal 14 that 3/3 replaces. key_buf_size renamed= to > =C2=A0=C2=A0=C2=A0 key_capacity and placed after bnode (no hole, 56 bytes= ), no > =C2=A0=C2=A0=C2=A0 comments inside the struct, extern kept on the prototy= pe like its > =C2=A0=C2=A0=C2=A0 neighbours, as suggested by Viacheslav. > v3: > https://lore.kernel.org/all/20261119005943.37851-1-ozgunkultekin@gmail.co= m/ > v2: > https://lore.kernel.org/all/20261118013337.67813-1-ozgunkultekin@gmail.co= m/ > v1: > https://lore.kernel.org/all/20261114043522.48764-1-ozgunkultekin@gmail.co= m/ > --- > =C2=A0fs/hfs/bfind.c |=C2=A0 5 +++-- > =C2=A0fs/hfs/bnode.c |=C2=A0 7 ++++--- > =C2=A0fs/hfs/brec.c=C2=A0 | 12 ++++++++---- > =C2=A0fs/hfs/btree.h | 15 ++++++++++++++- > =C2=A04 files changed, 29 insertions(+), 10 deletions(-) >=20 > diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c > index d56e47bdc..b37448e7b 100644 > --- a/fs/hfs/bfind.c > +++ b/fs/hfs/bfind.c > @@ -21,11 +21,12 @@ int hfs_find_init(struct hfs_btree *tree, struct > hfs_find_data *fd) > =C2=A0 > =C2=A0 fd->tree =3D tree; > =C2=A0 fd->bnode =3D NULL; > - ptr =3D kzalloc(tree->max_key_len * 2 + 4, GFP_KERNEL); > + fd->key_capacity =3D tree->max_key_len + HFS_KEY_LEN_MAX_SIZE; > + ptr =3D kzalloc(HFS_FIND_KEY_BUFS * fd->key_capacity, > GFP_KERNEL); Ditto. Please, see my comment for HFS+ patch. > =C2=A0 if (!ptr) > =C2=A0 return -ENOMEM; > =C2=A0 fd->search_key =3D ptr; > - fd->key =3D ptr + tree->max_key_len + 2; > + fd->key =3D ptr + fd->key_capacity; > =C2=A0 hfs_dbg("cnid %d, caller %ps\n", > =C2=A0 tree->cnid, __builtin_return_address(0)); > =C2=A0 switch (tree->cnid) { > diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c > index fcb5b9cd1..23ad1a565 100644 > --- a/fs/hfs/bnode.c > +++ b/fs/hfs/bnode.c > @@ -71,7 +71,8 @@ u8 hfs_bnode_read_u8(struct hfs_bnode *node, u32 > off) > =C2=A0 return data; > =C2=A0} > =C2=A0 > -void hfs_bnode_read_key(struct hfs_bnode *node, void *key, u32 off) > +void hfs_bnode_read_key(struct hfs_bnode *node, void *key, u32 off, > + u32 key_capacity) > =C2=A0{ > =C2=A0 struct hfs_btree *tree; > =C2=A0 u32 key_len; > @@ -83,8 +84,8 @@ void hfs_bnode_read_key(struct hfs_bnode *node, > void *key, u32 off) > =C2=A0 else > =C2=A0 key_len =3D tree->max_key_len + 1; > =C2=A0 > - if (key_len > sizeof(hfs_btree_key) || key_len < 1) { > - memset(key, 0, sizeof(hfs_btree_key)); > + if (key_len > key_capacity || key_len < 1) { Ditto. Please, see my comment for HFS+ patch. > + memset(key, 0, key_capacity); > =C2=A0 pr_err("hfs: Invalid key length: %u\n", key_len); > =C2=A0 return; > =C2=A0 } > diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c > index 5a2f740dd..84da30f65 100644 > --- a/fs/hfs/brec.c > +++ b/fs/hfs/brec.c > @@ -138,7 +138,8 @@ int hfs_brec_insert(struct hfs_find_data *fd, > void *entry, u32 entry_len) > =C2=A0 * at the start of the node and it is not the new node > =C2=A0 */ > =C2=A0 if (!rec && new_node !=3D node) { > - hfs_bnode_read_key(node, fd->search_key, data_off + > size); > + hfs_bnode_read_key(node, fd->search_key, data_off + > size, > + =C2=A0=C2=A0 fd->key_capacity); > =C2=A0 hfs_brec_update_parent(fd); > =C2=A0 } > =C2=A0 > @@ -156,7 +157,8 @@ int hfs_brec_insert(struct hfs_find_data *fd, > void *entry, u32 entry_len) > =C2=A0 entry_len =3D sizeof(cnid); > =C2=A0 > =C2=A0 /* get index key */ > - hfs_bnode_read_key(new_node, fd->search_key, 14); > + hfs_bnode_read_key(new_node, fd->search_key, 14, > + =C2=A0=C2=A0 fd->key_capacity); > =C2=A0 __hfs_brec_find(fd->bnode, fd); > =C2=A0 > =C2=A0 hfs_bnode_put(new_node); > @@ -450,7 +452,8 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 } > =C2=A0 fd->bnode =3D hfs_bnode_find(tree, new_node->parent); > =C2=A0 /* create index key and entry */ > - hfs_bnode_read_key(new_node, fd->search_key, 14); > + hfs_bnode_read_key(new_node, fd->search_key, 14, > + =C2=A0=C2=A0 fd->key_capacity); > =C2=A0 cnid =3D cpu_to_be32(new_node->this); > =C2=A0 > =C2=A0 __hfs_brec_find(fd->bnode, fd); > @@ -462,7 +465,8 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 if (new_node =3D=3D node) > =C2=A0 goto out; > =C2=A0 /* restore search_key */ > - hfs_bnode_read_key(node, fd->search_key, > 14); > + hfs_bnode_read_key(node, fd->search_key, 14, > + =C2=A0=C2=A0 fd->key_capacity); > =C2=A0 } > =C2=A0 new_node =3D NULL; > =C2=A0 } > diff --git a/fs/hfs/btree.h b/fs/hfs/btree.h > index 1f703f2c5..404e526f9 100644 > --- a/fs/hfs/btree.h > +++ b/fs/hfs/btree.h > @@ -74,11 +74,23 @@ struct hfs_bnode { > =C2=A0#define HFS_BNODE_NEW 1 > =C2=A0#define HFS_BNODE_DELETED 2 > =C2=A0 > +/* hfs_find_init() allocates search_key and key as one buffer */ > +#define HFS_FIND_KEY_BUFS 2 Ditto. Please, see my comment for HFS+ patch. > + > +/* > + * Room for the key length field at the start of every key. The > + * max_key_len of the b-tree header record does not count it (see > + * hfs_btree_open()). The field is a u8, or a u16 in > HFS_TREE_BIGKEYS > + * trees (see hfs_brec_keylen()); the buffers have room for the > larger. > + */ > +#define HFS_KEY_LEN_MAX_SIZE sizeof(__be16) Ditto. Please, see my comment for HFS+ patch. Thanks, Slava. > + > =C2=A0struct hfs_find_data { > =C2=A0 btree_key *key; > =C2=A0 btree_key *search_key; > =C2=A0 struct hfs_btree *tree; > =C2=A0 struct hfs_bnode *bnode; > + u32 key_capacity; > =C2=A0 int record; > =C2=A0 int keyoffset, keylength; > =C2=A0 int entryoffset, entrylength; > @@ -117,7 +129,8 @@ extern void hfs_bmap_free(struct hfs_bnode > *node); > =C2=A0extern void hfs_bnode_read(struct hfs_bnode *node, void *buf, u32 > off, u32 len); > =C2=A0extern u16 hfs_bnode_read_u16(struct hfs_bnode *node, u32 off); > =C2=A0extern u8 hfs_bnode_read_u8(struct hfs_bnode *node, u32 off); > -extern void hfs_bnode_read_key(struct hfs_bnode *node, void *key, > u32 off); > +extern void hfs_bnode_read_key(struct hfs_bnode *node, void *key, > u32 off, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 u32 key_capacity); > =C2=A0extern void hfs_bnode_write(struct hfs_bnode *node, void *buf, u32 > off, u32 len); > =C2=A0extern void hfs_bnode_write_u16(struct hfs_bnode *node, u32 off, u1= 6 > data); > =C2=A0extern void hfs_bnode_write_u8(struct hfs_bnode *node, u32 off, u8 > data);