Repository navigation
Conversation
`ls -l` ignored errors from ReadlinkFile, at both the operand and the directory-entry call sites, so a symlink whose target could not be read was listed without ` -> target`, with nothing on stderr and exit 0. Match GNU ls: print `ls: cannot read symbolic link 'NAME': ERR`, still list the entry, and exit 1. Found by Jacob Hayes with patina (https://github.com/JacobHayes/patina), by injecting EIO into readlink. Environment: Datadog workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ls quotes operands with SafeOperand, which escapes backslashes, and joins directory entries with "/", so build the expected path the same way. Environment: Datadog workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
What
ls -lcalledReadlinkFileat two places (file operands, and entries while listing a directory) and dropped the error. A symlink whose target couldn't be read showed up with no-> target, nothing on stderr, and exit 0.It now matches GNU ls: it prints
ls: cannot read symbolic link 'NAME': ERRon stderr, still lists the entry, and exits 1.Credit
Found by Jacob Hayes with his deterministic-simulation tool patina (finding #2: SILENT oracle, random EIO leg, about 7.8k runs; replays deterministically with
--fs-error-at read_link:2:EIO). Findings thread: https://dd.slack.com/archives/D0AC8RLB21J/p1793475631273749Tests
There's no native way to make
readlinkfail, sobuiltins/ls/readlink_error_test.goinjects the failure throughCallContext.ReadlinkFile:TestLsLongReadlinkFailureInDirectoryTestLsLongReadlinkFailureOnOperandBoth fail on main and pass with this change.
go test ./...passes exceptTestPSPentestLargePIDListDoesNotHanginbuiltins/ps, which fails the same way on clean main on this host.🤖 Generated with Claude Code