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 0000000000000000000000000000000000000000..787c73f1f33ee9af25f700ed6312b0db43bdfb88 --- /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 fc16708df510de45b0661f2c8b7fc4ea7c58f6e5..5f9130e8ab2e45800d56a43a78a75c77ead4e021 100644 --- a/rdma-core.spec +++ b/rdma-core.spec @@ -1,6 +1,6 @@ Name: rdma-core Version: 50.0 -Release: 10 +Release: 11 Summary: RDMA core userspace libraries and daemons License: GPLv2 or BSD Url: https://github.com/linux-rdma/rdma-core @@ -39,6 +39,7 @@ patch30: 0030-libhns-Remove-unused-return-value.patch patch31: 0031-libhns-Fix-several-context-locks-issue.patch patch32: 0032-libhns-Clean-up-signed-unsigned-mix-with-relational-.patch patch33: 0033-libhns-Fix-missing-flag-when-creating-qp-by-hnsdv_cr.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) systemd systemd-devel @@ -621,6 +622,12 @@ fi %doc %{_docdir}/%{name}-%{version}/70-persistent-ipoib.rules %changelog +* Fri May 24 zhangyaqi - 50.0-11 +- Type: bugfix +- ID: NA +- SUG: NA +- DESC: Fix an overflow bug in qsort comparison function + * Sun May 12 2024 yinsist - 50.0-10 - Type: requirement - ID: NA