From f19d3389f1a4497a62e4f41d1a9baee05c6333e7 Mon Sep 17 00:00:00 2001 From: zhangyaqi Date: Mon, 13 May 2024 09:18:25 +0800 Subject: [PATCH] Fix an overflow bug in qsort comparison function --- ...low-bug-in-qsort-comparison-function.patch | 36 +++++++++++++++++++ rdma-core.spec | 9 ++++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 0034-librdmacm-Fix-an-overflow-bug-in-qsort-comparison-function.patch diff --git a/0034-librdmacm-Fix-an-overflow-bug-in-qsort-comparison-function.patch b/0034-librdmacm-Fix-an-overflow-bug-in-qsort-comparison-function.patch new file mode 100644 index 0000000..787c73f --- /dev/null +++ b/0034-librdmacm-Fix-an-overflow-bug-in-qsort-comparison-function.patch @@ -0,0 +1,36 @@ +From c4a5ac8bba611206e062c0955fb605bfc0f48b0f Mon Sep 17 00:00:00 2001 +From: Mark Zhang +Date: Fri, 26 Apr 2024 14:17:55 +0300 +Subject: [PATCH] librdmacm: Fix an overflow bug in qsort comparison function + +Reference: https://github.com/linux-rdma/rdma-core/commit/c4a5ac8bba611206e062c0955fb605bfc0f48b0f + +The comparison function dev_cmp() doesn't work with 64b pointers in some +cases, as it casts the pointer to int. For example it's not able to sort +this list: + {0xfffe0c2f0b00, 0xaaac741b4a90, 0xaaac741b4d70} + +Fixes: e5d371cb0af0 ("librdmacm: Globally store and sort IB device list") +Signed-off-by: Mark Zhang +Reviewed-by: Leon Romanovsky +Signed-off-by: Yishai Hadas +--- + librdmacm/cma.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/librdmacm/cma.c b/librdmacm/cma.c +index 7b924bd..0a631bd 100644 +--- a/librdmacm/cma.c ++++ b/librdmacm/cma.c +@@ -311,7 +311,7 @@ static void remove_cma_dev(struct cma_device *cma_dev) + + static int dev_cmp(const void *a, const void *b) + { +- return (int)(*(char *const *)a - *(char *const *)b); ++ return (*(uintptr_t *)a > *(uintptr_t *)b) - (*(uintptr_t *)a < *(uintptr_t *)b); + } + + static int sync_devices_list(void) +-- +2.27.0 + diff --git a/rdma-core.spec b/rdma-core.spec index 5ba0596..8eec039 100644 --- a/rdma-core.spec +++ b/rdma-core.spec @@ -1,6 +1,6 @@ Name: rdma-core Version: 50.0 -Release: 8 +Release: 10 Summary: RDMA core userspace libraries and daemons License: GPLv2 or BSD Url: https://github.com/linux-rdma/rdma-core @@ -35,6 +35,7 @@ patch26: 0026-libhns-Add-RoH-device-IDs.patch patch27: 0027-libhns-Add-the-parsing-of-mac-type-in-RoH-mode.patch patch28: 0028-libhns-Fix-missing-flexible-WQE-buffer-page-flag.patch patch29: 0029-libhns-Fix-ext_sge-page-size.patch +patch34: 0034-librdmacm-Fix-an-overflow-bug-in-qsort-comparison-function.patch BuildRequires: binutils cmake >= 2.8.11 gcc libudev-devel pkgconfig pkgconfig(libnl-3.0) BuildRequires: pkgconfig(libnl-route-3.0) valgrind-devel systemd systemd-devel @@ -614,6 +615,12 @@ fi %doc %{_docdir}/%{name}-%{version}/70-persistent-ipoib.rules %changelog +* Mon May 13 zhangyaqi -50.0-10 +- Type: bugfix +- ID: NA +- SUG: NA +- DESC: Fix an overflow bug in qsort comparison function + * Mon May 6 2024 Juan Zhou - 50.0-8 - Type: bugfix - ID: NA -- Gitee