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

support user set remote mmap vma address #2461

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compel/include/uapi/infect.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ struct infect_ctx {
open_proc_fn open_proc;

int log_fd; /* fd for parasite code to send messages to */
unsigned long remote_map_addr; /* User-specified address where to mmap parasitic code, default not set */
};

extern struct infect_ctx *compel_infect_ctx(struct parasite_ctl *);
Expand Down
8 changes: 6 additions & 2 deletions compel/src/lib/infect.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@
uint8_t orig_code[MEMFD_FNAME_SZ] = MEMFD_FNAME;
pid_t pid = ctl->rpid;
long sret = -ENOSYS;
int ret, fd, lfd;
int ret, fd, lfd, remote_flags;

if (ctl->ictx.flags & INFECT_NO_MEMFD)
return 1;
Expand Down Expand Up @@ -860,7 +860,11 @@
goto err_cure;
}

ctl->remote_map = remote_mmap(ctl, NULL, size, remote_prot, MAP_FILE | MAP_SHARED, fd, 0);
remote_flags = MAP_FILE | MAP_SHARED;
if (ctl->ictx.remote_map_addr){

Check warning on line 864 in compel/src/lib/infect.c

View workflow job for this annotation

GitHub Actions / build

remote_flags |= MAP_FIXED_NOREPLACE;
}
ctl->remote_map = remote_mmap(ctl, (void *)ctl->ictx.remote_map_addr, size, remote_prot, remote_flags, fd, 0);
if (!ctl->remote_map) {
pr_err("Can't rmap memfd for parasite blob\n");
goto err_curef;
Expand Down
Loading