~ubuntu-branches/ubuntu/lucid/tcpdump/lucid-updates

« back to all changes in this revision

Viewing changes to debian/patches/CVE-2014-8767.patch

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2014-12-03 17:17:23 UTC
  • Revision ID: package-import@ubuntu.com-20141203171723-lm274az3b1gb3kbc
Tags: 4.0.0-6ubuntu3.1
* SECURITY UPDATE: denial of service and possible code execution in
  olsr_print
  - debian/patches/CVE-2014-8767.patch: improve bounds checking and
    error handling in print-olsr.c.
  - CVE-2014-8767
* SECURITY UPDATE: denial of service and possible code execution in
  print-aodv.c
  - debian/patches/CVE-2014-8769.patch: improve bounds checking and
    length checking in print-aodv.c, aodv.h.
  - CVE-2014-8769
* SECURITY UPDATE: denial of service and possible code execution in
  print-ppp.c
  - debian/patches/CVE-2014-9140.patch: improve bounds checking in
    print-ppp.c.
  - CVE-2014-9140

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Backport of:
 
2
 
 
3
From 4038f83ebf654804829b258dde5e0a508c1c2003 Mon Sep 17 00:00:00 2001
 
4
From: Guy Harris <guy@alum.mit.edu>
 
5
Date: Tue, 11 Nov 2014 16:49:39 -0800
 
6
Subject: [PATCH] Do more bounds checking and length checking.
 
7
 
 
8
Don't run past the end of the captured data, and don't run past the end
 
9
of the packet (i.e., don't make the length variable go negative).
 
10
 
 
11
Also, stop dissecting if the message length isn't valid.
 
12
---
 
13
 print-olsr.c | 56 +++++++++++++++++++++++++++++++++++++++++++-------------
 
14
 1 file changed, 43 insertions(+), 13 deletions(-)
 
15
 
 
16
Index: tcpdump-4.0.0/print-olsr.c
 
17
===================================================================
 
18
--- tcpdump-4.0.0.orig/print-olsr.c     2014-12-03 17:06:47.275721894 -0500
 
19
+++ tcpdump-4.0.0/print-olsr.c  2014-12-03 17:16:48.016960427 -0500
 
20
@@ -157,7 +157,7 @@
 
21
 /*
 
22
  * print a neighbor list with LQ extensions.
 
23
  */
 
24
-static void
 
25
+static int
 
26
 olsr_print_lq_neighbor (const u_char *msg_data, u_int hello_len)
 
27
 {
 
28
     struct olsr_lq_neighbor *lq_neighbor;
 
29
@@ -165,6 +165,8 @@
 
30
     while (hello_len >= sizeof(struct olsr_lq_neighbor)) {
 
31
 
 
32
         lq_neighbor = (struct olsr_lq_neighbor *)msg_data;
 
33
+        if (!TTEST(*lq_neighbor))
 
34
+            return (-1);
 
35
 
 
36
         printf("\n\t      neighbor %s, link-quality %.2lf%%"
 
37
                ", neighbor-link-quality %.2lf%%",
 
38
@@ -175,12 +177,13 @@
 
39
         msg_data += sizeof(struct olsr_lq_neighbor);
 
40
         hello_len -= sizeof(struct olsr_lq_neighbor);
 
41
     }
 
42
+    return (0);
 
43
 }
 
44
 
 
45
 /*
 
46
  * print a neighbor list.
 
47
  */
 
48
-static void
 
49
+static int
 
50
 olsr_print_neighbor (const u_char *msg_data, u_int hello_len)
 
51
 {
 
52
     int neighbor;
 
53
@@ -190,6 +193,8 @@
 
54
 
 
55
     while (hello_len >= sizeof(struct in_addr)) {
 
56
 
 
57
+        if (!TTEST2(*msg_data, sizeof(struct in_addr)))
 
58
+            return (-1);
 
59
         /* print 4 neighbors per line */
 
60
 
 
61
         printf("%s%s", ipaddr_string(msg_data),
 
62
@@ -198,6 +203,7 @@
 
63
         msg_data += sizeof(struct in_addr);
 
64
         hello_len -= sizeof(struct in_addr);
 
65
     }
 
66
+    return (0);
 
67
 }
 
68
 
 
69
 
 
70
@@ -245,6 +251,7 @@
 
71
     }
 
72
 
 
73
     while (tptr < (pptr+length)) {
 
74
+        int msg_len_valid = 0;
 
75
 
 
76
         if (!TTEST2(*tptr, sizeof(struct olsr_msg)))   
 
77
             goto trunc;
 
78
@@ -253,6 +260,9 @@
 
79
 
 
80
         msg_type = ptr.msg->msg_type;
 
81
         msg_len = EXTRACT_16BITS(ptr.msg->msg_len);
 
82
+            if ((msg_len >= sizeof (struct olsr_msg))
 
83
+                    && (msg_len <= length))
 
84
+                msg_len_valid = 1;
 
85
 
 
86
         /* infinite loop check */
 
87
         if (msg_type == 0 || msg_len == 0) {
 
88
@@ -268,6 +278,9 @@
 
89
                ME_TO_DOUBLE(ptr.msg->vtime),
 
90
                EXTRACT_16BITS(ptr.msg->msg_seq),
 
91
                msg_len);
 
92
+        if (!msg_len_valid) {
 
93
+            return;
 
94
+        }
 
95
 
 
96
         msg_tlen = msg_len - sizeof(struct olsr_msg);
 
97
         msg_data = tptr + sizeof(struct olsr_msg);
 
98
@@ -275,6 +288,8 @@
 
99
         switch (msg_type) {
 
100
         case OLSR_HELLO_MSG:
 
101
         case OLSR_HELLO_LQ_MSG:
 
102
+            if (msg_tlen < sizeof(struct olsr_hello))
 
103
+                goto trunc;
 
104
             if (!TTEST2(*msg_data, sizeof(struct olsr_hello))) 
 
105
                 goto trunc;
 
106
 
 
107
@@ -307,10 +322,14 @@
 
108
                 msg_tlen -= sizeof(struct olsr_hello_link);
 
109
                 hello_len -= sizeof(struct olsr_hello_link);
 
110
 
 
111
+                if (!TTEST2(*msg_data, hello_len))
 
112
+                    goto trunc;
 
113
                 if (msg_type == OLSR_HELLO_MSG) {
 
114
-                    olsr_print_neighbor(msg_data, hello_len);
 
115
+                    if (olsr_print_neighbor(msg_data, hello_len) == -1)
 
116
+                        goto trunc;
 
117
                 } else {
 
118
-                    olsr_print_lq_neighbor(msg_data, hello_len);
 
119
+                    if (olsr_print_lq_neighbor(msg_data, hello_len) == -1)
 
120
+                        goto trunc;
 
121
                 }
 
122
 
 
123
                 msg_data += hello_len;
 
124
@@ -320,6 +339,8 @@
 
125
 
 
126
         case OLSR_TC_MSG:
 
127
         case OLSR_TC_LQ_MSG:
 
128
+            if (msg_tlen < sizeof(struct olsr_tc))
 
129
+                goto trunc;
 
130
             if (!TTEST2(*msg_data, sizeof(struct olsr_tc)))    
 
131
                 goto trunc;
 
132
 
 
133
@@ -330,9 +351,11 @@
 
134
             msg_tlen -= sizeof(struct olsr_tc);
 
135
 
 
136
             if (msg_type == OLSR_TC_MSG) {
 
137
-                olsr_print_neighbor(msg_data, msg_tlen);
 
138
+                if (olsr_print_neighbor(msg_data, msg_tlen) == -1)
 
139
+                    goto trunc;
 
140
             } else {
 
141
-                olsr_print_lq_neighbor(msg_data, msg_tlen);
 
142
+                if (olsr_print_lq_neighbor(msg_data, msg_tlen) == -1)
 
143
+                    goto trunc;
 
144
             }
 
145
             break;
 
146