Skip to content

Commit 4c110ec

Browse files
[AUTO-CHERRYPICK] Patch CVE-2024-5564 in libndp - branch main (#9485)
Co-authored-by: Nick Samson <nick.samson@microsoft.com>
1 parent f374bf9 commit 4c110ec

2 files changed

Lines changed: 50 additions & 2 deletions

File tree

SPECS/libndp/CVE-2024-5564.patch

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From 05e4ba7b0d126eea4c04387dcf40596059ee24af Mon Sep 17 00:00:00 2001
2+
From: Hangbin Liu <liuhangbin@gmail.com>
3+
Date: Wed, 5 Jun 2024 11:57:43 +0800
4+
Subject: [PATCH] libndp: valid route information option length
5+
6+
RFC 4191 specifies that the Route Information Option Length should be 1, 2,
7+
or 3, depending on the Prefix Length. A malicious node could potentially
8+
trigger a buffer overflow and crash the tool by sending an IPv6 router
9+
advertisement message containing the "Route Information" option with a
10+
"Length" field larger than 3.
11+
12+
To address this, add a check on the length field.
13+
14+
Fixes: 8296a5bf0755 ("add support for Route Information Option (rfc4191)")
15+
Reported-by: Evgeny Vereshchagin <evverx@gmail.com>
16+
Suggested-by: Felix Maurer <fmaurer@redhat.com>
17+
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
18+
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
19+
---
20+
libndp/libndp.c | 11 +++++++++++
21+
1 file changed, 11 insertions(+)
22+
23+
diff --git a/libndp/libndp.c b/libndp/libndp.c
24+
index 6314717..72ec92e 100644
25+
--- a/libndp/libndp.c
26+
+++ b/libndp/libndp.c
27+
@@ -1231,6 +1231,17 @@ static bool ndp_msg_opt_route_check_valid(void *opt_data)
28+
*/
29+
if (((ri->nd_opt_ri_prf_reserved >> 3) & 3) == 2)
30+
return false;
31+
+
32+
+ /* The Length field is 1, 2, or 3 depending on the Prefix Length.
33+
+ * If Prefix Length is greater than 64, then Length must be 3.
34+
+ * If Prefix Length is greater than 0, then Length must be 2 or 3.
35+
+ * If Prefix Length is zero, then Length must be 1, 2, or 3.
36+
+ */
37+
+ if (ri->nd_opt_ri_len > 3 ||
38+
+ (ri->nd_opt_ri_prefix_len > 64 && ri->nd_opt_ri_len != 3) ||
39+
+ (ri->nd_opt_ri_prefix_len > 0 && ri->nd_opt_ri_len == 1))
40+
+ return false;
41+
+
42+
return true;
43+
}
44+

SPECS/libndp/libndp.spec

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
Summary: Library for Neighbor Discovery Protocol
22
Name: libndp
33
Version: 1.8
4-
Release: 1%{?dist}
4+
Release: 2%{?dist}
55
License: LGPLv2+
66
Vendor: Microsoft Corporation
77
Distribution: Mariner
88
Group: System Environment/Libraries
99
URL: http://www.libndp.org/
1010
Source: http://www.libndp.org/files/%{name}-%{version}.tar.gz
11+
Patch0: CVE-2024-5564.patch
1112

1213
%description
1314
This package contains a library which provides a wrapper
@@ -22,7 +23,7 @@ Requires: libndp
2223
Headers and libraries for the libndp.
2324

2425
%prep
25-
%setup -q
26+
%autosetup -p1
2627

2728
%build
2829
%configure --disable-static
@@ -48,6 +49,9 @@ find %{buildroot} -type f -name "*.la" -delete -print
4849
%{_libdir}/pkgconfig/*.pc
4950

5051
%changelog
52+
* Fri Jun 14 2024 Nick Samson <nisamson@microsoft.com> - 1.8-2
53+
- Patch CVE-2024-5564
54+
5155
* Tue Jan 11 2022 Henry Li <lihl@microsoft.com> - 1.8-1
5256
- Upgrade to version 1.8
5357
- Remove calling autogen, which does not exist in latest version

0 commit comments

Comments
 (0)