Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtio/fs/linux: Fix xattrs on symlinks #224

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

asahilina
Copy link
Contributor

@asahilina asahilina commented Oct 15, 2024

The f*attr library of functions only works on files opened normally. Symlinks can only be opened with O_PATH, but that doesn't support xattr operations. So, to handle symlinks, we need to use the l*attr family of functions directly on the pathname.

Thankfully, this does still work via /proc/self/fd/* for fds opened with O_PATH, so we can still do fd-relative operations (l*attr on such a path resolves the magic symlink and operates on the symlink that is actually opened as that fd).

This fixes ls: bin: Too many levels of symbolic links errors in the guest when SELinux attributes are in use.

The f*attr library of functions only works on files opened normally.
Symlinks can only be opened with O_PATH, but that doesn't support xattr
operations. So, to handle symlinks, we need to use the l*attr family of
functions directly on the pathname.

Thankfully, this does still work via /proc/self/fd/* for fds opened with
O_PATH, so we can still do fd-relative operations (l*attr on such a path
resolves the magic symlink and operates on the symlink that is actually
opened as that fd).

Signed-off-by: Asahi Lina <[email protected]>
Copy link
Contributor

@slp slp left a comment

Choose a reason for hiding this comment

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

Nice one, thanks.

@slp slp merged commit 201124d into containers:main Oct 16, 2024
5 checks passed
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.

2 participants