From nobody Tue Nov 17 19:51:52 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jTb3D51Tzz71ldD for ; Tue, 17 Nov 2026 19:51:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTb3D41v8z3G3f for ; Tue, 17 Nov 2026 19:51:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794945112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Upa1IMinE4XeXiqEuy5Q/6L/xF4/ndq44OydB1nG/0w=; b=NLm2MDHywHsJ2ilPEygsiJSBEY+Ctk5CRfdbZMjXELI53+7uKCrBwUQMzxPmltegBx0rF4 Z1/MmM3QWFO/ErjbRdSoM33NeZQspjOBRTgwA2kXU4SVdTf2dMNpgdA2WwH2HDYV5NbKJ7 7TCm+3Bk8ubdKtHtCxARSMqu23PEBHZrraEo0ivnF5/e+cGb/G7PeauOI0XLBCVQfi7KjY jEbikO8Y0SaayvIDpYj+qu3sd70BWJ7hb3dVXsOutICh4WoIJN+eqtHgonhJ6wsK8IV5AF Yg2KOKU/SupMMFI22xqBVdAuhF883OwOaPrcPe75n/Xbl4PWvEFewQhP85P6Gg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794945112; b=DBwIefiV5NvoLt/M40T+ceoPvTGeWQszISlRHB8QzKTo+pwn/ksNZtYcLhqpmFrJZqufOz 0KPPtSy41W9BqTD2X/72Ork17z/c7gkuyE7NYYAa++bybvTUXOV7KoyTq5BWWiQtehu/H5 CtSgr3k733lDgUoQBFnIG9Lo9BWCZb9Vjqy54gyKWSkSAXZahyMnWi9l966PUEQh4B0xMW Wk3jL49hlYjZV7aIs8IAZly0e9POIj8r7CJMcfdaTlTX6dXV2835G8ZHbEJ3YtycC2PzrR +3G1eotWd0cstYfJnxsfOVrEqilcccCY5Rf94gXyH+3+AVVsefy/oQalN0unxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794945112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Upa1IMinE4XeXiqEuy5Q/6L/xF4/ndq44OydB1nG/0w=; b=wtwrdIKz8jsR6CMMaVt2WLEhIhT+PYxpHTz0t86Rab0g2posdSgy0sLEOxsbFp9vX11WOP 4ylwtPsH36KaZzmm6A40/CtQz9r0PvIYlT4ggarKYWe1tEYH7k2A6w3Q1cTW9mO5WbGbgM eAMdX0fg9LHbMKcZ2cM2OwgiBvDWnZgrJi44667F37wZsLdx2kou2I1hNzZQlgtPlVP/Fy UgbvtrTwWID8Pi6cpZ85jdn3CYRKAZKqwIDwYvWn9tklq7Ty++4W17+gTlvFL4I7ibWL0Q 84o9/WsENWc0y/PvlmCqYig5glAhOIU9viwznlgeyBWjO9/zwsrK85srasZPeQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTb3D3Nk3zxGJ for ; Tue, 17 Nov 2026 19:51:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1248d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 19:51:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Nick Price From: Colin Percival Subject: git: 66e24d44effd - releng/15.2 - linux: do not truncate the listxattr() size List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository 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: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.2 X-Git-Reftype: branch X-Git-Commit: 66e24d44effdd9745e0becd4c3280b6b57bab7ee Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 19:51:52 +0000 Message-Id: <6afcb058.1248d.6bdbae68@gitrepo.freebsd.org> The branch releng/15.2 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=66e24d44effdd9745e0becd4c3280b6b57bab7ee commit 66e24d44effdd9745e0becd4c3280b6b57bab7ee Author: Nick Price AuthorDate: 2026-11-08 01:32:08 +0000 Commit: Colin Percival CommitDate: 2026-11-17 19:50:32 +0000 linux: do not truncate the listxattr() size listxattr() sized its buffer with min(), which truncates the 64-bit size to 32 bits, so a size of 2^32 + k allocated k bytes while the copy-out guard used the full size. The walk then read record lengths past the buffer and copied kernel heap out to the caller, and could panic the kernel. Any user can reach it through a user.* attribute on a file it owns. Use MIN(), and fail with EIO if a record runs past the data returned. Approved by: re (cperciva) Reviewed by: adrian, markj Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D61006 Signed-off-by: Nick Price (cherry picked from commit fbe4835e6b1eec36103a5ce97efbab11b3b5fc72) (cherry picked from commit a46d6ae4c0b6f6e8eb74b13da6f607d2ead74be7) --- sys/compat/linux/linux_xattr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_xattr.c b/sys/compat/linux/linux_xattr.c index 2eec33f8ef93..267cadedb986 100644 --- a/sys/compat/linux/linux_xattr.c +++ b/sys/compat/linux/linux_xattr.c @@ -139,7 +139,7 @@ listxattr(struct thread *td, struct listxattr_args *args) int attrnamespace, error; if (args->size != 0) - sz = min(LINUX_XATTR_LIST_MAX, args->size); + sz = MIN(LINUX_XATTR_LIST_MAX, args->size); else sz = LINUX_XATTR_LIST_MAX; @@ -189,6 +189,13 @@ listxattr(struct thread *td, struct listxattr_args *args) error = ERANGE; break; } + KASSERT(keylen + 1 <= rs, + ("%s: truncated record", __func__)); + if (keylen + 1 > rs) { + printf("%s: truncated record\n", __func__); + error = EIO; + goto out; + } ++key; if (args->list != NULL && args->size > 0) { sprintf(attrname, "%s.%.*s", prefix, keylen, key); @@ -201,6 +208,7 @@ listxattr(struct thread *td, struct listxattr_args *args) rs -= (keylen + 1); } } +out: if (error == 0) td->td_retval[0] = cnt; free(data, M_LINUX);