Skip to content

update-utmp: let libaudit determine comm on boot/shutdown - #43144

Merged
yuwata merged 1 commit into
systemd:mainfrom
markusboehme:fix/libaudit-4.2-comm-limit
Jul 29, 2026
Merged

yuwata merged 1 commit into
systemd:mainfrom
markusboehme:fix/libaudit-4.2-comm-limit

Conversation

@markusboehme

Copy link
Copy Markdown
Contributor

audit_log_user_comm_message from libaudit 4.2 rejects comm arguments that exceed the kernel's comm limit of 15 characters with EINVAL. The hard-coded "systemd-update-utmp" exceeds this by 4 characters.

Pass NULL as comm and let audit_log_user_comm_message determine comm using procfs instead. In practice, the AUDIT_SYSTEM_BOOT/SHUTDOWN audit records will have their comm set to "systemd-update-u".

Fixes: #43143

@github-actions github-actions Bot added utmp/wtmp please-review PR is ready for (re-)review by a maintainer labels Jul 24, 2026
@github-actions

github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown

Claude review of PR #43144 (1648602)

The change is small and correct: the comm argument is shortened from the over-length "systemd-update-utmp" (19 chars) to the explicit literal "update-utmp" (11 chars), staying under the kernel's 15-char comm limit that libaudit 4.2 enforces with EINVAL. The value is accepted on both libaudit < 4.2 and >= 4.2 and contains only printable ASCII (no hex-encoding). No correctness, memory-safety, lifetime, or security issues found across the reviewed lenses.

Nits

  • Procfs-derived comm changes logged value — src/update-utmp/update-utmp.c:66 — record comm becomes truncated systemd-update-u and now depends on /proc; an explicit ≤15-char literal would be deterministic and version-independent (same at line 96). Fixed: now uses the explicit literal "update-utmp".
  • Audit record comm value changes — src/update-utmp/update-utmp.c:66 — the comm= field in AUDIT_SYSTEM_BOOT/SHUTDOWN records changes from systemd-update-utmp to update-utmp, so consumers matching on the old string no longer match; unavoidable and intentional given the fix (same at line 96).

Workflow run

Comment thread src/update-utmp/update-utmp.c Resolved
Comment thread src/update-utmp/update-utmp.c Outdated
#if HAVE_AUDIT
if (c->audit_fd >= 0)
if (sym_audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_BOOT, "", "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
if (sym_audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_BOOT, "", NULL, NULL, NULL, NULL, 1) < 0 &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, how about to use update-utmp or (update-utmp) ?
The automatic systemd-update-u is slightly ambiguous.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering naming it something like that, or shortening systemd to sd like done elsewhere, but wasn't sure about the conventions of when to parenthesize or when to prefix with sd- (or both). I went with "update-utmp" for now.

@yuwata yuwata added reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks and removed please-review PR is ready for (re-)review by a maintainer labels Jul 25, 2026
audit_log_user_comm_message from libaudit 4.2 rejects comm arguments
that exceed the kernel's comm limit of 15 characters with EINVAL. The
hard-coded "systemd-update-utmp" exceeds this by 4 characters. Shorten
it to "update-utmp" instead.

Signed-off-by: Markus Boehme <[email protected]>
@markusboehme
markusboehme force-pushed the fix/libaudit-4.2-comm-limit branch from bf189c5 to 1648602 Compare July 28, 2026 22:39
@github-actions github-actions Bot added please-review PR is ready for (re-)review by a maintainer and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Jul 28, 2026
#if HAVE_AUDIT
if (c->audit_fd >= 0)
if (sym_audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_BOOT, "", "systemd-update-utmp", NULL, NULL, NULL, 1) < 0 &&
if (sym_audit_log_user_comm_message(c->audit_fd, AUDIT_SYSTEM_BOOT, "", "update-utmp", NULL, NULL, NULL, 1) < 0 &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude: nit: Claude: The comm= value in the emitted AUDIT_SYSTEM_BOOT record changes from systemd-update-utmp to update-utmp. The new value is 11 chars, within the kernel's 15-char comm limit, accepted by both libaudit < 4.2 (no length check) and >= 4.2 (which rejected the old 19-char value with EINVAL), and it is printable ASCII so libaudit does not hex-encode it. The one downstream consequence worth flagging: any audit-log consumer matching on comm=systemd-update-utmp will no longer match. This is unavoidable given the fix and is intentional (it is also the value maintainer yuwata requested), but it is a visible record-semantics change on systems where the old value was previously accepted. The same applies to the AUDIT_SYSTEM_SHUTDOWN call at line 96.

@yuwata yuwata left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Next time, please drop 'Signed-off-by' tag from the commit message. We do not use it.

@yuwata
yuwata merged commit b8968c4 into systemd:main Jul 29, 2026
61 of 63 checks passed
@github-actions github-actions Bot removed the please-review PR is ready for (re-)review by a maintainer label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

systemd-update-utmp fails with libaudit 4.2 due to overly long "comm"

3 participants