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

update execve #113

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

update execve #113

wants to merge 1 commit into from

Conversation

robinyuan1002
Copy link
Collaborator

Some modify with Wasmtime and Rawposix to support execve. So for right now we don't need to change cage anymore, we do exactly the same behavior with linux.

Copy link
Member

@Yaxuan-w Yaxuan-w left a comment

Choose a reason for hiding this comment

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

Great! Minor suggestions and we can merge dup3 pr after this one

@@ -133,17 +133,8 @@ impl Cage {
/*
* exec() will only return if error happens
Copy link
Member

Choose a reason for hiding this comment

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

Add comments about what we're doing here and man page link

Copy link
Contributor

Choose a reason for hiding this comment

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

also add how's our exec in rawposix is different from linux and why are we doing in this way

Comment on lines +150 to +161
let mainsigsetatomic = self
.sigset
.get(
&self
.main_threadid
.load(interface::RustAtomicOrdering::Relaxed),
)
.unwrap();
let mainsigset = interface::RustAtomicU64::new(
mainsigsetatomic.load(interface::RustAtomicOrdering::Relaxed),
);
newsigset.insert(0, mainsigset);
Copy link
Member

Choose a reason for hiding this comment

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

should comment out currently

@@ -785,8 +785,20 @@ impl<T: Clone + Send + 'static + std::marker::Sync, U: Clone + Send + 'static +
// to-do: exec should not change the process id/cage id, however, the exec call from rustposix takes an
// argument to change the process id. If we pass the same cageid, it would cause some error
// lind_exec(cloned_pid as u64, cloned_pid as u64);
Copy link
Member

Choose a reason for hiding this comment

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

should delete this comment

Comment on lines +184 to +186
interface::cagetable_remove(self.cageid);

interface::cagetable_insert(child_cageid, newcage);
interface::cagetable_insert(self.cageid, newcage);
Copy link
Contributor

Choose a reason for hiding this comment

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

why choose delete the old cage and create a new one instead of modifying on the existing one

Copy link
Contributor

Choose a reason for hiding this comment

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

@Yaxuan-w and I discussed this previously. I believe she mentioned some data types were difficult to modify. But I think those issues may not exist anymore? I agree it would be better to modify the existing struct if we can.

Copy link
Member

Choose a reason for hiding this comment

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

she mentioned some data types were difficult to modify.

These're not issues for this version rawposix because all things are in same library.

The issue would raise when splitting type conversion and constants as external libs, since this would cause circular imports

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Quote reply
Reference in new issue

I believe both way works. Must we modify on the existing one?

Copy link
Contributor

Choose a reason for hiding this comment

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

My preference would be to modify the existing struct rather than create a new one. Makes more sense logically as well as in terms of reducing overhead and complexity.

zombies: interface::RustLock::new(cloned_zombies), // when a process exec-ed, its child relationship should be perserved
child_num: interface::RustAtomicU64::new(child_num),
child_num: interface::RustAtomicU64::new(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

child relationship should be perserved, so child_num should be kept

@@ -133,17 +133,8 @@ impl Cage {
/*
* exec() will only return if error happens
Copy link
Contributor

Choose a reason for hiding this comment

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

also add how's our exec in rawposix is different from linux and why are we doing in this way

zombies: interface::RustLock::new(cloned_zombies), // when a process exec-ed, its child relationship should be perserved
child_num: interface::RustAtomicU64::new(child_num),
child_num: interface::RustAtomicU64::new(0),
vmmap: interface::RustLock::new(Vmmap::new()), // memory is cleared after exec
Copy link
Contributor

Choose a reason for hiding this comment

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

the real memory address should also be cleaned up not just vmmap. Probably need to add an interface in mem.rs to do memory cleanup

@rennergade
Copy link
Contributor

Some modify with Wasmtime and Rawposix to support execve. So for right now we don't need to change cage anymore, we do exactly the same behavior with linux.

This isn't really a great description for the PR, ideally you want to list the changes you made and why

@JustinCappos
Copy link
Member

JustinCappos commented Feb 21, 2025 via email

@@ -5,3 +5,4 @@ int __execve (const char *__path, char *const __argv[], char *const __envp[])
{
return MAKE_SYSCALL(69, "syscall|execve", __path, __argv, __envp, NOTUSED, NOTUSED, NOTUSED);
}
weak_alias (__execve, execve)
Copy link
Contributor

Choose a reason for hiding this comment

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

let's make this strong alias rather than weak alias

@JustinCappos
Copy link
Member

JustinCappos commented Feb 21, 2025 via email

@robinyuan1002
Copy link
Collaborator Author

Is there ever a reason we need to use weak_alias? my understanding is that this isn't very portable.

On Fri, Feb 21, 2025 at 3:38 PM Qianxi Chen @.> wrote: @.* commented on this pull request. ------------------------------ In src/glibc/sysdeps/unix/sysv/linux/i386/execve.c <#113 (comment)> : > @@ -5,3 +5,4 @@ int __execve (const char __path, char const __argv[], char const __envp[]) { return MAKE_SYSCALL(69, "syscall|execve", __path, __argv, __envp, NOTUSED, NOTUSED, NOTUSED); } +weak_alias (__execve, execve) let's make this strong alias rather than weak alias — Reply to this email directly, view it on GitHub <#113 (review)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGRODY2FU747C3AABJ3TCT2Q6FFTAVCNFSM6AAAAABXSB7ABKVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDMMZUGE3TCNBZHA . You are receiving this because you commented.Message ID: @.>

I believe in this case both work, but strong alias is the best way

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.

5 participants