From nobody Tue Sep 23 12:03:25 2025 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 4cWJXY6LJnz68XkM; Tue, 23 Sep 2025 12:03:25 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cWJXY36BFz3DTc; Tue, 23 Sep 2025 12:03:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758629005; 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=c/ouskvizrLORKu9SaEU2eoLkEWi5bL2CvWGRLlmZSU=; b=ZYSQ7ownFJVxLzteVrURSAtzFni0KryXTmJ06KWt1hvKF78TSMZD6viAGk68I7HBLByXv1 djfj02G0vnPAlR4jAk/rpOnGNqvEwtSlcGDipY+cWhXKj2V6wrtsZxNDZDWnh1hsoDQtHM XJLPDs032fNr9Pg/UG0u719cROtDKrcyMJGHl2/LyhXyYIXvR4oK5L39gbeBcLh/f+HKNU lyNtS1W+3NmkbtymfVEq9dSE2DIGsuKB2WGRJxRdCndgNY3a4S/b/qpf6ljfTTIy8f6eFe Y0hNzfEZGvP08c+ENCuGqGkNBz7diPxPjQ+ULkEb4nWv7A/nc9AZn9lDRshcOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758629005; 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=c/ouskvizrLORKu9SaEU2eoLkEWi5bL2CvWGRLlmZSU=; b=UPUlHwxuLhuG+qJaxK1WHzTqe3nSN1FwjVnbTj1/zXXacq7Uer6JCfoGmnvqYts/OI7xQP rKrMc3L0OozN6lbq9APnjUUgWVkYaRA4xPHDe1ZskDeqHmIT3JIvA8EJCg0HlTYL+WZdpC RpwoqbLbgsdhPVdD/ose//mYLhOUpPW0Q9wBfRLVCUS4QaE+wwI3QaE5vyFZrDH3vgZDXC FCznoeJCzyUKXYE3CDYpxEdQiJJDx0PILjB3JFU7PGycOvQgDmRiHc0C68/d9SXWLcLxEz WI/etVfBI/CDJCZFrvQ1jskFUBAJuIaaZ/gy5l060/Bz0Z7c/aWsgfBJGv9Hhg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758629005; a=rsa-sha256; cv=none; b=fo6WweIQHMRAmQSrJYyYLgypckOYkF5kfWnUD7OtcJmFooM16STvRHXH6hV9ujj2cnZFhP hjGMXwkQz/fGygpjdPqnvHiQskpEof9+JLSW2skwMCj3StwqDzPRIqr7yzwcOorSJlUfWO AcZevfAGIb34LrqkqnAk2ECbFfco0iYclx3QKoOldKJZYIYbcu2fxhU+JGXc9ydyrNkOFO /Tbc4nwxlv8L4sr/aBeLAAJKLj7jnqw4fSJE9IQYdaVhfhayObeHFYMWIZCyJumwDbQ0VV XAi1bKZOqwyjlXYEBlY2+sLUVEEUQjRQLTBB0hIV9MkNeYvqXs3VJ2IXrQweqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cWJXY2TzWzlcg; Tue, 23 Sep 2025 12:03:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58NC3PqU008193; Tue, 23 Sep 2025 12:03:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58NC3PLk008190; Tue, 23 Sep 2025 12:03:25 GMT (envelope-from git) Date: Tue, 23 Sep 2025 12:03:25 GMT Message-Id: <202509231203.58NC3PLk008190@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: d36c8416e7ed - stable/15 - libprocstat: procstat_getgroups_kvm(): Output again the effective GID 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: d36c8416e7ed6d02fd85dada19b40defc2a0f9f1 Auto-Submitted: auto-generated The branch stable/15 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=d36c8416e7ed6d02fd85dada19b40defc2a0f9f1 commit d36c8416e7ed6d02fd85dada19b40defc2a0f9f1 Author: Olivier Certner AuthorDate: 2025-08-28 14:49:07 +0000 Commit: Olivier Certner CommitDate: 2025-09-23 12:02:40 +0000 libprocstat: procstat_getgroups_kvm(): Output again the effective GID In particular, fixes 'procstat -s -M' (for processes with more than 16 groups). Reviewed by: kib Fixes: be1f7435ef218b1d ("kern: start tracking cr_gid outside of cr_groups[]") MFC after: 5 days MFC to: stable/15 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52275 (cherry picked from commit 11cbb7d122ac0219c214ad52c4d6f7cbb9d60ac1) --- lib/libprocstat/libprocstat.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 1651cbc6820f..df77cabcd36b 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -1973,6 +1973,7 @@ procstat_getgroups_kvm(kvm_t *kd, struct kinfo_proc *kp, unsigned int *cntp) struct ucred ucred; gid_t *groups; size_t len; + unsigned int ngroups; assert(kd != NULL); assert(kp != NULL); @@ -1990,19 +1991,22 @@ procstat_getgroups_kvm(kvm_t *kd, struct kinfo_proc *kp, unsigned int *cntp) proc.p_ucred, kp->ki_pid); return (NULL); } - len = ucred.cr_ngroups * sizeof(gid_t); + ngroups = 1 + ucred.cr_ngroups; + len = ngroups * sizeof(gid_t); groups = malloc(len); if (groups == NULL) { warn("malloc(%zu)", len); return (NULL); } - if (!kvm_read_all(kd, (unsigned long)ucred.cr_groups, groups, len)) { + groups[0] = ucred.cr_gid; + if (!kvm_read_all(kd, (unsigned long)ucred.cr_groups, groups + 1, + len - sizeof(gid_t))) { warnx("can't read groups at %p for pid %d", ucred.cr_groups, kp->ki_pid); free(groups); return (NULL); } - *cntp = ucred.cr_ngroups; + *cntp = ngroups; return (groups); }