RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1956463 - Provide better error message for UID or GID 65535
Summary: Provide better error message for UID or GID 65535
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: systemd
Version: 8.4
Hardware: All
OS: Linux
unspecified
low
Target Milestone: beta
: ---
Assignee: Michal Sekletar
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-05-03 18:14 UTC by Nicolas Wildner
Modified: 2022-11-03 07:27 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-03 07:27:45 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Nicolas Wildner 2021-05-03 18:14:42 UTC
Description of problem:
Whenever a unitfile is created with options "User=" and/or "Group=" pointing to a group or user that has ID 65535, service fails to start with Bad Message logs:



Example:
Apr 02 15:00:01 hostname systemd[PID]: example.service: Failed to determine user credentials: Bad message
Apr 02 15:00:01 hostname systemd[PID]: example.service: Failed at step USER spawning /usr/local/bin/example: Bad message
Apr 02 15:00:01 hostname systemd[PID]: Received SIGCHLD from PID 320644 ((sleep)).
Apr 02 15:00:01 hostname systemd[PID]: Child 320644 ((sleep)) died (code=exited, status=217/USER)
Apr 02 15:00:01 hostname systemd[PID]: example.service: Child 320644 belongs to example.service.
Apr 02 15:00:01 hostname systemd[PID]: example.service: Main process exited, code=exited, status=217/USER
Apr 02 15:00:01 hostname systemd[PID]: example.service: Failed with result 'exit-code'.

This also applies to systemd unit overrides on the same situation(GID and/or UID 65535).

At src/basic/user-util.c, inside int get_user_creds() the validation happens inside the following if:

     if (uid) {
                if (!uid_is_valid(p->pw_uid))
                        return -EBADMSG;

                *uid = p->pw_uid;
        }

        if (gid) {
                if (!gid_is_valid(p->pw_gid))
                        return -EBADMSG;

                *gid = p->pw_gid;
        }


The same file provides the MAX_UNSIGNED_SHORT(16bit -1) validation. Quoting the uid_is_valid() funcion:

bool uid_is_valid(uid_t uid) {

        /* Also see POSIX IEEE Std 1003.1-2008, 2016 Edition, 3.436. */

        /* Some libc APIs use UID_INVALID as special placeholder */
        if (uid == (uid_t) UINT32_C(0xFFFFFFFF))
                return false;

        /* A long time ago UIDs where 16bit, hence explicitly avoid the 16bit -1 too */
        if (uid == (uid_t) UINT32_C(0xFFFF))
                return false;

        return true;
}



Version-Release number of selected component (if applicable):
systemd-239-31.el8_2.2.x86_64, but it also reproduces on newer 8.3 versions as tested on additional VMs.



How reproducible:
Every time



Steps to Reproduce:
1. Create a custom systemd unitfile or unitfile override with "User=" and/or "Group=" with a username and/or group that uses ID 65535
2. Start the service.



Actual results:

"Failed to determine user credentials: Bad message" output followed by a "Main process exited, code=exited, status=217/USER"



Expected results:

Provide a better error handling message like "User %u has UID 65535" or "Group %g has GID 65535"



Additional info:
 - Ongoing case with this bug: https://access.redhat.com/support/cases/#/case/02928936
 - Ongoing KCS documenting this behavior: https://access.redhat.com/solutions/6009451
 - Upstream systemd documentation: https://systemd.io/UIDS-GIDS/

Comment 2 RHEL Program Management 2022-11-03 07:27:45 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.


Note You need to log in before you can comment on or make changes to this bug.