Re: [PATCH 80/82] xen-netback: Refactor intentional wrap-around test

From: Kees Cook
Date: Tue Jan 23 2024 - 16:32:44 EST


On Tue, Jan 23, 2024 at 08:55:44AM +0100, Jan Beulich wrote:
> On 23.01.2024 01:27, Kees Cook wrote:
> > --- a/drivers/net/xen-netback/hash.c
> > +++ b/drivers/net/xen-netback/hash.c
> > @@ -345,7 +345,7 @@ u32 xenvif_set_hash_mapping(struct xenvif *vif, u32 gref, u32 len,
> > .flags = GNTCOPY_source_gref
> > }};
> >
> > - if ((off + len < off) || (off + len > vif->hash.size) ||
> > + if ((add_would_overflow(off, len)) || (off + len > vif->hash.size) ||
>
> I'm not maintainer of this code, but if I was I would ask that the
> excess parentheses be removed, to improve readability.

Good call. I will adjust that. Thanks!

-Kees

--
Kees Cook