Skip to content

Commit 3e8030f

Browse files
lldp patches
The details are as follows: 1. 0010-Ported-fix-for-length-exceeded-from-lldp-community.patch Ported fix lldpd/lldpd#408 from LLDP community. lib: remove limit on system description length The limit was introduced in 9c49ced while fixing a memory leak. The state data is used to ensure we don't interleave operations. We need to handle the case where the value is truncated because it is larger than the allocated size. Fix sonic-net#408. 2. 0011-fix-med-location-len.patch Ported fix lldpd/lldpd#422 from community. lib: fix LLDP-MED location parsing in liblldpctl Some bounds were not checked correctly when parsing LLDP-MED civic location fields. This triggers out-of-bound reads (no write) in lldpcli, ultimately leading to a crash. Fix sonic-net#420 Signed-off-by: sudhanshukumar22 <[email protected]>
1 parent bf693be commit 3e8030f

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
From fdb789c348fdcde6d5ef8b837d7f33718bc0862b Mon Sep 17 00:00:00 2001
2+
From: sudhanshukumar22 <[email protected]>
3+
Date: Mon, 23 Nov 2020 20:47:28 -0800
4+
Subject: [PATCH] Ported fix for https://github.com/lldpd/lldpd/issues/408 from
5+
community
6+
7+
---
8+
src/lib/atom.c | 4 ++--
9+
1 file changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/src/lib/atom.c b/src/lib/atom.c
12+
index f81d3bb..75c1275 100644
13+
--- a/src/lib/atom.c
14+
+++ b/src/lib/atom.c
15+
@@ -327,7 +327,7 @@ _lldpctl_do_something(lldpctl_conn_t *conn,
16+
conn->state_data[0] = 0;
17+
}
18+
if (conn->state == state_send &&
19+
- (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data)))) {
20+
+ (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data) - 1))) {
21+
/* We need to send the currently built message */
22+
rc = lldpctl_send(conn);
23+
if (rc < 0)
24+
@@ -335,7 +335,7 @@ _lldpctl_do_something(lldpctl_conn_t *conn,
25+
conn->state = state_recv;
26+
}
27+
if (conn->state == state_recv &&
28+
- (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data)))) {
29+
+ (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data) - 1))) {
30+
/* We need to receive the answer */
31+
while ((rc = ctl_msg_recv_unserialized(&conn->input_buffer,
32+
&conn->input_buffer_len,
33+
--
34+
2.12.2
35+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From e9bf329eee94d6d49a17da35aea189179aeed3c6 Mon Sep 17 00:00:00 2001
2+
From: sudhanshukumar22 <[email protected]>
3+
Date: Thu, 24 Dec 2020 09:27:49 -0800
4+
Subject: [PATCH] From 5c3479463a919193213213e2d8634c754c09aa51 Mon Sep 17
5+
00:00:00 2001 From: Vincent Bernat <[email protected]> Date: Sun, 6 Dec 2020
6+
14:21:04 +0100 Subject: [PATCH] lib: fix LLDP-MED location parsing in
7+
liblldpctl
8+
9+
Some bounds were not checked correctly when parsing LLDP-MED civic
10+
location fields. This triggers out-of-bound reads (no write) in
11+
lldpcli, ultimately leading to a crash.
12+
13+
Fix #420
14+
Signed-off-by: sudhanshukumar22 <[email protected]>
15+
---
16+
src/lib/atoms/med.c | 8 ++++++--
17+
1 file changed, 6 insertions(+), 2 deletions(-)
18+
19+
diff --git a/src/lib/atoms/med.c b/src/lib/atoms/med.c
20+
index e1b20fd..595dba4 100644
21+
--- a/src/lib/atoms/med.c
22+
+++ b/src/lib/atoms/med.c
23+
@@ -540,6 +540,7 @@ _lldpctl_atom_get_str_med_location(lldpctl_atom_t *atom, lldpctl_key_t key)
24+
return NULL;
25+
case lldpctl_k_med_location_country:
26+
if (m->location->format != LLDP_MED_LOCFORMAT_CIVIC) break;
27+
+ if (m->location->data_len < 4) return NULL;
28+
value = _lldpctl_alloc_in_atom(atom, 3);
29+
if (!value) return NULL;
30+
memcpy(value, m->location->data + 2, 2);
31+
@@ -732,8 +733,11 @@ _lldpctl_atom_iter_med_caelements_list(lldpctl_atom_t *atom)
32+
{
33+
struct _lldpctl_atom_med_caelements_list_t *plist =
34+
(struct _lldpctl_atom_med_caelements_list_t *)atom;
35+
- struct ca_iter *iter = _lldpctl_alloc_in_atom(atom, sizeof(struct ca_iter));
36+
- if (!iter) return NULL;
37+
+ struct ca_iter *iter;
38+
+ if (plist->parent->location->data_len < 4 ||
39+
+ *(uint8_t*)plist->parent->location->data < 3 ||
40+
+ !(iter = _lldpctl_alloc_in_atom(atom, sizeof(struct ca_iter))))
41+
+ return NULL;
42+
iter->data = (uint8_t*)plist->parent->location->data + 4;
43+
iter->data_len = *(uint8_t*)plist->parent->location->data - 3;
44+
return (lldpctl_atom_iter_t*)iter;
45+
--
46+
2.12.2
47+

src/lldpd/patch/series

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
0004-lldpctl-put-a-lock-around-some-commands-to-avoid-rac.patch
44
0006-lib-fix-memory-leak.patch
55
0007-lib-fix-memory-leak-when-handling-I-O.patch
6+
0010-Ported-fix-for-length-exceeded-from-lldp-community.patch
7+
0011-fix-med-location-len.patch

0 commit comments

Comments
 (0)