• J
    treewide: use get_random_u32_inclusive() when possible · e8a533cb
    Jason A. Donenfeld 提交于
    These cases were done with this Coccinelle:
    
    @@
    expression H;
    expression L;
    @@
    - (get_random_u32_below(H) + L)
    + get_random_u32_inclusive(L, H + L - 1)
    
    @@
    expression H;
    expression L;
    expression E;
    @@
      get_random_u32_inclusive(L,
      H
    - + E
    - - E
      )
    
    @@
    expression H;
    expression L;
    expression E;
    @@
      get_random_u32_inclusive(L,
      H
    - - E
    - + E
      )
    
    @@
    expression H;
    expression L;
    expression E;
    expression F;
    @@
      get_random_u32_inclusive(L,
      H
    - - E
      + F
    - + E
      )
    
    @@
    expression H;
    expression L;
    expression E;
    expression F;
    @@
      get_random_u32_inclusive(L,
      H
    - + E
      + F
    - - E
      )
    
    And then subsequently cleaned up by hand, with several automatic cases
    rejected if it didn't make sense contextually.
    Reviewed-by: NKees Cook <keescook@chromium.org>
    Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> # for infiniband
    Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
    e8a533cb
tcp_input.c 202.0 KB