Skip to content

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

Merged
thehajime merged 1 commit into
lkl:masterfrom
rodionov:new_tgid
Jan 13, 2025
Merged

Enable creation of host tasks with new tgid in LKL.#553
thehajime merged 1 commit into
lkl:masterfrom
rodionov:new_tgid

Conversation

@rodionov

@rodionov rodionov commented Jan 8, 2025

Copy link
Copy Markdown

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 <zifantan@google.com>
Signed-off-by: Eugene Rodionov <rodionov@google.com>
@rodionov
rodionov requested review from tavip and thehajime January 8, 2025 04:22

@tavip tavip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks @rodionov !

@thehajime

Copy link
Copy Markdown
Member

LGTM, thanks for the patch !

@thehajime
thehajime merged commit 74da3bd into lkl:master Jan 13, 2025
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