rseq: error out on refcount overflow/underflow
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 11 Oct 2018 15:23:40 +0000 (11:23 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 11 Oct 2018 15:23:40 +0000 (11:23 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/rseq.c

index 7992b3122cc38ed934478a9616c0c86f39520ac5..172f4d986da3557248894ed433d1a98fdd279ae7 100644 (file)
@@ -25,6 +25,7 @@
 #include <syscall.h>
 #include <assert.h>
 #include <signal.h>
+#include <limits.h>
 
 #include <rseq/rseq.h>
 
@@ -103,6 +104,10 @@ int rseq_register_current_thread(void)
        sigset_t oldset;
 
        signal_off_save(&oldset);
+       if (__lib_rseq_abi.refcount == INT_MAX) {
+               ret = -1;
+               goto end;
+       }
        if (__lib_rseq_abi.refcount++)
                goto end;
        rc = sys_rseq(&__rseq_abi, sizeof(struct rseq), 0, RSEQ_SIG);
@@ -125,6 +130,10 @@ int rseq_unregister_current_thread(void)
        sigset_t oldset;
 
        signal_off_save(&oldset);
+       if (!__lib_rseq_abi.refcount) {
+               ret = -1;
+               goto end;
+       }
        if (--__lib_rseq_abi.refcount)
                goto end;
        rc = sys_rseq(&__rseq_abi, sizeof(struct rseq),
This page took 0.030603 seconds and 4 git commands to generate.