From c5f9dbb011aa800427fe53c5bec75632909d4b92 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 20 Oct 2016 12:18:01 -0700 Subject: [PATCH] Fix userquota_compare() function The AVL tree compare function requires that either -1, 0, or 1 be returned. However the strcmp() function only guarantees that a negative, zero, or positive value is returned. Therefore, the return value of strcmp() needs to be sanitized with AVL_ISIGN. This was initially overlooked because the x86_64 implementation of strcmp() happens to only returns the allowed values. This was observed on an aarch64 platform which behaves correctly but differently as described above. Signed-off-by: Brian Behlendorf --- module/zfs/dmu_objset.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c index cce3e732cbda..50b758f1e809 100644 --- a/module/zfs/dmu_objset.c +++ b/module/zfs/dmu_objset.c @@ -1355,12 +1355,15 @@ userquota_compare(const void *l, const void *r) { const userquota_node_t *luqn = l; const userquota_node_t *ruqn = r; + int rv; /* * NB: can only access uqn_id because userquota_update_cache() doesn't * pass in an entire userquota_node_t. */ - return (strcmp(luqn->uqn_id, ruqn->uqn_id)); + rv = (strcmp(luqn->uqn_id, ruqn->uqn_id)); + + return (AVL_ISIGN(rv)); } static void