fix crashes when using the --touch option
(cherry picked from commit edddee1bdd9a4083417b4d510b43c81352fb3eb3)
This commit is contained in:
parent
f022723234
commit
50654ce6c5
43
Fix-crashes-when-using-the-touch-option.patch
Normal file
43
Fix-crashes-when-using-the-touch-option.patch
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
From a47463a72864a76b0557468daf83741632ea4d72 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Patrick Mansfield <patrick.mansfield@cpacketnetworks.com>
|
||||||
|
Date: Mon, 30 Sep 2019 15:59:53 -0700
|
||||||
|
Subject: [PATCH] Fix crashes when using the "--touch" option.
|
||||||
|
|
||||||
|
Fix memory to be mapped read/write, so that the "touch" option can write to it.
|
||||||
|
|
||||||
|
Signed-off-by: Patrick Mansfield <patrick.mansfield@cpacketnetworks.com>
|
||||||
|
---
|
||||||
|
shm.c | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/shm.c b/shm.c
|
||||||
|
index 260eeff..fb592ed 100644
|
||||||
|
--- a/shm.c
|
||||||
|
+++ b/shm.c
|
||||||
|
@@ -119,7 +119,7 @@ void attach_sysvshm(char *name, char *opt)
|
||||||
|
shmlen = s.shm_segsz;
|
||||||
|
}
|
||||||
|
|
||||||
|
- shmptr = shmat(shmfd, NULL, SHM_RDONLY);
|
||||||
|
+ shmptr = shmat(shmfd, NULL, 0);
|
||||||
|
if (shmptr == (void*)-1)
|
||||||
|
err("shmat");
|
||||||
|
shmptr += shmoffset;
|
||||||
|
@@ -134,7 +134,7 @@ void attach_shared(char *name, char *opt)
|
||||||
|
{
|
||||||
|
struct stat64 st;
|
||||||
|
|
||||||
|
- shmfd = open(name, O_RDONLY);
|
||||||
|
+ shmfd = open(name, O_RDWR);
|
||||||
|
if (shmfd < 0) {
|
||||||
|
errno = 0;
|
||||||
|
if (shmlen == 0)
|
||||||
|
@@ -160,7 +160,7 @@ void attach_shared(char *name, char *opt)
|
||||||
|
|
||||||
|
/* RED-PEN For shmlen > address space may need to map in pieces.
|
||||||
|
Left for some poor 32bit soul. */
|
||||||
|
- shmptr = mmap64(NULL, shmlen, PROT_READ, MAP_SHARED, shmfd, shmoffset);
|
||||||
|
+ shmptr = mmap64(NULL, shmlen, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, shmoffset);
|
||||||
|
if (shmptr == (char*)-1)
|
||||||
|
err("shm mmap");
|
||||||
|
|
||||||
30
fix-use-after-free.patch
Normal file
30
fix-use-after-free.patch
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
From 498385e3aaf265d6e9786e0a391196cd82ab3260 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Pingfan Liu <piliu@redhat.com>
|
||||||
|
Date: Fri, 18 Jun 2021 18:14:20 +0800
|
||||||
|
Subject: [PATCH] numactl.c: fix use after free
|
||||||
|
|
||||||
|
The following command can trigger the bug
|
||||||
|
numactl --length 65536 --shm xxx -p0 -V > /dev/null
|
||||||
|
|
||||||
|
So reset mask to block any new access inside this loop.
|
||||||
|
|
||||||
|
Signed-off-by: Pingfan Liu <piliu@redhat.com>
|
||||||
|
---
|
||||||
|
numactl.c | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/numactl.c b/numactl.c
|
||||||
|
index 76a1cca..a39d220 100644
|
||||||
|
--- a/numactl.c
|
||||||
|
+++ b/numactl.c
|
||||||
|
@@ -534,6 +534,7 @@ int main(int ac, char **av)
|
||||||
|
if (nnodes != 1)
|
||||||
|
usage();
|
||||||
|
numa_bitmask_free(mask);
|
||||||
|
+ mask = NULL;
|
||||||
|
errno = 0;
|
||||||
|
did_node_cpu_parse = 1;
|
||||||
|
numa_set_bind_policy(0);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -1,12 +1,15 @@
|
|||||||
Name: numactl
|
Name: numactl
|
||||||
Version: 2.0.13
|
Version: 2.0.13
|
||||||
Release: 4
|
Release: 5
|
||||||
Summary: Library for tuning for Non Uniform Memory Access machines
|
Summary: Library for tuning for Non Uniform Memory Access machines
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
URL: https://github.com/numactl/numactl
|
URL: https://github.com/numactl/numactl
|
||||||
Source0: https://github.com/numactl/numactl/releases/download/v%{version}/numactl-%{version}.tar.gz
|
Source0: https://github.com/numactl/numactl/releases/download/v%{version}/numactl-%{version}.tar.gz
|
||||||
BuildRequires: libtool automake autoconf git
|
BuildRequires: libtool automake autoconf git
|
||||||
|
|
||||||
|
Patch0001: Fix-crashes-when-using-the-touch-option.patch
|
||||||
|
Patch0002: fix-use-after-free.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
Simple NUMA policy support. It consists of a numactl program to run other
|
Simple NUMA policy support. It consists of a numactl program to run other
|
||||||
programs with a specific NUMA policy and a libnuma shared library to set
|
programs with a specific NUMA policy and a libnuma shared library to set
|
||||||
@ -69,6 +72,9 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%{_mandir}/man3/*.3*
|
%{_mandir}/man3/*.3*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sat May 07 2022 zhouwenpei<zhouwenpei1@h-partners.com> - 2.0.13-5
|
||||||
|
- fix crashes when using the "--touch" option
|
||||||
|
|
||||||
* Fri Jan 10 2020 yuxiangyang<yuxiangyang4@huawei.com> - 2.0.13-4
|
* Fri Jan 10 2020 yuxiangyang<yuxiangyang4@huawei.com> - 2.0.13-4
|
||||||
- upgrade version to 2.0.13
|
- upgrade version to 2.0.13
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user