From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796166498; b=xVm6JlQO0ddlNqF873IZRNlQqVjQKMk40b8i5oPrto2ZXf8nTm617k5imhlFHdG4G8ut 9KWRDpbQWY4FwhCsVT+nQrs8o1AQcVG9FSyGjcYRtZvtRgqx1OJZOU86EhDJCLhpQw1I4 v0Rb/tc6dqDF4fBVJD7P/ucOVurjKpYJjR8TvycZTlMslAS8jnOIuhcfYfRwVk9aAJG5Y vdqMD9BPRKTgI7rTALXudW9MvWibxqUCWLicqzuiVqrZjicUGAJCY3FeYPeS5MoPwlw5S mMVCB2i0BTEsOSyjKWi94OzjUY6V3CBiJ6CJrwGkOyohKCufstWnzf87FWzmLO1EvUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796166498; 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=SR7zeWYvyeUyml5u761qx88zF7gM3MvLv5N9jQbQlYI=; b=u9KaGu2FwEj1k0/LUl1xHDmnayHZNZoOR1vlmt43Agd83U4bAAnrweM4VCjFGAoUbkMe /ke5yyiCKWOkz713s835NxQrr3hFY4AL8Ei971vPFotT8eUbQNi0DgAkBAm9kAuwSIDHc 55cRXDa/2ZrnEY9E2QRuBDv5cSH1ZxwGk9LqVlSUjP/uCD34CriGp2ZR+pJO1Px8HD4Zf QtN9zbwRoZZ2gi12Q/aLmpUzb1BJVVsaZ79aKFz1YbDIgU9hdQcR0HXD+T7PVQdiqD01I hDPIi2pulSAsQkZKuHX/qaE0Lb/Zb1yobtoqm9INdwdrYy8ZkNF5FZa8fdKXR/uVRdg== 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=JoUS4hRH; arc=none smtp.remote-ip=209.85.128.179 Received: from mail-yw1-f179.google.com (mail-yw1-f179.google.com [209.85.128.179]) (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 6049A606A322 for ; Tue, 1 Dec 2026 23:08:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6049A606A322 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=JoUS4hRH Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-8b4e246acc2so91059087b3.3 for ; Tue, 01 Dec 2026 15:08:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20260707.gappssmtp.com; s=20260707; t=1796166496; x=1796771296; 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=SR7zeWYvyeUyml5u761qx88zF7gM3MvLv5N9jQbQlYI=; b=JoUS4hRHB23la2e1AaXfc3Zp6ujXlBg3jMIdQxCaJ1YHb84iVcFwFuiAMoKamsqp6X 5xqUwKB+fGD6ZCORiwTxAR01T3moi2LQrtFda95i+6wjsulBu/8j77PZLCtohXf9Y6SE joW3xJE7JCV6u+Hhb0A+RUl2jl2KAxYQpMtuJkUNZrI4peTqsg2/Sh4AtaQRn6hHs/44 ZXOvg5LyDaxpGZT+rKu/mRSuCTnMxVyxu99ZGKqbNSVTaoyz6htOGThGu8llaw1Lf0fP Z9L/e/StAVz+BNnhqsTLkmuDatAU2KWoeGk5Q61dTs3LY6wq7pJijTUS7SCm5eUtKxjD F96g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796166496; x=1796771296; 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=SR7zeWYvyeUyml5u761qx88zF7gM3MvLv5N9jQbQlYI=; b=KunUsJ6rPInU57oKv501wJxE5lvFeBtoxQfsfgVkNaLv1kiMCidx4mTVUavEnvwsr8 XcFqRc4MIGJD/40RGUhao+SxUotWMkByK689TMwAbcF9Ux9D3J4Yc8p3nt6vt5KJlqh6 pISK9VO+Dnuj4d2CgpckuHTtOeYVC84Qi6Q4eKYHwzkXYplOBWJ8tn2CW87u/deY+8Md M09mhXzN3FZ93DfCpv+2OBEe1yg4vzp5OPZw61nInv2p+/2+9C+BJ7E9eAj6dePOoZSv u/uwzwZ5kEJJw44aKrdngUSkGORlJ+2SL2fl9KJkvJDJRjOznPJ/+f669D/fxoqQccmu C6Uw== X-Forwarded-Encrypted: i=1; AL+hErEUi684E4yldvChYS2aviRDkm6gWXjfFA9QTwYNrqF+g/9lah/hn7JQubcQEurE2MkzW0Gv9PaUPFru21c=@vger.kernel.org X-Gm-Message-State: APuU4Z84G3srkcr/djihqedbWDNyXqfBEhqoDbIEyItXhycWNekqd+ye sr5Ytccw7g67RXZYJoXJDzq1EF6tFsdMGHaLl+J8KhcfTYfIQ1ZCaIKl7cNrwy+lHxs= X-Gm-Gg: AZFdTZeuSrTfWxh8gJbT7kV0ibpgVh+NtmFZU5Ht6cJ0xEtrZf0kXWnneh50+NL189f o06n/waw2j7/jcKxayTV4LCo99/1i3XetgcImyCiu39OPDNRh3EJrJwDTxFcR0pYRaQRhK8TZtG TUPauOqLrf6NN3umqsSGu8o/+23jwxNd/MRdOBD+YY0Fv0zKSTNZiUdeZXgcGi/dEyj1vMYhCVu H654r0WqtppIUbDhSIzCdy/gBxeQuM3mn1GUJXwFPLDDbv5Fh1cs9pCq5kHemTppqt0czthnQM3 TPw6Oh13R7HBQXslFthirCcc0zGyoBeqRGBdhieWKNaGhCb2ljXcSa0Pki6EoM8rpJ06jQ2VAjK j8Ps0wlBTQxCXD9RcxnBywb6NkKqlWd1wv6dxtrPL6re3zEP2yDtHWnGDUcypmmOw9eaVxQnIpF HBlXJpEh30F0QePltaOR6MoYeCfr4wE2rjsY28QahyiWWdQaNyHRw7gMOyltBZQaWgsVkohMKSn RQ4spXgw5V+3r0QzDnxfXcsP0BWkuhxLvLU+10E9LjO11AntCYPcZ6r2HV08qMgUSRI248gDEAM 3+XDYO+t38tRGKAZ0P5RG33ISNAWzahf7uNYAl2T5RvGX55xg4bhsgW1U0tKmlfEAMUm0KJMyw0 be4UHWjnihatCp+Y7DZJO2dYobszazBJOv75+7MogXhNsabN3xmugNxy1a0414Dzr9ql/j/aoyW ZaNRf/OWAZKtykZgfk X-Received: by 2002:a05:690c:693:b0:8b5:6e9:2183 with SMTP id 00721157ae682-8b520319b6amr163913697b3.7.1796166496186; Tue, 01 Dec 2026 15:08:16 -0800 (PST) Received: from ?IPv6:2600:1700:6476:1430:f726:86c4:c7ef:c27? ([2600:1700:6476:1430:f726:86c4:c7ef:c27]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b5202cb0b0sm153206497b3.23.2026.12.01.15.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 15:08:15 -0800 (PST) Message-ID: <5939d448327a6379a206a4b69fd385c697755e77.camel@dubeyko.com> Subject: Re: [PATCH v5 1/3] hfsplus: 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, linux-kernel@vger.kernel.org, kovalev@altlinux.org, brauner@kernel.org, cengiz.can@canonical.com Date: Tue, 01 Dec 2026 15:08:13 -0800 In-Reply-To: <20261201094246.80197-2-ozgunkultekin@gmail.com> References: <20261127045416.1160-1-ozgunkultekin@gmail.com> <20261201094246.80197-1-ozgunkultekin@gmail.com> <20261201094246.80197-2-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-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 On Tue, 2026-12-01 at 01:42 -0800, Ozgun Kultekin wrote: > hfs_bnode_read_key() reads the key length of leaf records (and of all > records of variable-key and attributes trees) from disk and only > checks > it against sizeof(hfsplus_btree_key), 518 bytes. 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 __be16 key_len field, as hfs_btree_open() > checks (HFSPLUS_EXT_KEYLEN - sizeof(u16) and so on). For the extents > tree max_key_len is fixed at 10, so the whole allocation is 24 bytes > and > a crafted leaf key writes up to 516 bytes from the image into > kmalloc-32. The error path clears 518 bytes of the same buffer. >=20 > hfs_brec_insert() reaches this with a key that was never validated: > when the tree root is 0 it reads the key of record 0 of the leaf it > inserts into, and after a split it reads the first key of the new > node. > A read-write mount that extends the catalog, or an append to a file > whose extents spill into the extents tree, is enough. >=20 > Do not let hfs_bnode_read_key() assume the size of the buffer. 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 > key_capacity * 2, where key_capacity is max_key_len plus the size of > the > key_len field. 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 > --- >=20 > Notes: > =C2=A0=C2=A0=C2=A0 v5: search_key and key stay in one allocation, now wri= tten as > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 key_capacity * 2 with a commen= t, and the size of key_len is a > local > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 constant; HFS_FIND_KEY_BUFS an= d HFSPLUS_KEY_LEN_SIZE are > gone. > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Rebased on the hfs tree for-ne= xt branch. As suggested by > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Viacheslav. > =C2=A0=C2=A0=C2=A0 v4: > https://lore.kernel.org/all/20261127045416.1160-2-ozgunkultekin@gmail.com= / > =C2=A0=C2=A0=C2=A0 v3: > https://lore.kernel.org/all/20261119005943.37851-3-ozgunkultekin@gmail.co= m/ > =C2=A0=C2=A0=C2=A0 v2: > https://lore.kernel.org/all/20261118013337.67813-1-ozgunkultekin@gmail.co= m/ > =C2=A0=C2=A0=C2=A0 v1: > https://lore.kernel.org/all/20261114043522.48764-1-ozgunkultekin@gmail.co= m/ >=20 > =C2=A0fs/hfsplus/bfind.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 11 +++++++++-- > =C2=A0fs/hfsplus/bnode.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 7 ++++--- > =C2=A0fs/hfsplus/brec.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 12 ++++++++= ---- > =C2=A0fs/hfsplus/hfsplus_fs.h | 11 +++++++---- > =C2=A04 files changed, 28 insertions(+), 13 deletions(-) >=20 > diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c > index ca9813f58a..657f22df1a 100644 > --- a/fs/hfsplus/bfind.c > +++ b/fs/hfsplus/bfind.c > @@ -14,16 +14,23 @@ > =C2=A0 > =C2=A0int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd) > =C2=A0{ > + const size_t key_len_size =3D sizeof_field(hfsplus_btree_key, > key_len); > =C2=A0 void *ptr; > =C2=A0 > =C2=A0 fd->tree =3D tree; > =C2=A0 fd->bnode =3D NULL; > =C2=A0 hfs_find_result_init(fd); > - ptr =3D kzalloc(tree->max_key_len * 2 + 4, GFP_KERNEL); > + /* > + * max_key_len does not count the key_len field at the start > of > + * every key, so each key buffer needs max_key_len + > key_len_size > + * bytes. search_key and key share one allocation of two > buffers. > + */ > + fd->key_capacity =3D tree->max_key_len + key_len_size; > + ptr =3D kzalloc(fd->key_capacity * 2, GFP_KERNEL); > =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 mutex_lock_nested(&tree->tree_lock, > diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c > index 3a1a1fa6f2..144348bdbf 100644 > --- a/fs/hfsplus/bnode.c > +++ b/fs/hfsplus/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) I think we need a follow-up patch. Because, hfs_bnode_read_key() still returns void. On a bad length it zeroes the key and the callers continue: hfs_brec_update_parent() and __hfs_brec_find() run with an all-zero key. That can write a bogus index key into the parent node. > =C2=A0{ > =C2=A0 struct hfs_btree *tree; > =C2=A0 u32 key_len; > @@ -84,8 +85,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 + 2; > =C2=A0 > - if (key_len > sizeof(hfsplus_btree_key) || key_len < 1) { > - memset(key, 0, sizeof(hfsplus_btree_key)); > + if (key_len > key_capacity || key_len < 1) { I am still not sure that we should use key_len < 1. Something else should be here. > + memset(key, 0, key_capacity); > =C2=A0 pr_err("hfsplus: Invalid key length: %u\n", > key_len); > =C2=A0 return; > =C2=A0 } > diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c > index f416e562d4..c9fb6873ac 100644 > --- a/fs/hfsplus/brec.c > +++ b/fs/hfsplus/brec.c > @@ -148,7 +148,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 > @@ -166,7 +167,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, hfs_find_rec_by_key); > =C2=A0 > =C2=A0 hfs_bnode_put(new_node); > @@ -464,7 +466,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, hfs_find_rec_by_key); > @@ -476,7 +479,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/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h > index dd8f717943..3d33f2df0b 100644 > --- a/fs/hfsplus/hfsplus_fs.h > +++ b/fs/hfsplus/hfsplus_fs.h > @@ -286,13 +286,15 @@ static inline void > hfsplus_mark_inode_dirty(struct inode *inode, > =C2=A0} > =C2=A0 > =C2=A0struct hfs_find_data { > - /* filled by caller */ > + /* set by hfs_find_init() */ > =C2=A0 hfsplus_btree_key *search_key; > =C2=A0 hfsplus_btree_key *key; > - /* filled by find */ > =C2=A0 struct hfs_btree *tree; > + /* filled by find */ > =C2=A0 struct hfs_bnode *bnode; > - /* filled by findrec */ > + /* set by hfs_find_init(): size of each of search_key and > key */ > + u32 key_capacity; > + /* filled by findrec, reset by hfs_find_result_init() */ > =C2=A0 int record; > =C2=A0 int keyoffset, keylength; > =C2=A0 int entryoffset, entrylength; > @@ -403,7 +405,8 @@ void hfs_bmap_free(struct hfs_bnode *node); > =C2=A0void hfs_bnode_read(struct hfs_bnode *node, void *buf, u32 off, u32 > len); > =C2=A0u16 hfs_bnode_read_u16(struct hfs_bnode *node, u32 off); > =C2=A0u8 hfs_bnode_read_u8(struct hfs_bnode *node, u32 off); > -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=A0void hfs_bnode_write(struct hfs_bnode *node, void *buf, u32 off, u3= 2 > len); > =C2=A0void hfs_bnode_write_u16(struct hfs_bnode *node, u32 off, u16 data)= ; > =C2=A0void hfs_bnode_clear(struct hfs_bnode *node, u32 off, u32 len); Mostly, patch looks good. I need to run xfstests on patchset. Thanks, Slava.