提交 18e1d836 编写于 作者: W Wei Yongjun 提交者: Gerrit Renker

dccp: Fix incorrect length check for ICMPv4 packets

Unlike TCP, which only needs 8 octets of original packet data, DCCP requires
minimally 12 or 16 bytes for ICMP-payload sequence number checks.

This patch replaces the insufficient length constant of 8 with a two-stage
test, making sure that 12 bytes are available, before computing the basic
header length required for sequence number checks.
Signed-off-by: NWei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: NGerrit Renker <gerrit@erg.abdn.ac.uk>
上级 e0bcfb0c
...@@ -196,8 +196,8 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk, ...@@ -196,8 +196,8 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk,
static void dccp_v4_err(struct sk_buff *skb, u32 info) static void dccp_v4_err(struct sk_buff *skb, u32 info)
{ {
const struct iphdr *iph = (struct iphdr *)skb->data; const struct iphdr *iph = (struct iphdr *)skb->data;
const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + const u8 offset = iph->ihl << 2;
(iph->ihl << 2)); const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + offset);
struct dccp_sock *dp; struct dccp_sock *dp;
struct inet_sock *inet; struct inet_sock *inet;
const int type = icmp_hdr(skb)->type; const int type = icmp_hdr(skb)->type;
...@@ -207,7 +207,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info) ...@@ -207,7 +207,8 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
int err; int err;
struct net *net = dev_net(skb->dev); struct net *net = dev_net(skb->dev);
if (skb->len < (iph->ihl << 2) + 8) { if (skb->len < offset + sizeof(*dh) ||
skb->len < offset + __dccp_basic_hdr_len(dh)) {
ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS); ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS);
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册