kvm_proclist(): Restore outputting the effective GID

In particular, fixes 'procstat -s -M' (only if there are less than 16
groups).

Reviewed by:    kib, emaste
Fixes:          be1f7435ef ("kern: start tracking cr_gid outside of cr_groups[]")
MFC after:      9 days
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52260
This commit is contained in:
Olivier Certner 2025-08-28 16:19:43 +02:00
parent 63a40ca813
commit 7676df2fae
No known key found for this signature in database
GPG key ID: 8CA13040971E2627

View file

@ -150,13 +150,14 @@ kvm_proclist(kvm_t *kd, int what, int arg, struct proc *p,
kp->ki_cr_flags = 0;
if (ucred.cr_flags & CRED_FLAG_CAPMODE)
kp->ki_cr_flags |= KI_CRF_CAPABILITY_MODE;
if (ucred.cr_ngroups > KI_NGROUPS) {
if (1 + ucred.cr_ngroups > KI_NGROUPS) {
kp->ki_ngroups = KI_NGROUPS;
kp->ki_cr_flags |= KI_CRF_GRP_OVERFLOW;
} else
kp->ki_ngroups = ucred.cr_ngroups;
kvm_read(kd, (u_long)ucred.cr_groups, kp->ki_groups,
kp->ki_ngroups * sizeof(gid_t));
kp->ki_ngroups = 1 + ucred.cr_ngroups;
kp->ki_groups[0] = ucred.cr_gid;
kvm_read(kd, (u_long)ucred.cr_groups, kp->ki_groups + 1,
(kp->ki_ngroups - 1) * sizeof(gid_t));
if (ucred.cr_prison != NULL) {
if (KREAD(kd, (u_long)ucred.cr_prison, &pr)) {
_kvm_err(kd, kd->program,