Re: [PATCH nf] netfilter: avoid erronous array bounds warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 24, 2018 at 02:10:04PM +0200, Florian Westphal wrote:
> Unfortunately some versions of gcc emit following warning:
>   $ make net/xfrm/xfrm_output.o
>   linux/compiler.h:252:20: warning: array subscript is above array bounds [-Warray-bounds]
>   hook_head = rcu_dereference(net->nf.hooks_arp[hook]);
>                             ^~~~~~~~~~~~~~~~~~~~~
> xfrm_output_resume passes skb_dst(skb)->ops->family as its 'pf' arg so compiler
> can't know that we'll never access hooks_arp[].
> (NFPROTO_IPV4 or NFPROTO_IPV6 are only possible cases).
> 
> Avoid this by adding an explicit WARN_ON_ONCE() check.
> 
> This patch has no effect if the family is a compile-time constant as gcc
> will remove the switch() construct entirely.

Applied, thanks Florian.



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux