summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2015-07-06 11:49:19 -0400
committerPaul Moore <pmoore@redhat.com>2015-07-06 11:49:19 -0400
commita967e9dd328881bfefda2b1aa112c95f0b847935 (patch)
treec1e1a0b097795c08ca1c5cc41d6885ae551ca193
parent4dad8407a98f1f21d62481f5271088c79338bfd6 (diff)
downloadlibseccomp-a967e9dd328881bfefda2b1aa112c95f0b847935.tar.gz
db: fix braino in _db_node_mask_fixup()
If the mask is 0 and we do a masked compare we shouldn't "optimize" this case to a compare against zero. "(arg & 0) eq 0" != "(arg & ~0) eq 0". The former is a tautology while the latter depends on the value of "arg". Just mask "datum" instead to fix this bug. We'll do an unnecessary runtime test for the tautology in this case but follow up patches will take care of this. This fixes the failing test cases of 12-sim-basic_masked_ops with 64 bit argument values. Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Paul Moore <pmoore@redhat.com> (imported from commit ccaf7d240c2fe034a323af2783ddec6297ae37e6)
-rw-r--r--src/db.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/db.c b/src/db.c
index ab079db..d6580ee 100644
--- a/src/db.c
+++ b/src/db.c
@@ -828,17 +828,12 @@ int db_syscall_priority(struct db_filter *db,
* Fixup the node based on the op/mask
* @param node the chain node
*
- * Apply some simplifications based on the comparison op and mask value.
+ * Ensure the datum is masked as well.
*
*/
static void _db_node_mask_fixup(struct db_arg_chain_tree *node)
{
- if (node->op == SCMP_CMP_MASKED_EQ && node->mask == 0) {
- node->op = SCMP_CMP_EQ;
- node->mask = ARG_MASK_MAX;
- node->datum = 0;
- } else
- node->datum &= node->mask;
+ node->datum &= node->mask;
}
/**