Skip to content

Commit

Permalink
cr-restore: rseq: use glibc-specific way to unregister only as fallback
Browse files Browse the repository at this point in the history
Let's use dynamic approach to detect built-in *libc rseq in all cases,
and "old" static approach as a fallback path if the user kernel
lacks support of ptrace_get_rseq_conf feature.

Suggested-by: Florian Weimer <[email protected]>
Signed-off-by: Alexander Mikhalitsyn <[email protected]>
  • Loading branch information
mihalicyn authored and avagin committed Aug 8, 2022
1 parent f0b0a64 commit db9781e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions criu/cr-restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -3088,31 +3088,28 @@ static int prep_rseq(struct rst_rseq_param *rseq, ThreadCoreEntry *tc)
return 0;
}

#if defined(__GLIBC__) && defined(RSEQ_SIG)
static void prep_libc_rseq_info(struct rst_rseq_param *rseq)
{
if (!kdat.has_rseq) {
rseq->rseq_abi_pointer = 0;
return;
}

rseq->rseq_abi_pointer = encode_pointer(__criu_thread_pointer() + __rseq_offset);
rseq->rseq_abi_size = __rseq_size;
rseq->signature = RSEQ_SIG;
}
if (!kdat.has_ptrace_get_rseq_conf) {
#if defined(__GLIBC__) && defined(RSEQ_SIG)
rseq->rseq_abi_pointer = encode_pointer(__criu_thread_pointer() + __rseq_offset);
rseq->rseq_abi_size = __rseq_size;
rseq->signature = RSEQ_SIG;
#else
static void prep_libc_rseq_info(struct rst_rseq_param *rseq)
{
if (!kdat.has_rseq || !kdat.has_ptrace_get_rseq_conf) {
rseq->rseq_abi_pointer = 0;
#endif
return;
}

rseq->rseq_abi_pointer = kdat.libc_rseq_conf.rseq_abi_pointer;
rseq->rseq_abi_size = kdat.libc_rseq_conf.rseq_abi_size;
rseq->signature = kdat.libc_rseq_conf.signature;
}
#endif

static rlim_t decode_rlim(rlim_t ival)
{
Expand Down

0 comments on commit db9781e

Please sign in to comment.