From: Pablo Neira Ayuso Date: Wed, 11 Jan 2023 16:07:33 +0000 (+0100) Subject: netfilter: nft_payload: incorrect arithmetics when fetching VLAN header bits X-Git-Tag: archive/raspbian/5.10.162-1+rpi1^2~15 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=50ea5b78666e3482aa357d01c539bca1ee93af21;p=linux.git netfilter: nft_payload: incorrect arithmetics when fetching VLAN header bits Origin: https://git.kernel.org/linus/696e1a48b1a1b01edad542a1ef293665864a4dd0 Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2023-0179 If the offset + length goes over the ethernet + vlan header, then the length is adjusted to copy the bytes that are within the boundaries of the vlan_ethhdr scratchpad area. The remaining bytes beyond ethernet + vlan header are copied directly from the skbuff data area. Fix incorrect arithmetic operator: subtract, not add, the size of the vlan header in case of double-tagged packets to adjust the length accordingly to address CVE-2023-0179. Reported-by: Davide Ornaghi Fixes: f6ae9f120dad ("netfilter: nft_payload: add C-VLAN support") Signed-off-by: Pablo Neira Ayuso Gbp-Pq: Topic bugfix/all Gbp-Pq: Name netfilter-nft_payload-incorrect-arithmetics-when-fet.patch --- diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c index 551e0d6cf63..74c220eeec1 100644 --- a/net/netfilter/nft_payload.c +++ b/net/netfilter/nft_payload.c @@ -62,7 +62,7 @@ nft_payload_copy_vlan(u32 *d, const struct sk_buff *skb, u8 offset, u8 len) return false; if (offset + len > VLAN_ETH_HLEN + vlan_hlen) - ethlen -= offset + len - VLAN_ETH_HLEN + vlan_hlen; + ethlen -= offset + len - VLAN_ETH_HLEN - vlan_hlen; memcpy(dst_u8, vlanh + offset - vlan_hlen, ethlen);