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: Fix corrupted dirents due to trailing garbage #191

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

asahilina
Copy link
Contributor

The dirent name length is supposed to be the actual strlen() of the name, without any padding. SYS_getdents64, however, will pad the records it returns (for alignment, etc.) as well as NUL-terminate the name.

This was causing dirents in the guest kernel to have spurious NUL padding treated as part of the name, which in turn was breaking getcwd() under some conditions (and probably other more subtle things).

Copy link

@andy9a9 andy9a9 left a comment

Choose a reason for hiding this comment

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

Ok, fine with me 👍

The dirent name length is supposed to be the actual strlen() of the
name, without any padding. SYS_getdents64, however, will pad the records
it returns (for alignment, etc.) as well as NUL-terminate the name.

This was causing dirents in the guest kernel to have spurious NUL
padding treated as part of the name, which in turn was breaking getcwd()
under some conditions (and probably other more subtle things).

Signed-off-by: Asahi Lina <lina@asahilina.net>
@asahilina
Copy link
Contributor Author

Fixed the code formatting ^^

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 catch. Let's get it merged and cut a new minor release.

@slp slp merged commit 73d104c into containers:main Jun 3, 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.

4 participants