From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796426163; b=iCg6RZMPjXSH8karb4J08eFVbM5JbdB3uaeggXmtGyBHW6hJbkgluOi3AbpTfk/SLevC Y9XEQcZeM+0OOWVf3+XXWXM8/BplaYupn2wflgZcDHNWzk2AkntKTiags8lbySVDca8uI EEYCUcHfYT1/nnCP8Er7aP/vwqH5qoBWzTQ076kbzM94eAE3glVa9BXvhA45tkYeN4FTD e4ANswu8PoN9q3J2x+99YH3MGZPhfAM0YYS8iWPaagZbMH7Ye0iquitcd7LfEkwckfPJz I8mKbgUo+tpDtehz33zImtPg9/Kv+ifZUyLJn1IKqnS6wqz/oMqqu0vmnmgYBQ8fFcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796426163; 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=FjZhK/4zuq7esVpuzHWkjEf8eaTs30EmlrQ2APGF5X8=; b=W8GK+McbPavlTrAEF7iP+7s9FuKPbMGZP/gz6QAsbiSF0b3/WWuWRoOiMDvuLGvLiCQO Barwt+mp9YUeDTh0x5fjlMvxSPAt+Bwmd7a4tVsOzBLSUzQTkPOzBXf8LzcOnpIjV1F0l iNovZBFxaMlITrMjpGdLyi335oNAGh332Z86RrAf8rX/trUzg/z4AX0dZMqE9PipnaUUf LonvDVQAJq67BJYQP8GvUr3NJLPuiJTVdxjKAaB9A4f+jRmxpc43Jlb+gyI0SYEqvFEGM uGJazz26l3ayaSGToB9mPyWlIi+kmM8sf1rmhKpv6YJ374JnzDiICTH5gAqlf2D5yLw== 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=bIpnynhh; arc=none smtp.remote-ip=209.85.128.170 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (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 1FFBF606A32C for ; Fri, 4 Dec 2026 23:16:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1FFBF606A32C 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=bIpnynhh Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-8b3402105b9so10728487b3.0 for ; Fri, 04 Dec 2026 15:16:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20260707.gappssmtp.com; s=20260707; t=1796426161; x=1797030961; 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=FjZhK/4zuq7esVpuzHWkjEf8eaTs30EmlrQ2APGF5X8=; b=bIpnynhhJq6nsiZcr+TmcHhZ9km7YTz5FNAi0gm6SnA1d+D0++dvwV5VqbGpFXBfaJ HF0u/3eVYNKheYAJqsuvdL5bi8F1wP05lVbLA2N7sLry+63XJ3t4c2q4R8s9M7BQBiaH 7rbrwSNYuOeJbg55YBQKoG0Xb5I1lRPIbZAjfK1vBKe98SZr2RBBqF6BTMboD1hr/n// aX/lV601S8nBuj6/1LLbwcdznMZICnRT1J8obGYSBR96y60gJFgKd138oKn6OgDI6kKA Gj3gWBqQAUVhod+PKR/jOIYOZJIcAwigvZd2uG8ABso3thQUYUvET7FVIMpeSqk1RJ/F s6UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796426161; x=1797030961; 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=FjZhK/4zuq7esVpuzHWkjEf8eaTs30EmlrQ2APGF5X8=; b=g98hqcdUQPQlsW3LNUI2mP0DXjLQbWOu910u/ALWpYHYdwHeI5YKJOvParWg1DB1mb z47ko+xDhdWZm1QfhmTtooSX4/Lp7U42LqB3dKizMUr+9W0O5V7t3UMSbw0A0RudCo3O DXPcu9Bx2isg/GBdpVximMIDqFA5ElWqgTN6paDBs8dTwBY0rCx9u0VAJHu/xowTvnwv DO1YPFsj3xvXA9Z9gzE/+G8sog3+Qf75WKYyfuBmH7dbBGLa7qOdSsQFyzlkrodXQRJK ZQibJAkYDAOBnPmGOB7Xacj03hLHfw+qbZIHSMA5qXPZxLcvPg7bdrLPnzFS3JeCsScG 4mZw== X-Forwarded-Encrypted: i=1; AL+hErHafK8CIrSaO+6r9EMrDvyp94mJ1DmJDzmWC91yytJnLiOJO4AI9zPy6Isa4KqXoCvM86TGmixdmKQEbBU=@vger.kernel.org X-Gm-Message-State: AB4q+uF4qqKdh+2ctPCIJGR2RYvlSGMBg3NzDiB4dz4Fae/rSCDi3CZ9 vbXzEMOMjgiSPneXs1+BYXcxWAQJJQExGzmCaWpYxngr3E8OZbZKiPqdxMaFoCx/GC0W/JGBELp 3jxuh5Rg= X-Gm-Gg: AZFdTZcrcOLyYq5TznqBfltSQH2kcuIBHnFO9zRxmbXXlby2ZnmDed3wtSW2Sb/ODRh HScWKJOdF4h7yQtWANZ7iYvyzfwFHEZ+dS/BAjBGy1ewxtam7ZErVRVdzBOKU0ld58L1htU0ck4 /6LVsb2nYZr9TSYs/TasDW7ecuC5fjrYHnnu9QG3OIiiA30glv6pq/yz8Fs5jXp6cKZF8UD32cE xL56CXqfNGsOa7iBygzWOA/J7cGABsERTsh/4E0lWzL5Vm1XOcrA6PGH32DwyqNFHVnv+U8Agtf wKxCb0pv9dcb7q8FsQM41ZeY9OEUJdb7kfVw+qKQZ5xSZvwVKLcrPyjupt7mPIjiAabgEAskITn lkhScP7ZdZ3Wgloy1dmiRr/lBxHRafNSKulzdMYD0zcm7j0hAq2c1yNo1NjSwKMWvvCXf6aEJh0 ubyBdeV5ueMJWifHtH98RRHwUsTBgj131yaHNBzckvBLKF6ChITMkx3AKBZAuGF5Z4iAqISoVMf MZOWT2aLAi4rE7GvpUxwT0jYNTCbe6CUNF92XwS+aHODxXqCP2MHMZKp2/SQb4Wq7RsM5d7ihoR Hb1F45k5gj1KYh1EeNJJbjbnpgx93trTtHK09zOrJM/OqacflIKvGXuM62hTFOrQbrrnhVIEWvQ GYUPPLq0Yi7yDC4S28J6rsN88LVuS5P8Bbthk1os7mXXmPNkYZVsgdS5G0mcMpUpKh7T7c/Nlum ks/MiOiqI7Tps1So/KVvY= X-Received: by 2002:a05:690c:3608:b0:8b0:6617:e282 with SMTP id 00721157ae682-8b659da7d51mr16002637b3.12.1796426160887; Fri, 04 Dec 2026 15:16:00 -0800 (PST) Received: from ?IPv6:2600:1700:6476:1430:d9f4:eaa9:479c:5d66? ([2600:1700:6476:1430:d9f4:eaa9:479c:5d66]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b660df72e0sm15673017b3.38.2026.12.04.15.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 15:16:00 -0800 (PST) Message-ID: <2f67d1c3f7fa60161366a4d52cdd6b3eca9a90d8.camel@dubeyko.com> Subject: Re: [PATCH v2] hfsplus: validate attribute key name length on every read path From: Viacheslav Dubeyko To: Kyuwon Cho , John Paul Adrian Glaubitz , Yangtao Li Cc: Ozgun Kultekin , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 04 Dec 2026 15:15:59 -0800 In-Reply-To: <179636379461.1106205.12507366887678809732@skku.edu> References: <179636379461.1106205.12507366887678809732@skku.edu> 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 15:34 +0900, Kyuwon Cho wrote: > Attribute keys carry an outer key length and an embedded Unicode name > length. hfsplus_attr_bin_cmp_key() trusts the embedded length, so an > inconsistent key can make it read beyond the key buffer. >=20 > Validate the lengths in a common helper used by hfs_brec_keylen() and > hfs_bnode_read_key(). The latter covers keys copied while inserting a > record, updating a parent, or splitting a node. Check that the record > is > large enough before reading the embedded length, and include the node > and > record numbers in corruption messages. Thanks a lot for the v2. It addresses all my comments on v1. However, I still have one important concern and a few minor comments. >=20 > Fixes: 3e05ca20fb57 ("hfsplus: add functionality of manipulating by > records in attributes tree") > Suggested-by: Viacheslav Dubeyko > Signed-off-by: Kyuwon Cho > --- > Changes in v2: > - Move attribute-key validation into a helper used by both > =C2=A0 hfs_brec_keylen() and hfs_bnode_read_key(), covering insert, paren= t > =C2=A0 update, and node-split key copies, as requested by Viacheslav > Dubeyko. > - Reject short records before reading the embedded name length, > return > =C2=A0 immediately after an oversized outer key, and report the name > length, > =C2=A0 key length, node ID, and record index. > - Rebase on Ozgun Kultekin's v5 key-buffer-size series. >=20 > v1: > https://lore.kernel.org/all/179619831256.1663618.16544869010167759924@skk= u.edu/ > Base series: > https://lore.kernel.org/all/20261201094246.80197-1-ozgunkultekin@gmail.co= m/ >=20 > The issue was found by an LLM-guided test generator that we are > developing as a research prototype. >=20 > Tested with setxattr-driven attribute-tree node splits on a valid > HFS+ > volume; the attributes remain readable after remount. Could you please confirm that the v1 reproducer (hfsplus_brec_remove() path) doesn't trigger the KASAN report with v2 applied? And did you check the split path with a corrupted key (when the invalid key ends up as the first record of the node)? >=20 > The reproducer is attached to my reply in the v1 thread. >=20 > =C2=A0fs/hfsplus/bnode.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 12 +++++++++++- > =C2=A0fs/hfsplus/brec.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 43 ++++++++= ++++++++++++++++++++++++++----- > -- > =C2=A0fs/hfsplus/hfsplus_fs.h |=C2=A0 4 +++- > =C2=A03 files changed, 50 insertions(+), 9 deletions(-) >=20 > diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c > index d91714e97b9b..97e570b10853 100644 > --- a/fs/hfsplus/bnode.c > +++ b/fs/hfsplus/bnode.c > @@ -71,7 +71,7 @@ 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, > u16 rec, > =C2=A0 u32 key_capacity) > =C2=A0{ > =C2=A0 struct hfs_btree *tree; > @@ -90,6 +90,16 @@ void hfs_bnode_read_key(struct hfs_bnode *node, > void *key, u32 off, > =C2=A0 pr_err("hfsplus: Invalid key length: %u\n", > key_len); > =C2=A0 return; > =C2=A0 } > + if (tree->cnid =3D=3D HFSPLUS_ATTR_CNID) { > + u16 rec_off; > + u16 rec_len =3D hfs_brec_lenoff(node, rec, &rec_off); > + > + if (hfs_brec_len_invalid(node, rec_len) || rec_off > !=3D off || > + =C2=A0=C2=A0=C2=A0 !hfsplus_attr_key_valid(node, rec, off, key_len, > rec_len)) { > + memset(key, 0, key_capacity); > + return; > + } > + } The main problem is that hfs_bnode_read_key() is still a void function. If the key is invalid, then we zero the key and the caller simply continues with it. For example, after a node split, hfs_brec_insert() calls __hfs_brec_find() for the parent node with zeroed search key and inserts an index record with this zeroed key. And hfs_brec_update_parent() will search for the parent's index record by means of zeroed key. So, we avoid the out-of-bounds read, but we convert the detected corruption into new corruption of the b-tree, and the operation reports success. I think hfs_bnode_read_key() should return an error (-EIO) for an invalid key, and hfs_brec_insert() and hfs_brec_update_parent() should propagate it. Also, the case of invalid record length or rec_off !=3D off is completely silent here. The rec_off !=3D off case can happen only if the caller passes a wrong record index, which is a kernel bug rather than volume corruption. So, I think WARN_ON_ONCE() is more appropriate for it. Moreover, both off and rec are provided to the function, but they carry the same information. Every caller knows the record index, so the function could take only rec and retrieve the offset by hfs_brec_lenoff(). Then, we don't need to check the consistency of off and rec at all. > =C2=A0 > =C2=A0 hfs_bnode_read(node, key, off, key_len); > =C2=A0} > diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c > index c56ca7a852b1..babbd51a9db6 100644 > --- a/fs/hfsplus/brec.c > +++ b/fs/hfsplus/brec.c > @@ -18,6 +18,34 @@ static struct hfs_bnode *hfs_bnode_split(struct > hfs_find_data *fd); > =C2=A0static int hfs_brec_update_parent(struct hfs_find_data *fd); > =C2=A0static int hfs_btree_inc_height(struct hfs_btree *); > =C2=A0 > +bool hfsplus_attr_key_valid(struct hfs_bnode *node, u16 rec, u32 > key_off, > + =C2=A0=C2=A0=C2=A0 u16 key_len, u16 rec_len) > +{ > + const u16 min_key_len =3D > + offsetof(struct hfsplus_attr_key, key_name.unicode); > + u16 name_len; > + > + if (node->tree->cnid !=3D HFSPLUS_ATTR_CNID) > + return true; hfs_bnode_read_key() already checks the tree ID before calling the helper. Could we keep only one of these checks? Thanks, Slava. > + > + if (rec_len < min_key_len) { > + pr_err("hfsplus: attribute record length %u is too > short for key length %u in node %u record %u\n", > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rec_len, key_len, node->this, rec= ); > + return false; > + } > + > + name_len =3D hfs_bnode_read_u16(node, key_off + > + offsetof(struct hfsplus_attr_key, > key_name.length)); > + if (name_len > HFSPLUS_ATTR_MAX_STRLEN || key_len > rec_len > || > + =C2=A0=C2=A0=C2=A0 key_len !=3D min_key_len + 2 * name_len) { > + pr_err("hfsplus: invalid attribute name length %u > for key length %u in node %u record %u\n", > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 name_len, key_len, node->this, re= c); > + return false; > + } > + > + return true; > +} > + > =C2=A0/* Get the length and offset of the given record in the given node > */ > =C2=A0u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off) > =C2=A0{ > @@ -62,10 +90,11 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 > rec) > =C2=A0 > =C2=A0 retval =3D hfs_bnode_read_u16(node, recoff) + 2; > =C2=A0 if (retval > node->tree->max_key_len + 2) { > - pr_err("keylen %d too large\n", > - retval); > - retval =3D U16_MAX; > + pr_err("keylen %d too large\n", retval); > + return U16_MAX; > =C2=A0 } > + if (!hfsplus_attr_key_valid(node, rec, recoff, > retval, len)) > + return U16_MAX; > =C2=A0 } > =C2=A0 return retval; > =C2=A0} > @@ -148,7 +177,7 @@ 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, 1, > =C2=A0 =C2=A0=C2=A0 fd->key_capacity); > =C2=A0 hfs_brec_update_parent(fd); > =C2=A0 } > @@ -168,7 +197,7 @@ int hfs_brec_insert(struct hfs_find_data *fd, > void *entry, u32 entry_len) > =C2=A0 > =C2=A0 /* get index key */ > =C2=A0 hfs_bnode_read_key(new_node, fd->search_key, > - =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, fd- > >key_capacity); > + =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, 0, 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); > @@ -468,7 +497,7 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 fd->bnode =3D hfs_bnode_find(tree, new_node->parent); > =C2=A0 /* create index key and entry */ > =C2=A0 hfs_bnode_read_key(new_node, fd->search_key, > - =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, fd- > >key_capacity); > + =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, 0, 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); > @@ -481,7 +510,7 @@ static int hfs_brec_update_parent(struct > hfs_find_data *fd) > =C2=A0 goto out; > =C2=A0 /* restore search_key */ > =C2=A0 hfs_bnode_read_key(node, fd->search_key, > - =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, > + =C2=A0=C2=A0 HFS_BNODE_FIRST_REC_OFF, > 0, > =C2=A0 =C2=A0=C2=A0 fd->key_capacity); > =C2=A0 } > =C2=A0 new_node =3D NULL; > diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h > index 43062f056f8c..963c664172ca 100644 > --- a/fs/hfsplus/hfsplus_fs.h > +++ b/fs/hfsplus/hfsplus_fs.h > @@ -405,7 +405,7 @@ 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, > u16 rec, > =C2=A0 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)= ; > @@ -427,6 +427,8 @@ bool hfs_bnode_need_zeroout(struct hfs_btree > *tree); > =C2=A0/* brec.c */ > =C2=A0u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off); > =C2=A0u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec); > +bool hfsplus_attr_key_valid(struct hfs_bnode *node, u16 rec, u32 > key_off, > + =C2=A0=C2=A0=C2=A0 u16 key_len, u16 rec_len); > =C2=A0int hfs_brec_insert(struct hfs_find_data *fd, void *entry, u32 > entry_len); > =C2=A0int hfs_brec_remove(struct hfs_find_data *fd); > =C2=A0