Skip to content

Commit 9ecf5e5

Browse files
committed
Merge branch 'dev-v2.4.4' into 'R2.4'
Prepare for v2.4.4 release See merge request gpudirect/gdrcopy!42
2 parents 428e8fa + f1d7002 commit 9ecf5e5

File tree

9 files changed

+54
-12
lines changed

9 files changed

+54
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [2.4.4] - 2024-12-16
4+
- Fix the use-after-free bug of mr objects in gdrdv\_vma\_close.
5+
- Fix the resource leakage bug in gdrdrv\_release.
6+
37
## [2.4.3] - 2024-12-02
48
- Fix NVIDIA\_IS\_OPENSOURCE detection when compile with NVIDIA driver version 545 or newer.
59
- Fix compile error in gdrdrv when compile on RHEL9.5.
@@ -91,7 +95,6 @@
9195
- Add _validate_ unit test to ensure that gdrcopy functions as expected.
9296
- Add a script for packaging gdrcopy in the rpm format.
9397

94-
9598
[2.4.3]: https://github.com/NVIDIA/gdrcopy/releases/tag/v2.4.3
9699
[2.4.2]: https://github.com/NVIDIA/gdrcopy/releases/tag/v2.4.2
97100
[2.4.1]: https://github.com/NVIDIA/gdrcopy/releases/tag/v2.4.1

packages/build-deb-packages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ MODULE_SUBDIR=$(awk '/MODULE_SUBDIR \?=/ { print $3 }' ${TOP_DIR_PATH}/src/gdrdr
9696

9797
MAJOR_VERSION=$(awk '/#define GDR_API_MAJOR_VERSION/ { print $3 }' ${TOP_DIR_PATH}/include/gdrapi.h | tr -d '\n')
9898
MINOR_VERSION=$(awk '/#define GDR_API_MINOR_VERSION/ { print $3 }' ${TOP_DIR_PATH}/include/gdrapi.h | tr -d '\n')
99-
VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.3"
99+
VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.4"
100100
if [ "X$VERSION" == "X" ]; then
101101
echo "Failed to get version numbers!" >&2
102102
exit 1

packages/build-rpm-packages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ MODULE_SUBDIR=$(awk '/MODULE_SUBDIR \?=/ { print $3 }' ${TOP_DIR_PATH}/src/gdrdr
9292

9393
MAJOR_VERSION=$(awk '/#define GDR_API_MAJOR_VERSION/ { print $3 }' ${TOP_DIR_PATH}/include/gdrapi.h | tr -d '\n')
9494
MINOR_VERSION=$(awk '/#define GDR_API_MINOR_VERSION/ { print $3 }' ${TOP_DIR_PATH}/include/gdrapi.h | tr -d '\n')
95-
VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.3"
95+
VERSION="${MAJOR_VERSION}.${MINOR_VERSION}.4"
9696
if [ "X$VERSION" == "X" ]; then
9797
echo "Failed to get version numbers!" >&2
9898
exit 1

packages/debian-lib/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
libgdrapi (2.4.4) stable; urgency=low
2+
3+
* No change.
4+
5+
-- Pak Markthub <[email protected]> Mon, 16 Dec 2024 11:59:59 -0700
6+
17
libgdrapi (2.4.3) stable; urgency=low
28

39
* No change.

packages/debian-meta/changelog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
gdrcopy (2.4.4) stable; urgency=low
2+
3+
* Fix the use-after-free bug of mr objects in gdrdv_vma_close.
4+
* Fix the resource leakage bug in gdrdrv_release.
5+
6+
-- Pak Markthub <[email protected]> Mon, 16 Dec 2024 11:59:59 -0700
7+
18
gdrcopy (2.4.3) stable; urgency=low
29

310
* Fix NVIDIA_IS_OPENSOURCE detection when compile with NVIDIA driver version 545 or newer.

packages/debian-tests/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
gdrcopy-tests (2.4.4) stable; urgency=low
2+
3+
* No change.
4+
5+
-- Pak Markthub <[email protected]> Mon, 16 Dec 2024 11:59:59 -0700
6+
17
gdrcopy-tests (2.4.3) stable; urgency=low
28

39
* No change.

packages/dkms/debian/changelog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
gdrdrv-dkms (2.4.4) stable; urgency=low
2+
3+
* Fix the use-after-free bug of mr objects in gdrdv_vma_close.
4+
* Fix the resource leakage bug in gdrdrv_release.
5+
6+
-- Pak Markthub <[email protected]> Mon, 16 Dec 2024 11:59:59 -0700
7+
18
gdrdrv-dkms (2.4.3) stable; urgency=low
29

310
* Fix NVIDIA_IS_OPENSOURCE detection when compile with NVIDIA driver version 545 or newer.

packages/gdrcopy.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ rm -rf $RPM_BUILD_DIR/%{name}-%{version}
363363

364364

365365
%changelog
366+
* Mon Dec 16 2024 Pak Markthub <[email protected]> 2.4.4-%{_release}
367+
- Fix the use-after-free bug of mr objects in gdrdv_vma_close.
368+
- Fix the resource leakage bug in gdrdrv_release.
366369
* Mon Dec 02 2024 Pak Markthub <[email protected]> 2.4.3-%{_release}
367370
- Fix NVIDIA_IS_OPENSOURCE detection when compile with NVIDIA driver version 545 or newer.
368371
* Thu Oct 31 2024 Pak Markthub <[email protected]> 2.4.2-%{_release}

src/gdrdrv/gdrdrv.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ static void gdr_free_mr_unlocked(gdr_mr_t *mr)
499499
gdr_err("nvidia_p2p_put_pages error %d, async callback may have been fired\n", status);
500500
}
501501
#endif
502+
502503
} else {
503504
gdr_dbg("invoking unpin_buffer while callback has already been fired\n");
504505

@@ -527,11 +528,6 @@ static int gdrdrv_release(struct inode *inode, struct file *filp)
527528
gdr_err("filp contains no info\n");
528529
return -EIO;
529530
}
530-
// Check that the caller is the same process that did gdrdrv_open
531-
if (!gdrdrv_check_same_process(info, current)) {
532-
gdr_dbg("filp is not opened by the current process\n");
533-
return -EACCES;
534-
}
535531

536532
mutex_lock(&info->lock);
537533
list_for_each_safe(p, n, &info->mr_list) {
@@ -1142,11 +1138,27 @@ static long gdrdrv_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned
11421138

11431139
void gdrdrv_vma_close(struct vm_area_struct *vma)
11441140
{
1145-
gdr_mr_t *mr = (gdr_mr_t *)vma->vm_private_data;
1146-
gdr_dbg("closing vma=0x%px vm_file=0x%px vm_private_data=0x%px mr=0x%px mr->vma=0x%px\n", vma, vma->vm_file, vma->vm_private_data, mr, mr->vma);
1141+
gdr_hnd_t handle;
1142+
gdr_mr_t *mr = NULL;
1143+
gdr_info_t* info = NULL;
1144+
1145+
if (!vma->vm_file)
1146+
return;
1147+
1148+
info = vma->vm_file->private_data;
1149+
if (!info)
1150+
return;
1151+
1152+
handle = gdrdrv_handle_from_off(vma->vm_pgoff);
1153+
mr = gdr_get_mr_from_handle_write(info, handle);
1154+
if (!mr)
1155+
return;
1156+
1157+
gdr_dbg("closing vma=0x%px vm_file=0x%px mr=0x%px mr->vma=0x%px\n", vma, vma->vm_file, mr, mr->vma);
11471158
// TODO: handle multiple vma's
11481159
mr->vma = NULL;
11491160
mr->cpu_mapping_type = GDR_MR_NONE;
1161+
gdr_put_mr_write(mr);
11501162
}
11511163

11521164
/*----------------------------------------------------------------------------*/
@@ -1306,8 +1318,6 @@ static int gdrdrv_mmap(struct file *filp, struct vm_area_struct *vma)
13061318
// Set to None first
13071319
mr->cpu_mapping_type = GDR_MR_NONE;
13081320
vma->vm_ops = &gdrdrv_vm_ops;
1309-
gdr_dbg("overwriting vma->vm_private_data=%px with mr=%px\n", vma->vm_private_data, mr);
1310-
vma->vm_private_data = mr;
13111321

13121322
// check for physically contiguous IO ranges
13131323
p = 0;

0 commit comments

Comments
 (0)