From nobody Mon Sep 11 12:00:18 2023 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 4Rkldt5q9rz4sts9; Mon, 11 Sep 2023 12:00:18 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rkldt4zRhz3Qdc; Mon, 11 Sep 2023 12:00:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694433618; 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=dLcb5dnF0MTQjG353yQcUDHgUvm8Nx9pdNFbUSWTlPY=; b=PF6Vngr2nVrNTKQ4PXILd5xNsAkJ0q3y/1R5RYVL/MeFtH57X0VfQMWsuv5AhvxAZlKzcY txHYjFYtnIK9CdBujEJxlM/V2qBmKmFOl5hqtrnZjKa4HcjcMpO8ySVV0ZpMYTsg5/xFEz EJWO6kLhFOZ5jyCq5woPFzQMdvz+KASysaGuKpY/Q6vobv6SMt/4wE40NVSQqXlok/glg2 tDc9nlr7TjNoVD0K6cisrDZdzKGVD32XU1dUDJx3+QWG7ziPNsHwu4JlKRs6oPTTJ9nHdF 5d+Az4FZilyqRTnKPGd9wzbcfW/DBbP9MQEYhLPjLp3wq9BuCbqogKe0S5k42Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694433618; a=rsa-sha256; cv=none; b=b6gsIQm3mgBWylw2q4ez6HZt2wm9G01GkEw1UZ2EkccJs85D5i0ejjHHn7akDgv8SIDcvF R4Eu3RCV1DCJhgS47WhBm7SvOi1kuGLMavzXdggiH+Nx5msj7VAlgaolNBsujr57rW4Sm2 FKr62OxiNZ28aXXrO6lzISlRrBaDFkUtdi+96u2/xbM+QrmMC8QxXX7uWH1oMOA6U1JuZg ZzsvU71RiomHyhlFtMVF8F2Qg8jXLHPD+8SL2PiF7tbgbIjrNStvrYN1V5kK8ZeuVUvXkZ qJ0hKo3GP4W/HxHLxceVENlAJtH5v04J1ulUUNJhHZQxkZqRpVihMtkYVQJODw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694433618; 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=dLcb5dnF0MTQjG353yQcUDHgUvm8Nx9pdNFbUSWTlPY=; b=G5TFE80ldjHtVb+UZNrOYw9/76PjongXwwjl7V6uvvQz5gDN4wc1dpcpm86bfOgBIlFIYi VvRoHz5qxHTVaTTzDJLxJJjxltzMWOZxAxnUpdJRin9RfOcHDKTNR5Je4iePXFVf4x5nQq 5QufqhkjQ5+gJkNEsDfYb1148whBFrvIf8kvOUhzoXfE+zv4Wpz7wigpao56/FUNOGrSk/ qgi3uTY+pGcqtXjbJSZ3VrHpwekMAVsTM0V1tJn/OpUkIDKssrhXCfnvvfKkUoy+S3EcQf e99fP5xDuih2O55SLYTKEKnvakY51KpxBljAyBtqmSJYL2tDR4Hg90n5RJb5Qw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rkldt3xZCznpJ; Mon, 11 Sep 2023 12:00:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38BC0IuS001505; Mon, 11 Sep 2023 12:00:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38BC0I86001502; Mon, 11 Sep 2023 12:00:18 GMT (envelope-from git) Date: Mon, 11 Sep 2023 12:00:18 GMT Message-Id: <202309111200.38BC0I86001502@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: 53b3e15d732f - stable/14 - linux(4): Fix listxattr for the case when the size is 0 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 53b3e15d732ff6ff0df7870107d45a371a376e73 Auto-Submitted: auto-generated The branch stable/14 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=53b3e15d732ff6ff0df7870107d45a371a376e73 commit 53b3e15d732ff6ff0df7870107d45a371a376e73 Author: Dmitry Chagin AuthorDate: 2023-09-05 08:51:46 +0000 Commit: Dmitry Chagin CommitDate: 2023-09-11 11:59:38 +0000 linux(4): Fix listxattr for the case when the size is 0 If size is specified as zero, these calls return the current size of the list of extended attribute names (and leave list unchanged). Tested by: zirias MFC after: 1 week (cherry picked from commit 18d1c86788f66f42c4e096142f4f8d168f68732c) --- sys/compat/linux/linux_xattr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/compat/linux/linux_xattr.c b/sys/compat/linux/linux_xattr.c index 74b47f1cbaec..71d7ae58439e 100644 --- a/sys/compat/linux/linux_xattr.c +++ b/sys/compat/linux/linux_xattr.c @@ -173,24 +173,28 @@ listxattr(struct thread *td, struct listxattr_args *args) while (rs > 0) { keylen = (unsigned char)key[0]; pairlen = prefixlen + 1 + keylen + 1; - if (cnt + pairlen > LINUX_XATTR_LIST_MAX) { + cnt += pairlen; + if (cnt > LINUX_XATTR_LIST_MAX) { error = E2BIG; break; } - if ((args->list != NULL && cnt > args->size) || + /* + * If size is specified as zero, return the current size + * of the list of extended attribute names. + */ + if ((args->size > 0 && cnt > args->size) || pairlen >= sizeof(attrname)) { error = ERANGE; break; } ++key; - if (args->list != NULL) { + if (args->list != NULL && args->size > 0) { sprintf(attrname, "%s.%.*s", prefix, keylen, key); error = copyout(attrname, args->list, pairlen); if (error != 0) break; args->list += pairlen; } - cnt += pairlen; key += keylen; rs -= (keylen + 1); }