IB/rxe: Add a runtime check in alloc_index()
authorBart Van Assche <bart.vanassche@sandisk.com>
Tue, 10 Jan 2017 19:15:48 +0000 (11:15 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 8 Oct 2017 08:26:04 +0000 (10:26 +0200)
[ Upstream commit 642c7cbcaf2ffc1e27f67eda3dc47347ac5aff37 ]

Since index values equal to or above 'range' can trigger memory
corruption, complain if index >= range.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Andrew Boyer <andrew.boyer@dell.com>
Cc: Moni Shoua <monis@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/sw/rxe/rxe_pool.c

index 6bac071..ee26a1b 100644 (file)
@@ -274,6 +274,7 @@ static u32 alloc_index(struct rxe_pool *pool)
        if (index >= range)
                index = find_first_zero_bit(pool->table, range);
 
+       WARN_ON_ONCE(index >= range);
        set_bit(index, pool->table);
        pool->last = index;
        return index + pool->min_index;