Re: [PATCH] bpf: fix netfilter link comparison to handle unsigned flags
From: Alexei Starovoitov
Date: Sun Sep 21 2025 - 22:20:50 EST
On Sun, Sep 21, 2025 at 6:52 PM Haofeng Li <920484857@xxxxxx> wrote:
>
> Thank you for your review and feedback.
>
> >Did you actually observe an overflow producing an error when sorting,
> >here? Or did you run into some compiler warning?
>
> I did not encounter a runtime error or a compiler warning caused by this potential overflow.
> The issue was identified during code review as a potential risk,
> considering the theoretical possibility of wrap-around with unsigned subtraction,
> which prompted me to submit this patch for code robustness.
>
> >This being said, I don't mind making the code cleaner for these
> >comparisons, but we should probably treat all three attributes the same,
> >and update the rest of the function as well?
>
> Thank you for pointing this out.
> I will prepare a v2 patch that thoroughly reviews and updates the comparison
> logic for all three fields (netfilter.pf, netfilter.hooknum, and netfilter.flags),
> replacing all subtraction-based comparisons with explicit conditional checks.
Don't. We don't fix theoretical issues.