Patch "netfilter: nft_payload: rebuild vlan header on h_proto access" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    netfilter: nft_payload: rebuild vlan header on h_proto access

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     netfilter-nft_payload-rebuild-vlan-header-on-h_proto.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit effc6a397c615d3a9e1ddc135daacbc643cf13ff
Author: Florian Westphal <fw@xxxxxxxxx>
Date:   Fri Sep 29 10:42:10 2023 +0200

    netfilter: nft_payload: rebuild vlan header on h_proto access
    
    [ Upstream commit af84f9e447a65b4b9f79e7e5d69e19039b431c56 ]
    
    nft can perform merging of adjacent payload requests.
    This means that:
    
    ether saddr 00:11 ... ether type 8021ad ...
    
    is a single payload expression, for 8 bytes, starting at the
    ethernet source offset.
    
    Check that offset+length is fully within the source/destination mac
    addersses.
    
    This bug prevents 'ether type' from matching the correct h_proto in case
    vlan tag got stripped.
    
    Fixes: de6843be3082 ("netfilter: nft_payload: rebuild vlan header when needed")
    Reported-by: David Ward <david.ward@xxxxxxxxxx>
    Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
    Stable-dep-of: 33c563ebf8d3 ("netfilter: nft_payload: skbuff vlan metadata mangle support")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/netfilter/nft_payload.c b/net/netfilter/nft_payload.c
index b1745304dbd22..697566e4ae759 100644
--- a/net/netfilter/nft_payload.c
+++ b/net/netfilter/nft_payload.c
@@ -110,6 +110,17 @@ static int nft_payload_inner_offset(const struct nft_pktinfo *pkt)
 	return pkt->inneroff;
 }
 
+static bool nft_payload_need_vlan_copy(const struct nft_payload *priv)
+{
+	unsigned int len = priv->offset + priv->len;
+
+	/* data past ether src/dst requested, copy needed */
+	if (len > offsetof(struct ethhdr, h_proto))
+		return true;
+
+	return false;
+}
+
 void nft_payload_eval(const struct nft_expr *expr,
 		      struct nft_regs *regs,
 		      const struct nft_pktinfo *pkt)
@@ -128,7 +139,7 @@ void nft_payload_eval(const struct nft_expr *expr,
 			goto err;
 
 		if (skb_vlan_tag_present(skb) &&
-		    priv->offset >= offsetof(struct ethhdr, h_proto)) {
+		    nft_payload_need_vlan_copy(priv)) {
 			if (!nft_payload_copy_vlan(dest, skb,
 						   priv->offset, priv->len))
 				goto err;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux