| Date | Fri, 14 May 2021 11:34:39 +0200 | From | Pavel Machek <> | Subject | Re: [PATCH 5.10 424/530] cxgb4: Fix unintentional sign extension issues |
| |
Hi!
> From: Colin Ian King <colin.king@canonical.com>
> The shifting of the u8 integers f->fs.nat_lip[] by 24 bits to > the left will be promoted to a 32 bit signed int and then > sign-extended to a u64. In the event that the top bit of the u8 > is set then all then all the upper 32 bits of the u64 end up as > also being set because of the sign-extension. Fix this by > casting the u8 values to a u64 before the 24 bit left shift.
Should we really use -stable series for beta-testing patches going to -rc1? Because that's what Sasha is effectively doing.
> Addresses-Coverity: ("Unintended sign extension") > Fixes: 12b276fbf6e0 ("cxgb4: add support to create hash filters") > Signed-off-by: Colin Ian King <colin.king@canonical.com> > Signed-off-by: David S. Miller <davem@davemloft.net> > Signed-off-by: Sasha Levin <sashal@kernel.org>
> set_tcb_field(adap, f, tid, TCB_RX_FRAG3_LEN_RAW_W, > WORD_MASK, f->fs.nat_lip[3] | > f->fs.nat_lip[2] << 8 | > f->fs.nat_lip[1] << 16 | > - f->fs.nat_lip[0] << 24, 1); > + (u64)f->fs.nat_lip[0] << 25, 1); > } > }
This one is wrong.
Best regards, Pavel -- http://www.livejournal.com/~pavelmachek [unhandled content-type:application/pgp-signature] |