Kal Conley 1ba83f505c xsk: Elide base_addr comparison in xp_unaligned_validate_desc
Remove redundant (base_addr >= pool->addrs_cnt) comparison from the
conditional.

In particular, addr is computed as:

    addr = base_addr + offset

... where base_addr and offset are stored as 48-bit and 16-bit unsigned
integers, respectively. The above sum cannot overflow u64 since base_addr
has a maximum value of 0x0000ffffffffffff and offset has a maximum value
of 0xffff (implying a maximum sum of 0x000100000000fffe). Since overflow
is impossible, it follows that addr >= base_addr.

Now if (base_addr >= pool->addrs_cnt), then clearly:

    addr >= base_addr
         >= pool->addrs_cnt

Thus, (base_addr >= pool->addrs_cnt) implies (addr >= pool->addrs_cnt).
Subsequently, the former comparison is unnecessary in the conditional
since for any boolean expressions A and B, (A || B) && (A -> B) is
equivalent to B.

Signed-off-by: Kal Conley <kal.conley@dectris.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20230411130025.19704-1-kal.conley@dectris.com
2023-04-13 15:00:11 +02:00
..
2023-01-12 17:02:20 -06:00
2023-02-21 18:24:12 -08:00
2023-02-13 09:30:14 +00:00
2023-02-21 18:24:12 -08:00
2023-02-22 14:47:20 -08:00
2023-02-21 18:24:12 -08:00
2023-02-21 18:24:12 -08:00
2023-03-08 13:21:47 +00:00
2023-02-21 18:24:12 -08:00
2023-02-10 17:51:27 -08:00
2022-08-22 14:26:30 +01:00
2023-02-21 18:24:12 -08:00