2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

compel: always pass user_fpregs_struct_t to compel_get_task_regs()

All architectures create on-stack structure for floating point save area
in compel_get_task_regs() if the caller passes NULL rather than a valid
pointer.

The only place that calls compel_get_task_regs() with NULL for floating
point save area is parasite_start_daemon() and it is simpler to define
this strucuture on stack of parasite_start_daemon().

The availability of floating point save data is required in
parasite_start_daemon() to detect shadow stack presence early during
parasite infection and will be used in later patches.

Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
This commit is contained in:
Mike Rapoport (IBM) 2022-05-15 10:04:16 +03:00 committed by Andrei Vagin
parent 0b8c51eaad
commit 17f4dd0959
7 changed files with 8 additions and 13 deletions

View File

@ -59,10 +59,9 @@ int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigfr
return 0; return 0;
} }
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save, int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *fpsimd, save_regs_t save,
void *arg, __maybe_unused unsigned long flags) void *arg, __maybe_unused unsigned long flags)
{ {
user_fpregs_struct_t tmp, *fpsimd = ext_regs ? ext_regs : &tmp;
struct iovec iov; struct iovec iov;
int ret; int ret;

View File

@ -65,10 +65,9 @@ int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigfr
} }
#define PTRACE_GETVFPREGS 27 #define PTRACE_GETVFPREGS 27
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save, int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *vfp, save_regs_t save,
void *arg, __maybe_unused unsigned long flags) void *arg, __maybe_unused unsigned long flags)
{ {
user_fpregs_struct_t tmp, *vfp = ext_regs ? ext_regs : &tmp;
int ret = -1; int ret = -1;
pr_info("Dumping GP/FPU registers for %d\n", pid); pr_info("Dumping GP/FPU registers for %d\n", pid);

View File

@ -119,10 +119,9 @@ int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigfr
return 0; return 0;
} }
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save, int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *xs, save_regs_t save,
void *arg, __maybe_unused unsigned long flags) void *arg, __maybe_unused unsigned long flags)
{ {
user_fpregs_struct_t xsave = {}, *xs = ext_regs ? ext_regs : &xsave;
int ret = -1; int ret = -1;
pr_info("Dumping GP/FPU registers for %d\n", pid); pr_info("Dumping GP/FPU registers for %d\n", pid);

View File

@ -391,10 +391,9 @@ static int __get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_stru
return 0; return 0;
} }
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save, int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs, save_regs_t save,
void *arg, __maybe_unused unsigned long flags) void *arg, __maybe_unused unsigned long flags)
{ {
user_fpregs_struct_t tmp, *fpregs = ext_regs ? ext_regs : &tmp;
int ret; int ret;
ret = __get_task_regs(pid, regs, fpregs); ret = __get_task_regs(pid, regs, fpregs);

View File

@ -293,10 +293,9 @@ static int s390_disable_ri_bit(pid_t pid, user_regs_struct_t *regs)
/* /*
* Prepare task registers for restart * Prepare task registers for restart
*/ */
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save, int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs, save_regs_t save,
void *arg, __maybe_unused unsigned long flags) void *arg, __maybe_unused unsigned long flags)
{ {
user_fpregs_struct_t tmp, *fpregs = ext_regs ? ext_regs : &tmp;
struct iovec iov; struct iovec iov;
int rewind; int rewind;

View File

@ -345,10 +345,9 @@ static int corrupt_extregs(pid_t pid)
return 0; return 0;
} }
int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save, int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *xs, save_regs_t save,
void *arg, unsigned long flags) void *arg, unsigned long flags)
{ {
user_fpregs_struct_t xsave = {}, *xs = ext_regs ? ext_regs : &xsave;
int ret = -1; int ret = -1;
pr_info("Dumping general registers for %d in %s mode\n", pid, user_regs_native(regs) ? "native" : "compat"); pr_info("Dumping general registers for %d in %s mode\n", pid, user_regs_native(regs) ? "native" : "compat");

View File

@ -739,6 +739,7 @@ static int parasite_start_daemon(struct parasite_ctl *ctl)
{ {
pid_t pid = ctl->rpid; pid_t pid = ctl->rpid;
struct infect_ctx *ictx = &ctl->ictx; struct infect_ctx *ictx = &ctl->ictx;
user_fpregs_struct_t ext_regs;
/* /*
* Get task registers before going daemon, since the * Get task registers before going daemon, since the
@ -746,7 +747,7 @@ static int parasite_start_daemon(struct parasite_ctl *ctl)
* while in daemon it is not such. * while in daemon it is not such.
*/ */
if (compel_get_task_regs(pid, &ctl->orig.regs, NULL, ictx->save_regs, ictx->regs_arg, ictx->flags)) { if (compel_get_task_regs(pid, &ctl->orig.regs, &ext_regs, ictx->save_regs, ictx->regs_arg, ictx->flags)) {
pr_err("Can't obtain regs for thread %d\n", pid); pr_err("Can't obtain regs for thread %d\n", pid);
return -1; return -1;
} }