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

Failed to spawn stage2 when /dev has noexec flag #335

Open
Kazurin-775 opened this issue Apr 14, 2022 · 1 comment
Open

Failed to spawn stage2 when /dev has noexec flag #335

Kazurin-775 opened this issue Apr 14, 2022 · 1 comment

Comments

@Kazurin-775
Copy link

It is common for modern Linux kernels (or distributions) to have /dev mounted with noexec flag to enhance security (such as the Ubuntu 20.04 LTS cloud image which we used in our tests). But this prevents VMSH from spawning the stage2 process, as the following kmsg states:

[   59.024633] stage1: failed to spawn stage2: errno=-13
[   59.033913] stage1: failed

... where -13 = Permission denied. Removing the noexec flag with mount -o remount,exec /dev resolves the problem.

Maybe some additional checks should be added to prevent stage1 from extracting stage2 binaries into unsuitable directories, such as those with ro or noexec?

@Mic92
Copy link
Owner

Mic92 commented Apr 14, 2022

Yes. There should be definitely fallback directories like /tmp etc. The only tricky part is that we don't want to use a lot of kernel api for compatibility reasons. The easiest solution would be to process if execution fails here:

let res = ffi::call_usermodehelper(

and than fallback to different directories.

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

No branches or pull requests

2 participants