Skip to content

Commit c842743

Browse files
RyderCRDkuba-moo
authored andcommitted
net: sched: act_csum: validate nested VLAN headers
tcf_csum_act() walks nested VLAN headers directly from skb->data when an skb still carries in-payload VLAN tags. The current code reads vlan->h_vlan_encapsulated_proto and then pulls VLAN_HLEN bytes without first ensuring that the full VLAN header is present in the linear area. If only part of an inner VLAN header is linearized, accessing h_vlan_encapsulated_proto reads past the linear area, and the following skb_pull(VLAN_HLEN) may violate skb invariants. Fix this by requiring pskb_may_pull(skb, VLAN_HLEN) before accessing and pulling each nested VLAN header. If the header still is not fully available, drop the packet through the existing error path. Fixes: 2ecba2d ("net: sched: act_csum: Fix csum calc for tagged packets") Reported-by: Yifan Wu <yifanwucs@gmail.com> Reported-by: Juefei Pu <tomapufckgml@gmail.com> Co-developed-by: Yuan Tan <yuantan098@gmail.com> Signed-off-by: Yuan Tan <yuantan098@gmail.com> Suggested-by: Xin Liu <bird@lzu.edu.cn> Tested-by: Ren Wei <enjou1224z@gmail.com> Signed-off-by: Ruide Cao <caoruide123@gmail.com> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/22df2fcb49f410203eafa5d97963dd36089f4ecf.1774892775.git.caoruide123@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 51f4e09 commit c842743

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

net/sched/act_csum.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,12 @@ TC_INDIRECT_SCOPE int tcf_csum_act(struct sk_buff *skb,
604604
protocol = skb->protocol;
605605
orig_vlan_tag_present = true;
606606
} else {
607-
struct vlan_hdr *vlan = (struct vlan_hdr *)skb->data;
607+
struct vlan_hdr *vlan;
608608

609+
if (!pskb_may_pull(skb, VLAN_HLEN))
610+
goto drop;
611+
612+
vlan = (struct vlan_hdr *)skb->data;
609613
protocol = vlan->h_vlan_encapsulated_proto;
610614
skb_pull(skb, VLAN_HLEN);
611615
skb_reset_network_header(skb);

0 commit comments

Comments
 (0)