From db9781ef06dc1b205ae4ef134dde056fad4c8c31 Mon Sep 17 00:00:00 2001 From: Alexander Mikhalitsyn Date: Wed, 20 Jul 2022 15:17:35 +0300 Subject: [PATCH] cr-restore: rseq: use glibc-specific way to unregister only as fallback 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 Signed-off-by: Alexander Mikhalitsyn --- criu/cr-restore.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/criu/cr-restore.c b/criu/cr-restore.c index 5b5b41dfc8..919d10ab57 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -3088,7 +3088,6 @@ 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) { @@ -3096,15 +3095,14 @@ static void prep_libc_rseq_info(struct rst_rseq_param *rseq) 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; } @@ -3112,7 +3110,6 @@ static void prep_libc_rseq_info(struct rst_rseq_param *rseq) 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) {