Simplify struct inject_opts.rval semantics
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 9 Feb 2017 22:26:14 +0000 (22:26 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 9 Feb 2017 22:26:14 +0000 (22:26 +0000)
Drop use of INJECT_OPTS_RVAL_DISABLE special inject_opts.rval value,
INJECT_OPTS_RVAL_DEFAULT is enough.

* defs.h (INJECT_OPTS_RVAL_DISABLE): Remove.
* qualify.c (qualify_inject_common): Do not replace
INJECT_OPTS_RVAL_DEFAULT with INJECT_OPTS_RVAL_DISABLE
in inject_opts.rval.
* syscall.c (tamper_with_syscall_entering): Check
for INJECT_OPTS_RVAL_DEFAULT instead of INJECT_OPTS_RVAL_DISABLE.

defs.h
qualify.c
syscall.c

diff --git a/defs.h b/defs.h
index 59c9e0ec004a3f8bfb8f0b487df68b10a5453c85..b333a2218b2da5d59196202b400e11f65d3904b4 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -206,7 +206,6 @@ struct inject_opts {
 
 #define MAX_ERRNO_VALUE                        4095
 #define INJECT_OPTS_RVAL_DEFAULT       (-(MAX_ERRNO_VALUE + 1))
-#define INJECT_OPTS_RVAL_DISABLE       (INJECT_OPTS_RVAL_DEFAULT - 1)
 
 /* Trace Control Block */
 struct tcb {
index 4ce98694287b11fd821406973707c1a3ee45c9e1..bb4aefe3806fe706a6fa05267c9eb111798e8e22 100644 (file)
--- a/qualify.c
+++ b/qualify.c
@@ -522,16 +522,13 @@ qualify_inject_common(const char *const str,
                error_msg_and_die("invalid %s '%s'", description, str);
        }
 
-       if (opts.rval == INJECT_OPTS_RVAL_DEFAULT) {
-               /* If neither retval nor error is specified, then ... */
-               if (opts.signo) {
-                       /* disable syscall fault injection if signal is specified. */
-                       opts.rval = INJECT_OPTS_RVAL_DISABLE;
-               } else if (fault_tokens_only) {
-                       /* default error code for fault= syntax is ENOSYS */
+       /* If neither of retval, error, or signal is specified, then ... */
+       if (opts.rval == INJECT_OPTS_RVAL_DEFAULT && !opts.signo) {
+               if (fault_tokens_only) {
+                       /* in fault= syntax the default error code is ENOSYS. */
                        opts.rval = -ENOSYS;
                } else {
-                       /* an error has to be specified in inject= syntax. */
+                       /* in inject= syntax this is not allowed. */
                        error_msg_and_die("invalid %s '%s'", description, str);
                }
        }
index 714fee715b005eea3a065ff9b893659aaf30623a..c0407ed509b707580a2aa8df25b374f2ee3e0cff 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -596,7 +596,7 @@ tamper_with_syscall_entering(struct tcb *tcp, unsigned int *signo)
 
        if (opts->signo > 0)
                *signo = opts->signo;
-       if (opts->rval != INJECT_OPTS_RVAL_DISABLE && !arch_set_scno(tcp, -1))
+       if (opts->rval != INJECT_OPTS_RVAL_DEFAULT && !arch_set_scno(tcp, -1))
                tcp->flags |= TCB_TAMPERED;
 
        return 0;