aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authoryujuan.qi <yujuan.qi@mediatek.com>2017-07-31 11:23:01 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-05 09:18:33 +0200
commit8ed0ff83f5fd0ca412a52bd71af332598c01ca46 (patch)
treeb9c19c886856228c0be1f5dd8fd9e0b04fc0d231 /net
parent21a24b5db1858867ffafb5ca221b352a232e15eb (diff)
Cipso: cipso_v4_optptr enter infinite loop
commit 40413955ee265a5e42f710940ec78f5450d49149 upstream. in for(),if((optlen > 0) && (optptr[1] == 0)), enter infinite loop. Test: receive a packet which the ip length > 20 and the first byte of ip option is 0, produce this issue Signed-off-by: yujuan.qi <yujuan.qi@mediatek.com> Acked-by: Paul Moore <paul@paul-moore.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/cipso_ipv4.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 5f3b81941a6f..5169b9b36b6a 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -1593,9 +1593,17 @@ unsigned char *cipso_v4_optptr(const struct sk_buff *skb)
int taglen;
for (optlen = iph->ihl*4 - sizeof(struct iphdr); optlen > 0; ) {
- if (optptr[0] == IPOPT_CIPSO)
+ switch (optptr[0]) {
+ case IPOPT_CIPSO:
return optptr;
- taglen = optptr[1];
+ case IPOPT_END:
+ return NULL;
+ case IPOPT_NOOP:
+ taglen = 1;
+ break;
+ default:
+ taglen = optptr[1];
+ }
optlen -= taglen;
optptr += taglen;
}