netfilter: check the length of the data before dereferencing it
Subsystems (3)
PATCH 1/1 netfilter: check the length of the data before dereferencing it
We should check the length of the data before dereferencing it when parsing the TCP options.
--- net/netfilter/nf_conntrack_proto_tcp.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/nf_conntrack_proto_tcp.c +4 -0
@@ -404,6 +404,8 @@ static void tcp_options(const struct sk_buff *skb, length--;continue ;default : +if (length <2 ) +return ; opsize=*ptr++;if (opsize <2 )/* "silly options" */ return ;
@@ -464,6 +466,8 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff, length--;continue ;default : +if (length <2 ) +return ; opsize = *ptr++;if (opsize <2 )/* "silly options" */ return ;
Pablo Neira Ayuso
maintainerQuoted 12 lines · Changli Gao
We should check the length of the data before dereferencing it when parsing the TCP options.
Signed-off-by Changli Gao <[email protected]>--- net/netfilter/nf_conntrack_proto_tcp.c | 4 ++++ 1 file changed, 4 insertions(+)net/netfilter/nf_conntrack_proto_tcp.c +0
-0
net/netfilter/nf_conntrack_proto_tcp.c static void tcp_options(const struct sk_buff *skb, · line 411
Quoted 8 lines
net/netfilter/nf_conntrack_proto_tcp.c +2
-0@@ -404,6 +404,8 @@ static void tcp_options(const struct sk_buff *skb, length--;continue ;default : +if (length <2 ) +return ; opsize=*ptr++;if (opsize <2 )/* "silly options" */ return ;
length is always multiple of 4:
int length = (tcph->doff*4) - sizeof(struct tcphdr);
Quoted 24 lines · Pablo Neira Ayuso
Quoted 12 lines · Changli Gao
We should check the length of the data before dereferencing it when parsing the TCP options.
Signed-off-by Changli Gao <[email protected]>--- net/netfilter/nf_conntrack_proto_tcp.c | 4 ++++ 1 file changed, 4 insertions(+)net/netfilter/nf_conntrack_proto_tcp.c +0
-0net/netfilter/nf_conntrack_proto_tcp.c static void tcp_options(const struct sk_buff *skb, · line 411
Quoted 8 lines
net/netfilter/nf_conntrack_proto_tcp.c +2
-0@@ -404,6 +404,8 @@ static void tcp_options(const struct sk_buff *skb, length--;continue ;default : +if (length <2 ) +return ; opsize=*ptr++;if (opsize <2 )/* "silly options" */ return ;length is always multiple of 4:
Quoted 2 lines
int length = (tcph->doff*4) - sizeof(struct tcphdr); --
initial value yes, but it can change in the loop.
Pablo Neira Ayuso
maintainerQuoted 25 lines · Eric Dumazet
Quoted 24 lines · Pablo Neira Ayuso
Quoted 12 lines · Changli Gao
We should check the length of the data before dereferencing it when parsing the TCP options.
Signed-off-by Changli Gao <[email protected]>--- net/netfilter/nf_conntrack_proto_tcp.c | 4 ++++ 1 file changed, 4 insertions(+)net/netfilter/nf_conntrack_proto_tcp.c +0
-0net/netfilter/nf_conntrack_proto_tcp.c static void tcp_options(const struct sk_buff *skb, · line 411
Quoted 8 lines
net/netfilter/nf_conntrack_proto_tcp.c +2
-0@@ -404,6 +404,8 @@ static void tcp_options(const struct sk_buff *skb, length--;continue ;default : +if (length <2 ) +return ; opsize=*ptr++;if (opsize <2 )/* "silly options" */ return ;length is always multiple of 4:
Quoted 4 lines
Quoted 2 lines
int length = (tcph->doff*4) - sizeof(struct tcphdr); --
initial value yes, but it can change in the loop.
Indeed, then I think we need a similar patch for tcp_parse_options() in net/ipv4/tcp_input.c
Quoted 3 lines · Pablo Neira Ayuso
Indeed, then I think we need a similar patch for
tcp_parse_options()innet/ipv4/tcp_input.c
I'll send a separated patch for it. Thanks.
Signature · 2 lines
Regards, Changli Gao([email protected])