Conversation
CI scan-build raised eleven warnings against the rosetta merge. Resolving them surfaced a latent utimensat bug: Linux UTIME_NOW (0x3fffffff) and UTIME_OMIT (0x3ffffffe) were passed straight through to macOS, whose sys/stat.h uses -1 and -2 for those sentinels. Guests asking for UTIME_NOW were getting an nsec value > 999999999, which the host utimensat rejects as EINVAL; UTIME_OMIT silently degraded to "set tv_nsec to a billion". Both are now translated explicitly, and both-OMIT is short-circuited before any fd/flag validation since the call is a guaranteed no-op. src/core/stack.c (build_linux_stack) - Always allocate at least one calloc slot for arg_ptrs/env_ptrs so the pointers are never NULL. The empty-loop case is a no-op, and the static analyzer no longer has to correlate (argc > 0) with arg_ptrs being non-NULL. src/core/rosetta.c (rosetta_finalize) - Drop the ownership-transfer bin_host_fd = -1 sentinel. No goto fail path runs past fd_alloc_at(3) on success, so the store was dead. The refreshed comment warns future maintainers that adding any fallible step below the commit point requires explicit ownership handling. src/syscall/mem.c (sys_mmap success path, mmap_fork_prepare_anon_shared) - Drop the track_backing_fd = -1 sentinel after guest_region_add_ex_owned_gpa() takes ownership; same audit, same comment as the rosetta change. Tighten the mmap_fork_prepare_anon_shared API so txn_out must be non-NULL, returning -LINUX_EINVAL up front; the three "if (txn_out) *txn_out = txn" guards in error paths were the leak scan-build flagged. The sole caller in forkipc.c already supplies a non-NULL out-pointer. src/syscall/fuse.c (fuse_dev_write FUSE_INIT handling) - Detect the local reply-buffer OOM (req->reply == NULL with reply_len > 0) up front and take a dedicated branch. The previous code fell into the protocol-error else branch and overwrote -LINUX_ENOMEM with -LINUX_EPROTO while marking the daemon dead, turning a host OOM into a fake protocol failure. The new local_oom branch preserves -LINUX_ENOMEM as the request error so the originator sees the root cause, and still marks session->daemon_dead so init waiters wake out of fuse_wait_for_init_locked with -LINUX_ENOTCONN; otherwise the init_cond broadcast below would let them re-block on the still-false init_done flag. src/syscall/sidecar.c, fd.c, inotify.c - Replace read(fd, buf, n) with readv(fd, &iov, 1) for the three drain / locked-file-read sites that scan-build's unix.BlockInCriticalSection flagged. Each read site is either a regular file under the sidecar fcntl lock or an O_NONBLOCK pipe drain, neither of which can actually block; the checker only knows the read/recv names, so readv with a single iovec is functionally identical and silences the warning. src/syscall/fs.c (sys_utimensat) - Translate Linux UTIME_NOW/UTIME_OMIT to the macOS sentinels and short-circuit when both timestamps are UTIME_OMIT. The original passthrough relied on the (incorrect) comment that the constants matched on macOS; they do not. Reject flags != 0 combined with a NULL path with EINVAL (Linux's do_utimes_fd does the same), and reject utimensat(AT_FDCWD, NULL, ...) with EFAULT before futimens(-2, ...) would return EBADF and diverge from Linux. src/syscall/fs-stat.c (sys_fstat, sys_newfstatat, sys_statx) - Zero-initialize the local struct stat before the host call so partial FUSE / /proc emulator backfills do not expose stack garbage through translate_stat / translate_statx. src/syscall/abi.h - Define LINUX_UTIME_NOW and LINUX_UTIME_OMIT alongside the existing AT_* sentinels so the fs.c translation reads from one source of truth.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI scan-build raised eleven warnings against the rosetta merge. Resolving them surfaced a latent utimensat bug: Linux UTIME_NOW (0x3fffffff) and UTIME_OMIT (0x3ffffffe) were passed straight through to macOS, whose sys/stat.h uses -1 and -2 for those sentinels. Guests asking for UTIME_NOW were getting an nsec value > 999999999, which the host utimensat rejects as EINVAL; UTIME_OMIT silently degraded to "set tv_nsec to a billion". Both are now translated explicitly, and both-OMIT is short-circuited before any fd/flag validation since the call is a guaranteed no-op.
src/core/stack.c (build_linux_stack)
src/core/rosetta.c (rosetta_finalize)
src/syscall/mem.c (sys_mmap success path, mmap_fork_prepare_anon_shared)
src/syscall/fuse.c (fuse_dev_write FUSE_INIT handling)
src/syscall/sidecar.c, fd.c, inotify.c
src/syscall/fs.c (sys_utimensat)
src/syscall/fs-stat.c (sys_fstat, sys_newfstatat, sys_statx)
src/syscall/abi.h
Summary by cubic
Fixes scan-build regressions and corrects utimensat behavior on macOS by translating Linux UTIME_NOW/UTIME_OMIT and short-circuiting no-ops. This removes EINVAL/EPROTO false errors and improves safety around FUSE init, mmap fork, and stat handling.
Bug Fixes
Refactors
Written for commit b6ad3cb. Summary will update on new commits. Review in cubic