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

Enable creation of host tasks with new tgid in LKL. #553

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

Conversation

rodionov
Copy link

@rodionov rodionov commented Jan 8, 2025

Hi @tavip, @thehajime,

Here is a change by @abcSup which enables creation of new processes in LKL (tasks with new thread group leader id). At the moment in LKL all the host tasks share the same tgid field and, thus, are considered to be part of the same process. With this change it will be possible to "emulate" multiple processes running on top of LKL. These processes would still share the same virtual address space and file descriptor table but would have different thread group leaders.

This functionality is needed to enable Android Binder fuzzing which restricts threads to sending transactions to each other when they belong to the same process (i.e. share the same tgid).

The approach taken here is very similar to okuoku@3847b0a by @okuoku (context in #551 (comment))

Let us know what you think.

Thanks,
Eugene

Introduce a new LKL-specific syscall `new_thread_group_leader` which
creates a new task_struct for the host thread with new tgid. This
should be the very first LKL syscall invoked by a newly spawned thread
which wants to be threat group leader.

Upon return from the syscall LKL creates a new tast_struct with a new
tgid for the calling thread. The parent of the thread invoking the
syscall (as returned via `lkl_sys_getppid`) is equal to pid of the
thread which spawned the child thread.

The child thread is cloned from the parent using CLONE_VM, CLONE_FS,
CLONE_FILES and CLONE_SIGHAND flags.

Signed-off-by: Zi Fan Tan <[email protected]>
Signed-off-by: Eugene Rodionov <[email protected]>
@rodionov rodionov requested review from tavip and thehajime January 8, 2025 04:22
Copy link
Member

@tavip tavip left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @rodionov !

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.

3 participants