Skip to content

utmpx: reject non-regular Linux login files - #16233

Open
mattsu2020 wants to merge 2 commits into
uutils:mainfrom
mattsu2020:utmpx/traditional-reader
Open

mattsu2020 wants to merge 2 commits into
uutils:mainfrom
mattsu2020:utmpx/traditional-reader

Conversation

@mattsu2020

@mattsu2020 mattsu2020 commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Reject non-regular Linux utmp inputs without waiting for FIFO writers, and validate and read the same descriptor. getutxent() accepts neither that descriptor nor O_NONBLOCK; its record-lock timeout does not protect the open. Add regression tests for FIFOs, path replacement and incomplete records.

Related to #13171. Path persistence is split into #16284, and a shared lock-wait budget into #16285.

Comment thread src/uucore/src/lib/features/utmpx.rs Resolved
Comment thread src/uucore/src/lib/features/utmpx.rs Resolved
Comment thread docs/src/platforms.md Resolved
Comment thread tests/by-util/test_who.rs Resolved
Comment thread src/uucore/src/lib/features/utmpx.rs Resolved
Comment thread src/uucore/src/lib/features/utmpx.rs Resolved
@sylvestre

Copy link
Copy Markdown
Contributor

thanks for tackling this!
This mixes three changes (FIFO rejection, the path persisting across iterators, bounded lock waits) and replaces glibc's reader without saying why. Could you please split it and document why getutxent isn't enough on Linux?

@mattsu2020
mattsu2020 marked this pull request as draft November 8, 2026 14:05
@mattsu2020
mattsu2020 force-pushed the utmpx/traditional-reader branch from 90f1515 to 708ca2e Compare November 8, 2026 14:21
@mattsu2020 mattsu2020 changed the title utmpx: read validated Linux files with bounded lock waits utmpx: reject non-regular Linux login files Nov 8, 2026
@mattsu2020

Copy link
Copy Markdown
Contributor Author

thanks for tackling this! This mixes three changes (FIFO rejection, the path persisting across iterators, bounded lock waits) and replaces glibc's reader without saying why. Could you please split it and document why getutxent isn't enough on Linux?

I split the PR and added a comment explaining the custom implementation of getutxent

@mattsu2020
mattsu2020 marked this pull request as ready for review November 8, 2026 14:59
@codspeed

codspeed Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning, 1 note

⚠️ 122 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 1 benchmark has no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

✅ 405 untouched benchmarks
⏩ 70 skipped benchmarks1


Comparing mattsu2020:utmpx/traditional-reader (c46fe30) with main (a68dc1e)

Open in CodSpeed

Footnotes

  1. 70 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment thread src/uucore/src/lib/features/utmpx.rs Resolved
Comment thread src/uucore/src/lib/features/utmpx.rs Resolved
Comment thread src/uucore/src/lib/features/utmpx.rs Resolved
Comment thread tests/by-util/test_who.rs Resolved
@mattsu2020
mattsu2020 force-pushed the utmpx/traditional-reader branch from f2599f8 to 53eabce Compare November 9, 2026 10:55
Open and validate a nonblocking descriptor, then select it for libc via
/proc/self/fd. Keep getutxent for record reads and locking.

Cover FIFO rejection, path replacement, invalid inputs and cleanup.
Use one test-only helper for the uucore unit tests and who FIFO test.
Keep the helper inside uucore so it is included in the crate package.
@mattsu2020
mattsu2020 force-pushed the utmpx/traditional-reader branch from 53eabce to c46fe30 Compare November 10, 2026 06:35
@mattsu2020
mattsu2020 requested a review from sylvestre November 12, 2026 11:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants