Skip to content

feat(disable symlinks): add --disable-symlinks flag to opt out of symlink support - #5254

Merged
thrivikram-karur-g merged 3 commits into
masterfrom
vikram-opt-out-symlinks
Nov 17, 2026
Merged

thrivikram-karur-g merged 3 commits into
masterfrom
vikram-opt-out-symlinks

Conversation

@thrivikram-karur-g

Copy link
Copy Markdown
Contributor

Description

Adds an opt-out flag --disable-symlinks (config file: file-system: disable-symlinks: true, default: false) to disable symlink support on a GCSFuse mount.

In multi-tenant or shared-mount setups where users bring their own bucket, a user could upload a GCS object with symlink metadata pointing to a path on the host machine (e.g., /etc/shadow) and read host files outside the mount point.

Summary of the code changes:

  • Config (cfg/params.yaml): Added file-system.disable-symlinks (--disable-symlinks, default false).
  • Block symlink creation & readlink (internal/fs/fs.go): CreateSymlink and ReadSymlink return syscall.ENOTSUP when DisableSymlinks is enabled.
  • Mint regular file inodes (internal/fs/fs.go): mintInode skips NewSymlinkInode when DisableSymlinks is enabled and creates a FileInode (S_IFREG) instead, ensuring the kernel VFS never follows the target path on the host.
  • Directory listings (internal/fs/inode/dir.go, internal/fs/fs.go): ReadEntries (ReadDir) and ReadDirPlus report DT_File instead of DT_Link for symlink objects when DisableSymlinks is enabled.
  • Docs (docs/semantics.md): Documented --disable-symlinks under the # Symlink inodes section.

Link to the issue in case of a bug fix.

b/433488710

Testing details

  1. Manual
    Executed the below manual test plan comparing default behavior (--disable-symlinks=false) vs opt-out enabled (--disable-symlinks=true).

Created a host file /tmp/host_secret.txt (outside the mount) and created both a legacy symlink (0B object, target in gcsfuse_symlink_target metadata) and a standard symlink (20B object with target in content + goog-reserved-file-is-symlink=true) pointing to /tmp/host_secret.txt:

echo "SECRET_HOST_DATA" > /tmp/host_secret.txt

# 1. Create legacy symlink in GCS
go run . --enable-standard-symlinks=false <BUCKET_NAME> <MOUNT_DIR>
ln -s /tmp/host_secret.txt <MOUNT_DIR>/legacy_symlink
fusermount -u <MOUNT_DIR>

# 2. Mount in Default mode (--disable-symlinks=false) and create standard symlink
go run . <BUCKET_NAME> <MOUNT_DIR>
ln -s /tmp/host_secret.txt <MOUNT_DIR>/standard_symlink
# Verified Default mode checks below, then unmounted:
fusermount -u <MOUNT_DIR>

# 3. Remount with --disable-symlinks=true
go run . --disable-symlinks <BUCKET_NAME> <MOUNT_DIR>
# Verified Disabled mode checks below

Verified the comparative behavior across all symlink operations:

Command Default (--disable-symlinks=false) Disabled (--disable-symlinks=true)
ln -s /tmp/host_secret.txt <MOUNT_DIR>/new_link Succeeds; creates symlink in GCS Fails with Operation not supported (ENOTSUP)
ls -l <MOUNT_DIR> Lists lrw-r--r-- ... -> /tmp/host_secret.txt (DT_Link) Lists -rw-r--r-- regular files (DT_File), no arrow
stat <MOUNT_DIR>/legacy_symlink symbolic link, Size: 20 regular empty file, Size: 0 (0B GCS object)
stat <MOUNT_DIR>/standard_symlink symbolic link, Size: 20 regular file, Size: 20 (20B GCS object content)
readlink <MOUNT_DIR>/legacy_symlink Prints /tmp/host_secret.txt Fails (EINVAL - not a symlink)
readlink <MOUNT_DIR>/standard_symlink Prints /tmp/host_secret.txt Fails (EINVAL - not a symlink)
cat <MOUNT_DIR>/legacy_symlink Follows link; prints SECRET_HOST_DATA Prints nothing (0B GCS object; host untouched)
cat <MOUNT_DIR>/standard_symlink Follows link; prints SECRET_HOST_DATA Prints literal /tmp/host_secret.txt from GCS (host untouched)
  1. Unit tests - Added (cmd/root_test.go, internal/fs/inode/dir_test.go, internal/fs/disable_symlinks_test.go)
  2. Integration tests - Added TestDisableSymlinksTestSuite (tools/integration_tests/symlink_handling)

Any backward incompatible change? If so, please explain.

N/A

@github-actions github-actions Bot added the remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR. label Nov 16, 2026

@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 a new configuration option and command-line flag, --disable-symlinks (or file-system.disable-symlinks in the configuration file), to disable symbolic link support in GCSFuse. When enabled, creating new symlinks is blocked (returning ENOTSUP), and existing symlink objects in the bucket are treated as regular files instead of symlinks. The changes span configuration parsing, protobuf definitions, filesystem inode logic, documentation, and extensive unit and integration tests. I have no feedback to provide as there are no review comments.

Comment thread internal/fs/inode/dir.go Resolved
@thrivikram-karur-g

Copy link
Copy Markdown
Contributor Author

/gemini review

@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 a new --disable-symlinks configuration flag to GCSFuse, which blocks the creation of new symlinks (returning ENOTSUP) and treats existing symlink objects as regular files. The changes span configuration parsing, proto definitions, file system operations, and comprehensive testing. The review feedback suggests simplifying the integration test suite structure by directly embedding BaseSymlinkSuite within DisableSymlinksTestSuite to eliminate boilerplate setup and teardown methods.

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.11%. Comparing base (c551196) to head (ccdb2bf).

Files with missing lines Patch % Lines
cfg/pb/config.pb.go 0.00% 3 Missing ⚠️
internal/fs/fs.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5254      +/-   ##
==========================================
- Coverage   85.11%   85.11%   -0.01%     
==========================================
  Files         181      181              
  Lines       19848    19861      +13     
==========================================
+ Hits        16894    16904      +10     
- Misses       2953     2956       +3     
  Partials        1        1              
Flag Coverage Δ
unittests 85.11% <73.33%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@thrivikram-karur-g
thrivikram-karur-g merged commit c307495 into master Nov 17, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

execute-integration-tests Run only integration tests remind-reviewers Auto remind reviewers in attention set for review post 24hrs of inactivity on PR.

2 participants