Skip to content

syscalls: prevent overwriting currently executing binary - #14164

Closed
Rajkaran-122 wants to merge 2 commits into
google:masterfrom
Rajkaran-122:contrib/fix-overwrite-running-binary
Closed

syscalls: prevent overwriting currently executing binary#14164
Rajkaran-122 wants to merge 2 commits into
google:masterfrom
Rajkaran-122:contrib/fix-overwrite-running-binary

Conversation

@Rajkaran-122

Copy link
Copy Markdown

Add ETXTBSY check in renameat to prevent renaming the currently executing binary. This implements basic Linux behavior where attempting to overwrite a running executable fails with ETXTBSY error.

This is a partial implementation of ETXTBSY behavior as requested in #1005, preventing modification of the executable file itself while it's running.

Add ETXTBSY check in renameat to prevent renaming the currently
executing binary. This implements basic Linux behavior where attempting
to overwrite a running executable fails with ETXTBSY error.

This is a partial implementation of ETXTBSY behavior as requested in google#1005,
preventing modification of the executable file itself while it's running.
Comment thread pkg/sentry/syscalls/linux/sys_file.go Outdated
exe := t.MemoryManager().Executable()
if exe != nil {
// Check if the source file is the current executable.
oldVD, err := t.Kernel().VFS().FindFileDescription(t, oldtpop.pop)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

VirtualFilesystem has no FindFileDescription method

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.

wth, @Rajkaran-122 why are you spamming us? xD

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Banning this user in #14208.

…FileDescription

The previous implementation used VirtualFilesystem.FindFileDescription which
does not exist. Changed to use VirtualFilesystem.OpenAt which is the correct
method to get a FileDescription from a PathOperation.

This fixes the build error reported in PR google#14164.

@milantracy milantracy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the PR is not acceptable, and i have no idea what the PR wants to fix

  1. Linux doesn't return ETXTBSY on rename.
  2. #1005 is about a different path, renameat isn't involved

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