netlabel: out of bound access in cipso_v4_validate()
authorEric Dumazet <edumazet@google.com>
Fri, 3 Feb 2017 08:03:26 +0000 (00:03 -0800)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Jun 2017 22:46:58 +0000 (00:46 +0200)
commit d71b7896886345c53ef1d84bda2bc758554f5d61 upstream.

syzkaller found another out of bound access in ip_options_compile(),
or more exactly in cipso_v4_validate()

Fixes: 20e2a8648596 ("cipso: handle CIPSO options correctly when NetLabel is disabled")
Fixes: 446fda4f2682 ("[NetLabel]: CIPSOv4 engine")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Paul Moore <paul@paul-moore.com>
Acked-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/net/cipso_ipv4.h
net/ipv4/cipso_ipv4.c

index a8c2ef6d3b932abbb42e28be158d472effd02513..9078b31d336f75d48ba4459b9edaf270d6be4bff 100644 (file)
@@ -303,6 +303,10 @@ static inline int cipso_v4_validate(const struct sk_buff *skb,
        }
 
        for (opt_iter = 6; opt_iter < opt_len;) {
+               if (opt_iter + 1 == opt_len) {
+                       err_offset = opt_iter;
+                       goto out;
+               }
                tag_len = opt[opt_iter + 1];
                if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len - opt_iter))) {
                        err_offset = opt_iter + 1;
index 667c1d4ca9847c627127dc633e19c7c94f354188..4322372dddbe4366cea4c2503a8d83ee869e1d4c 100644 (file)
@@ -1649,6 +1649,10 @@ int cipso_v4_validate(const struct sk_buff *skb, unsigned char **option)
                                goto validate_return_locked;
                        }
 
+               if (opt_iter + 1 == opt_len) {
+                       err_offset = opt_iter;
+                       goto validate_return_locked;
+               }
                tag_len = tag[1];
                if (tag_len > (opt_len - opt_iter)) {
                        err_offset = opt_iter + 1;