Skip to content

Commit a661ed3

Browse files
ummakynesgregkh
authored andcommitted
netfilter: nft_payload: sanitize offset and length before calling skb_checksum()
[ Upstream commit d5953d6 ] If access to offset + length is larger than the skbuff length, then skb_checksum() triggers BUG_ON(). skb_checksum() internally subtracts the length parameter while iterating over skbuff, BUG_ON(len) at the end of it checks that the expected length to be included in the checksum calculation is fully consumed. Fixes: 7ec3f7b ("netfilter: nft_payload: add packet mangling support") Reported-by: Slavin Liu <slavin-ayu@qq.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent bcefc3c commit a661ed3

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

net/netfilter/nft_payload.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
306306
if ((priv->csum_type == NFT_PAYLOAD_CSUM_INET || priv->csum_flags) &&
307307
(priv->base != NFT_PAYLOAD_TRANSPORT_HEADER ||
308308
skb->ip_summed != CHECKSUM_PARTIAL)) {
309+
if (offset + priv->len > skb->len)
310+
goto err;
311+
309312
fsum = skb_checksum(skb, offset, priv->len, 0);
310313
tsum = csum_partial(src, priv->len, 0);
311314

0 commit comments

Comments
 (0)