From nobody Mon Jul 6 19:35:40 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 4gvF2V0T57z6kYjS for ; Mon, 06 Jul 2026 19:35:46 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gvF2T6sk7z3lTJ for ; Mon, 06 Jul 2026 19:35:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783366546; 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=LG4bWYo5Elv29alpUSzJp8zA8izMhBhwlEwImmTjr/A=; b=QUpGDcD7F5enXmirO9B/fcbJxU2xq4TtN5MGCVtk01HLtQlThvrYU0Cakw4+nYDYywOnEp Lmkf27EF4eQkIvQNvVOnz5g39nYL/noguAG0hHpRJI8AHa7oc1YxZ4oAmCuLQkuieTREiy m8cKvNG5sScRCC0v3YPJMar+kzCLwa7gqs/dSjbEJlKACdKC9MZAHgrDSjCb4I8rwi3ewJ 2gVa60Z7eomSeFFFqQZyfjz9Jq62cY+UyQ2Tgsr1m4FrOEAINd11TqhIAFP+QYzE7kh/8Q Fa4XE1KFN2b9Qd15Z/0CjZ79a/5c+ArmDZKT2g5Rej5vjcbaztesRY0zcQ0moA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783366546; a=rsa-sha256; cv=none; b=LnOBqWEG1ujJGg5W/OCdqF9AOAycuAOLSNUNzg7LmNjm7CT1mf7Hz9tHjodIPO8tHkCS3d uGwYkgOwLtgZUK0HHKgnomZrrNtoecg75CPCY5Crv2suzbAv76AkqIYvvvj/gQDbKnz4ui KIzLPVSTziAb1RD1SNHCGNgIxKdGbjw01095jc4Uj6rDzLCyOT/6+WoTTjIiVeXQux9Mlt PUnU8L5KIlHyNCoI87XUdN3Pz4IfqM21D+QH8aPYj+OlPBBeMqaGyHpveMgJjjZ7BqmAp4 1IZh65V2K628ibITE1VaP27z7Fwdy8ZR/vPqmPIVnpIotRaB9n8M327dh3C42w== 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=1783366546; 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=LG4bWYo5Elv29alpUSzJp8zA8izMhBhwlEwImmTjr/A=; b=cVNUWwCNn7AMS8rwAqtIA14RfE74Oa11tpHRyxVGkDZkh0dlqNIgJzxoTKxZgD8UBZzNGb s8FV/xfgGua3x/FK+hOTCkUXFtUVC6wtUrCBM+zOFNKcb5CaFbDlWmxOJFym9rQj30VF6r 1YRppn30XARlY65+Crf/viFYHQcG0TPl7VsT/aY6I5ptF3d0Lef8oiocpQxmcw+CrZ1JxL 2L/fDRrPQdtrgnirdB4Dw0Se0ZfIRYSCQyZTOscV71PbQ2ApYVy4hFO4ha2deMCN4EzJyT I9JhOw2+8BGGeGgYVcI8lsTjDyaKGiWROw6gNUyuEUNlNX+UGPH98uLNbT8L3Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gvF2T5Tnjz1HMl for ; Mon, 06 Jul 2026 19:35:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 40202 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 06 Jul 2026 19:35:40 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Peter Eriksson From: Rick Macklem Subject: git: d7d71341ae7d - main - acl_from_text.c: Allow negative uid/gid numbers to be handled 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: 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: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d7d71341ae7d79886143a9ce427dca0e858eda97 Auto-Submitted: auto-generated Date: Mon, 06 Jul 2026 19:35:40 +0000 Message-Id: <6a4c038c.40202.3c63240e@gitrepo.freebsd.org> The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=d7d71341ae7d79886143a9ce427dca0e858eda97 commit d7d71341ae7d79886143a9ce427dca0e858eda97 Author: Peter Eriksson AuthorDate: 2026-07-06 19:33:22 +0000 Commit: Rick Macklem CommitDate: 2026-07-06 19:33:22 +0000 acl_from_text.c: Allow negative uid/gid numbers to be handled getfacl / acl_to_text() incorrectly prints uid/gid numbers as signed integers. This causes uid / gid numbers larger than 2G (2147483648) to print as negative numbers. The libc acl_from_text() function does not handle negative numbers. This diff adds a backwards compatiblity fix to allow negative numbers... Reviewed by: rmacklem MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D57180 --- lib/libc/posix1e/acl_from_text.c | 41 +++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/libc/posix1e/acl_from_text.c b/lib/libc/posix1e/acl_from_text.c index 765b58290a04..746338b37f0c 100644 --- a/lib/libc/posix1e/acl_from_text.c +++ b/lib/libc/posix1e/acl_from_text.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include "acl_support.h" @@ -263,6 +264,24 @@ error_label: return(NULL); } +/* + * Make sure the number given fits inside an uid_t or gid_t. + * Currently (2026-05-23) uid_t & gid_t is an uint32_t. + * Special case handle uid_t/gid_t numbers specified as negative numbers. + * Assumes that uid_t and gid_t are the same types. + */ +static int +_invalid_uidgid(intmax_t v) { + if (v < 0) { + if ((-v) & ~(uintmax_t)((~(uid_t)0)>>1)) + return (2); /* Underflow, does not fit into uid_t */ + } else { + if (v & ~(uintmax_t)(~(uid_t)0)) + return (1); /* Overflow, does not fit into uid_t */ + } + return (0); +} + /* * Given a username/groupname from a text form of an ACL, return the uid/gid * XXX NOT THREAD SAFE, RELIES ON GETPWNAM, GETGRNAM @@ -274,19 +293,21 @@ _acl_name_to_id(acl_tag_t tag, char *name, uid_t *id) { struct group *g; struct passwd *p; - unsigned long l; + intmax_t v; char *endp; switch(tag) { case ACL_USER: p = getpwnam(name); if (p == NULL) { - l = strtoul(name, &endp, 0); - if (*endp != '\0' || l != (unsigned long)(uid_t)l) { - errno = EINVAL; + errno = 0; + v = strtoimax(name, &endp, 0); + if (name == endp || *endp != '\0' || + errno == ERANGE || _invalid_uidgid(v) != 0) { + errno = EINVAL; /* No or invalid number */ return (-1); } - *id = (uid_t)l; + *id = v; return (0); } *id = p->pw_uid; @@ -295,12 +316,14 @@ _acl_name_to_id(acl_tag_t tag, char *name, uid_t *id) case ACL_GROUP: g = getgrnam(name); if (g == NULL) { - l = strtoul(name, &endp, 0); - if (*endp != '\0' || l != (unsigned long)(gid_t)l) { - errno = EINVAL; + errno = 0; + v = strtoimax(name, &endp, 0); + if (name == endp || *endp != '\0' || + errno == ERANGE || _invalid_uidgid(v) != 0) { + errno = EINVAL; /* No or invalid number */ return (-1); } - *id = (gid_t)l; + *id = v; return (0); } *id = g->gr_gid;