Skip to content

fix(inode): bound symlink target reads - #5262

Open
singh4jitendra wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
singh4jitendra:fix/bound-symlink-target-reads
Open

singh4jitendra wants to merge 1 commit into
GoogleCloudPlatform:masterfrom
singh4jitendra:fix/bound-symlink-target-reads

Conversation

@singh4jitendra

Copy link
Copy Markdown
Contributor

Description

A standard symlink target is stored in object contents. We currently read all of it even though the kernel cannot use a target longer than its pathname limit.

This bounds the read, rejects oversized standard and legacy targets with ENAMETOOLONG, and keeps the valid boundary working. The tests use small fake objects, including a response larger than the reported metadata size. This complements the symlink opt-out in #5254.

Link to the issue in case of a bug fix.

Fixes #5260

Testing details

Go 1.27.4 on Ubuntu 24.04 under WSL.

  1. Manual -
    • make build - passed with 0 lint issues.
  2. Unit tests -
    • go test -mod=readonly -p 1 -count=1 -timeout=90s -run '^TestSymlinkTarget(ReadIsBounded|LengthBoundaries)$' ./internal/fs/inode - failed as expected before the fix.
    • go test -mod=readonly -p 1 -count=1 -race -timeout=3m ./internal/fs/inode ./internal/fs/wrappers - passed on native Linux storage.
    • The bounded-stream case uses only 16 KiB, checks the reader is closed, and requires at most PATH_MAX bytes to be consumed.
  3. Integration tests - Not run. No cloud bucket, FUSE mount or memory-exhaustion probe was used.

Any backward incompatible change? If so, please explain.

Targets at or above PATH_MAX now return ENAMETOOLONG; these exceed the platform's supported target length. Normal standard/legacy targets, including the valid boundary, keep working.

Limit standard target reads to the platform pathname boundary and reject oversized standard or legacy targets without retaining unusable content. Cover the exact boundary, stale size metadata, bounded consumption and reader cleanup.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces size limits on symlink targets to ensure they fit within the platform's pathname limit (4095 bytes on Linux), returning ENAMETOOLONG for longer targets. It bounds standard symlink target reads using io.LimitReader and validates legacy symlink target lengths. Additionally, it updates the documentation and adds comprehensive unit tests to verify these boundaries. I have no feedback to provide as the implementation is clean and well-tested.

@singh4jitendra
singh4jitendra marked this pull request as ready for review November 17, 2026 05:29
@singh4jitendra
singh4jitendra requested a review from a team as a code owner November 17, 2026 05:29
@singh4jitendra

Copy link
Copy Markdown
Contributor Author

Hi @kislaykishore, could you help get CI running for this symlink-target limit fix and take a look when you have a chance? Let me know if there's anything you'd like changed. Thanks!

@singh4jitendra

Copy link
Copy Markdown
Contributor Author

Hi @kislaykishore, could you help approve CI and review the symlink-target bounds when you have a moment? Happy to address any feedback. Thanks!

@singh4jitendra

Copy link
Copy Markdown
Contributor Author

Hi @kislaykishore, could you take a look at the symlink-target limit fix when you have time? Thanks!

@anushka567
anushka567 self-requested a review November 30, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant