• Matthew Wilcox's avatar
    idr: Fix handling of IDs above INT_MAX · 4b0ad076
    Matthew Wilcox authored
    Khalid reported that the kernel selftests are currently failing:
    
    selftests: test_bpf.sh
    ========================================
    test_bpf: [FAIL]
    not ok 1..8 selftests:  test_bpf.sh [FAIL]
    
    He bisected it to 6ce711f2 ("idr: Make
    1-based IDRs more efficient").
    
    The root cause is doing a signed comparison in idr_alloc_u32() instead
    of an unsigned comparison.  I went looking for any similar problems and
    found a couple (which would each result in the failure to warn in two
    situations that aren't supposed to happen).
    
    I knocked up a few test-cases to prove that I was right and added them
    to the test-suite.
    Reported-by: 's avatarKhalid Aziz <khalid.aziz@oracle.com>
    Tested-by: 's avatarKhalid Aziz <khalid.aziz@oracle.com>
    Signed-off-by: 's avatarMatthew Wilcox <mawilcox@microsoft.com>
    4b0ad076
idr.c 18.6 KB