Skip to content

Commit d5953d6

Browse files
committed
netfilter: nft_payload: sanitize offset and length before calling skb_checksum()
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 <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 4ed234f commit d5953d6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/netfilter/nft_payload.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,9 @@ static void nft_payload_set_eval(const struct nft_expr *expr,
904904
((priv->base != NFT_PAYLOAD_TRANSPORT_HEADER &&
905905
priv->base != NFT_PAYLOAD_INNER_HEADER) ||
906906
skb->ip_summed != CHECKSUM_PARTIAL)) {
907+
if (offset + priv->len > skb->len)
908+
goto err;
909+
907910
fsum = skb_checksum(skb, offset, priv->len, 0);
908911
tsum = csum_partial(src, priv->len, 0);
909912

0 commit comments

Comments
 (0)