From nobody Sun Nov 08 01:32:14 2026 X-Original-To: dev-commits-src-main@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 4jMb4Z2hlqz6yHTF for ; Sun, 08 Nov 2026 01:32:14 +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 4jMb4Z1qBBz4qRP for ; Sun, 08 Nov 2026 01:32:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794101534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Z7fesSYzOna1vHKnoJDaIjqy10FPi/WLQxIk8rOBwCM=; b=esDjFR+cPuGtIDLwARJB+HqUp+1jbksETeCKH2DfBuvPGJHuCLh2nSLfRVGfwaLoW8aTup P3/gIp9ilsko0L0e9KIpzb5bdTuxD5tHENhu4tQWS1kq4dyHNgPhZMmFz/5ru59TdAK6Gq Z60Zh4e6yri01xN9/utyagOgiBWWPhhfudHb1cOULzLZ3XFt17Fb+lyafqkm/LSxchkXIt uEplWsnSpWeNYfUA+xJCLWy4Alm3jaJfVuYozap6pC0kEurz8gD+QRjVEom9QXxg49MnII R02Xz78aBsEq6Ftaiz0lk0B5YAyHUHITVSHBYnge7nTBQj/rFoepK70fZLab6g== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794101534; b=qC6vcmJ0MIQfJPD5hxZq7dND+gm4EcKJyWYhk1vxAt4bjebccdC7v1aR7TsWMZMdz91+93 Ykt3SmKhCo4KCeet7XdCFzyXmuQPO/EykRKcRSrKYLWhs8GxozaKSY2pBDqholspW2VFAx 8Ksz4iSGwJhurt5WTuWFdPaXsxQoJtL9sJ8B9GRiVPA+V95sYtUvhWKa0QETSrCkIIDu3n xg0XpWWbflw+jCHU2CnItWm1U91lBe5bDKB1/EPo7ER+EAYlbQK8/0p9B33maO6evq3Qbf M30HDGrNFE4tmP/3jepNo6LxXt1w5jzR7Sa0goR2MtnpPUsVj2A14vjOy113NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794101534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Z7fesSYzOna1vHKnoJDaIjqy10FPi/WLQxIk8rOBwCM=; b=eUSJbBObsV147JMAYHZYYuT24Q58a9b4CI1CnyK4C1IZqPeV3Zzklclwg76aVEsKDdSRkn qUi9VPOsTdBQjRTdraygwTDa2462BLlzYJBkrM2uLJZiohQdeqp8RKY/ZfNvSE3Ua5THFm JbO++bWuUqjLb5wyeqNoc95GnXk4eLsCsFmPocXzVnGpgQ5qvuRDHe0FqUpD3xnAVED8tv WUzjBlcoZxhf4+s4SvZJ1iPMzBDphstiUSETK+c/gJgdYfcEsOUS/xA9Z+SMmDOtYz/xUD VOYhKQBnCxfeultYSZZM6cuSOzgKw1Kpaw3IvO82UCerl62gGWmD95kmk8xYpw== 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 4jMb4Z1B2GznGX for ; Sun, 08 Nov 2026 01:32:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 48eaf by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 08 Nov 2026 01:32:14 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Nick Price Subject: git: fbe4835e6b1e - main - linux: do not truncate the listxattr() size List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch 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: nprice X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fbe4835e6b1eec36103a5ce97efbab11b3b5fc72 Auto-Submitted: auto-generated Date: Sun, 08 Nov 2026 01:32:14 +0000 Message-Id: <6aefd11e.48eaf.266e7980@gitrepo.freebsd.org> The branch main has been updated by nprice: URL: https://cgit.FreeBSD.org/src/commit/?id=fbe4835e6b1eec36103a5ce97efbab11b3b5fc72 commit fbe4835e6b1eec36103a5ce97efbab11b3b5fc72 Author: Nick Price AuthorDate: 2026-11-08 01:32:08 +0000 Commit: Nick Price CommitDate: 2026-11-08 01:32:08 +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. Reviewed by: adrian, markj Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D61006 Signed-off-by: Nick Price --- 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 9a206089ada1..6bba5346c748 100644 --- a/sys/compat/linux/linux_xattr.c +++ b/sys/compat/linux/linux_xattr.c @@ -153,7 +153,7 @@ listxattr(struct thread *td, struct listxattr_args *args) } 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; @@ -203,6 +203,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); @@ -215,6 +222,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);