Re: [PATCH v2] bpf: fix netfilter link comparison to handle unsigned flags

From: Alexei Starovoitov

Date: Sun Sep 21 2025 - 22:21:25 EST


On Sun, Sep 21, 2025 at 7:17 PM Haofeng Li <920484857@xxxxxx> wrote:
>
> From: lihaofeng <lihaofeng@xxxxxxxxxx>
>
> The original implementation of netfilter_link_compar() used subtraction
> to compare the netfilter.flags field, which is an unsigned type.
> This could result in incorrect comparison results when the unsigned
> value wrapped around due to underflow.
>
> Changed the comparison logic for flags to use explicit conditional
> checks (similar to how priority is handled) instead of subtraction,
> ensuring correct negative/zero/positive return values regardless of
> the underlying data type.
>
> This fixes potential sorting issues when using this comparison function
> with algorithms like qsort() or bsearch().
>
> Signed-off-by: lihaofeng <lihaofeng@xxxxxxxxxx>

Nack. We don't fix theoretical issues.

pw-bot: cr