!156 [sync] PR-151: librdmacm: Fix an overflow bug in qsort comparison function

From: @openeuler-sync-bot 
Reviewed-by: @hellotcc 
Signed-off-by: @hellotcc
This commit is contained in:
openeuler-ci-bot 2024-07-24 02:46:16 +00:00 committed by Gitee
commit 0908e9ea6c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 44 additions and 1 deletions

View File

@ -0,0 +1,36 @@
From c4a5ac8bba611206e062c0955fb605bfc0f48b0f Mon Sep 17 00:00:00 2001
From: Mark Zhang <markzhang@nvidia.com>
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 <markzhang@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
---
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

View File

@ -1,6 +1,6 @@
Name: rdma-core Name: rdma-core
Version: 50.0 Version: 50.0
Release: 10 Release: 11
Summary: RDMA core userspace libraries and daemons Summary: RDMA core userspace libraries and daemons
License: GPLv2 or BSD License: GPLv2 or BSD
Url: https://github.com/linux-rdma/rdma-core 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 patch31: 0031-libhns-Fix-several-context-locks-issue.patch
patch32: 0032-libhns-Clean-up-signed-unsigned-mix-with-relational-.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 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: binutils cmake >= 2.8.11 gcc libudev-devel pkgconfig pkgconfig(libnl-3.0)
BuildRequires: pkgconfig(libnl-route-3.0) systemd systemd-devel BuildRequires: pkgconfig(libnl-route-3.0) systemd systemd-devel
@ -621,6 +622,12 @@ fi
%doc %{_docdir}/%{name}-%{version}/70-persistent-ipoib.rules %doc %{_docdir}/%{name}-%{version}/70-persistent-ipoib.rules
%changelog %changelog
* Wed May 29 zhangyaqi <zhangyaqi@kylinos.cn> - 50.0-11
- Type: bugfix
- ID: NA
- SUG: NA
- DESC: Fix an overflow bug in qsort comparison function
* Sun May 12 2024 yinsist <jianhui.oerv@isrc.iscas.ac.cn> - 50.0-10 * Sun May 12 2024 yinsist <jianhui.oerv@isrc.iscas.ac.cn> - 50.0-10
- Type: requirement - Type: requirement
- ID: NA - ID: NA