Skip to content

guest: require digits on both sides of a syslog timestamp's point - #2214

Merged
Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
agents/issue-2211-syslog-timestamp-digits
Nov 26, 2026
Merged

Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
agents/issue-2211-syslog-timestamp-digits

Conversation

@ppenna

@ppenna Pedro Henrique Penna (ppenna) commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2211

What does this pull request change?

SyslogLine::parse in nvx/src/guest/kernel_text.rs, the reader of kernel
log lines as syslog(2) returns them, which the time ABI's boot check C4 in
nvx-time and nvx-time-probe's fallback share, now takes a leading bracket
for a timestamp only when its seconds and its fraction each hold one or more
digits. <6>[.] message, <6>[5.] message, and <6>[ .5] message now keep
their brackets in their messages and have no timestamp, as <6>[abc] message
already did; before, they parsed as 0 s, 5 s, and 0.5 s, without their
brackets. The kernel's own timestamps, [%5lu.%06lu], and fractions of other
lengths, such as that of [12.5], parse as before.

Start at microseconds, which now reads the seconds with the shared
guest::parse::parse_decimal, which refuses empty text, and requires a
nonempty fraction of digits. The rustdoc of it and of SyslogLine::parse says
so, and the new test
syslog_brackets_without_seconds_or_fraction_digits_stay_in_the_message
covers the three forms.

It changes no consumer of the reader: C4's exemption of the time tools' own
NVX-TIME- records still tests the start of a line's message, which now keeps
a malformed bracket.

Why is this change needed?

microseconds checked only that the seconds and the fraction held nothing but
digits, which empty text satisfies, and read empty seconds as 0. That
leniency comes from the time ABI decoder's former syslog_message, which
skipped zero or more digits on each side of the point; 2ac2ce1a20c kept it
when it merged that reader with the probe's into SyslogLine, although it
documented the strict form, and its message says that the tools read the
kernel's text "only in the form in which they are written".

The impact is low, as #2211 describes: NVX's guest kernel stamps every line
(CONFIG_PRINTK_TIME=y), so such a bracket comes first only when a command
line sets printk.time=0 and a message's own text starts with one. Then C4
also exempted a line such as <6>[.] NVX-TIME-... from its W+X, watch-rule,
and forbidden-record checks, and the probe printed such a message with a
fabricated timestamp and without its bracket.

Rejected alternatives: requiring exactly the kernel's six fraction digits,
which the rustdoc and the existing test, with [12.5], do not ask for and no
reader needs; and documenting the empty parts as accepted, which would keep a
form that the kernel never writes and the misreading of messages that start
with one.

How was this change validated?

Checks and results:

  • Reproduced at the base, c074bf631d2: the new test fails there, as
    <6>[.] message parses as (Some(0), "message"), and passes with the fix.
    cargo test --locked --features guest --lib (from nvx/) passes with the
    fix: 1249 passed, 0 failed, 42 ignored, which need root, capabilities, or an
    environment of their own.

  • python scripts\local_gates.py --base origin/dev --run on Windows, with a
    release nvx built so that NVX names it: test-changes (0 changes to
    existing tests, 1 added), markdown-links, test-layout, nvx-format,
    nvx-lint, nvx-test, nvx-doc, nvx-msrv, and nvx-cli (2326 tests OK,
    89 skipped; test_adversarial.py 84 OK, 11 skipped) passed. These Rust gates
    do not compile nvx/src/guest on Windows, so the Linux run below is the one
    that checks the change.

  • python3 scripts/local_gates.py --base origin/dev --run in WSL 2, in a clone
    of 25317d20b70, whose tree the head, e0ca73a51be, keeps with a reworded
    message, with a temporary python → python3 link on PATH:
    test-changes, markdown-links, test-layout, nvx-format, nvx-lint,
    nvx-test (1870 lib tests with all features passed, 59 ignored), nvx-doc,
    nvx-public-api, nvx-msrv, nvx-macos, nvx-guest-binaries-lint, and
    nvx-guest-binaries-build passed. nvx-cli stopped at its first command,
    python3 -m pip install --requirement scripts/setup/azure/requirements.txt,
    which the distribution's Python refuses (externally-managed-environment);
    its only requirement, PyYAML 6.0.3, is installed, and the gate's remaining
    commands passed: 2326 tests OK (41 skipped), test_adversarial.py 84 OK, and
    the nvx.py help checks.

  • A code-review pass of the branch's diff found no issue.

  • Runtime check in WSL 2 with KVM: the nvx-time of release
    v0.1.0-dev.0d2ea37c50be, whose nvx/, guest/, and kernel/ equal the
    base's, taken from its Alpine initramfs (sha256 a45929c7…), and the fixed
    one that this commit's guest-binary build produced (sha256 d6e1e5ed…), each
    running C4's scan of a log, nvx-time test syslog LOG, on real guest boot
    logs read through syslog(2) (dmesg -r -S) from guests booted with the
    release's artifacts and --cpu-profile host:

    Log Release nvx-time Fixed nvx-time
    Boot log, 173 stamped lines ok ok
    Boot log with printk.time=0, 173 unstamped lines ok ok
    The same, plus <6>[.] NVX-TIME-x kvm-clock: Using msrs ok: exempted as an own record fail forbidden record: [.] NVX-TIME-x kvm-clock: Using msrs
    The same, plus <4>[5.] NVX-TIME-x x86/mm: Found insecure W+X mapping at address 0xffffffffc0000000 ok, no W+X ok, then wx [5.] NVX-TIME-x x86/mm: Found insecure W+X mapping at address 0xffffffffc0000000

    The printk.time=0 log confirms the trigger: its syslog(2) lines carry no
    timestamp, so a message's own leading bracket comes first.

Backend, host OS, host type, and guest: the unit tests and Linux gates ran in
this Windows 11 workstation's default WSL 2 distribution (Linux
6.18.58.1-microsoft-standard-WSL2, Rust 1.97.1), and the guests booted there
on KVM, an Alpine guest of release v0.1.0-dev.0d2ea37c50be with
--cpu-profile host, a WSL fallback with no recorded host type; the Windows
gates ran natively on that workstation. nvx_hosts.py select reached
azure-intel-kvm-1, azure-intel-mshv-1, and azure-intel-whp-1
(virtual-machine), but they are GitHub Actions runners with no configured
checkout, and azure-intel-kvm-1 has no Rust toolchain, so no check ran on
them; azure-intel-kvm-2, azure-intel-kvm-5, azure-intel-mshv-3,
azure-intel-mshv-5, azure-intel-whp-2, azure-intel-whp-3,
azure-intel-whp-6, azure-intel-whp-7, and azure-intel-whp-12 were
unreachable. test-microvm --backend kvm --scenario time-abi-conformance could
not run in WSL: its guest boots with --cpu-profile auto, and WSL's KVM refuses
the built-in intel.alderlake.v1 with E_PROFILE_UNSUPPORTED (MSR 0x10a bits
8, 17). No initramfs with the fixed binaries was packed, as WSL lacks cpio,
so no guest booted with them.

CI: run 45820231220
of the head, e0ca73a51be, passed, with the guest artifacts built from this
change: the microVM tests on KVM, MSHV, and WHP, both shards and the guests
and sandboxes of each, and MSHV's debug kernel; the platform jobs of the three
backends; the packages; nvx on ubuntu-latest and windows-latest; the NVX
CLI on Linux and Windows; the quality gates; and Required status check.

Checklist

  • Tests cover the new or fixed behavior, in the layout that
    python3 scripts/check_test_layout.py checks.
  • python3 scripts/check_test_changes.py --base origin/dev lists no change
    to an existing test, or a Changes to existing tests section below
    explains each one.
  • The documentation that the change affects is updated, including
    .github/copilot-instructions.md and the skills when a convention or
    workflow changes.
  • A change to the public API of nvx updates nvx/public-api/ with
    python3 scripts/public_api.py --update.
  • Snapshots, protocols, and on-disk formats stay compatible, or the
    description says how the change versions or migrates them.

SyslogLine::parse, which the time ABI's boot check C4 and
nvx-time-probe's syslog(2) fallback use to split a kernel log line,
took a leading bracket whose seconds or fraction held no digit for a
timestamp: `<6>[.] message` parsed as 0 s, `<6>[5.] message` as 5 s,
and `<6>[ .5] message` as 0.5 s, each without the bracket in its
message. Its rustdoc says that a timestamp is decimal seconds with a
decimal fraction and that a line whose brackets hold anything else
keeps them in its message, and the kernel writes its timestamps as
`[%5lu.%06lu]`. C4, which exempts the time tools' own NVX-TIME-
records by the start of the message, then also exempted a line such
as `<6>[.] NVX-TIME-...`, and the probe printed such a message with a
fabricated timestamp. Reported in #2211.

`microseconds` checked only that the seconds and the fraction held
nothing but digits, which empty text satisfies, and read empty
seconds as 0: a leniency of the time ABI decoder's former
`syslog_message`, which 2ac2ce1 kept when it merged that reader
with the probe's into `SyslogLine`.

It now reads the seconds with the shared `parse_decimal`, which
refuses empty text, and requires one or more digits in the fraction.
A fraction of another length than the kernel's six digits, such as
that of `[12.5]`, still parses as before. The rustdoc of both
functions says so.

Evidence, on this Windows workstation's default WSL 2 distribution
(Linux 6.18.58.1-microsoft-standard-WSL2) with Rust 1.97.1, since the
guest module builds only on Linux, and the reachable configured Linux
hosts, azure-intel-kvm-1 and azure-intel-mshv-1, are CI runners
without a checkout or a Rust toolchain: at c074bf6, the new test
fails, as `<6>[.] message` parses as (Some(0), "message"); with the
change, `cargo test --locked --features guest --lib` passes, 1249
tests passed and 42 ignored, which need root, capabilities, or an
environment of their own.

Tests: the new kernel_text test
syslog_brackets_without_seconds_or_fraction_digits_stay_in_the_message
fails at c074bf6 and passes with the change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the kernel syslog parser change.

No open issues 🎉

What changed in this PR

Fixes #2211 by tightening the shared kernel syslog parser used by the guest time tools. Malformed timestamp brackets now remain part of the message rather than producing a fabricated timestamp.

Changes:

  • Require at least one digit on each side of the timestamp’s decimal point.
  • Add regression coverage for [.], [5.], and [ .5].
  • Clarify the parser documentation while preserving support for valid variable-length fractions.
File Description
nvx/​src/​guest/​kernel_text/​tests.rs Tests that malformed timestamps retain their brackets and yield no timestamp.
nvx/​src/​guest/​kernel_text.rs Rejects empty seconds or fractions and documents the accepted format.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the syslog timestamp parsing change.

No open issues 🎉

Review effort: Balanced

@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 26, 2026
Merged via the queue into dev with commit 3678a12 Nov 26, 2026
59 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-2211-syslog-timestamp-digits branch November 26, 2026 19:00
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.

nvx: the time tools take a syslog line's [.], [5.], or [ .5] for a timestamp and drop it from the message

2 participants