From 67ae8f484e12381abefb5c2d66dd957beb844569 Mon Sep 17 00:00:00 2001 From: kouwenqi Date: Wed, 10 Apr 2024 16:18:07 +0800 Subject: [PATCH] blkparse: fix incorrectly sized memset in check_cpu_map --- ...orrectly-sized-memset-in-check_cpu_m.patch | 32 +++++++++++++++++++ blktrace.spec | 6 +++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 0004-blkparse-fix-incorrectly-sized-memset-in-check_cpu_m.patch diff --git a/0004-blkparse-fix-incorrectly-sized-memset-in-check_cpu_m.patch b/0004-blkparse-fix-incorrectly-sized-memset-in-check_cpu_m.patch new file mode 100644 index 0000000..d6d385f --- /dev/null +++ b/0004-blkparse-fix-incorrectly-sized-memset-in-check_cpu_m.patch @@ -0,0 +1,32 @@ +From 7f5d2c5173d72018aa29c583c9291ef10abaf8df Mon Sep 17 00:00:00 2001 +From: Jeff Mahoney +Date: Thu, 21 Oct 2021 10:16:20 -0400 +Subject: [PATCH] blkparse: fix incorrectly sized memset in check_cpu_map + +The memset call in check_cpu_map always clears sizeof(unsigned long *) +regardless of what size was allocated. Use calloc instead to allocate +the map so it's zeroed properly regardless of the size requested. + +Signed-off-by: Jeff Mahoney +Signed-off-by: Jens Axboe +--- + blkparse.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/blkparse.c b/blkparse.c +index 498857c..9d2029a 100644 +--- a/blkparse.c ++++ b/blkparse.c +@@ -2236,8 +2236,7 @@ static int check_cpu_map(struct per_dev_info *pdi) + /* + * create a map of the cpus we have traces for + */ +- cpu_map = malloc(pdi->cpu_map_max / sizeof(long)); +- memset(cpu_map, 0, sizeof(*cpu_map)); ++ cpu_map = calloc(1, pdi->cpu_map_max / sizeof(long)); + n = rb_first(&rb_sort_root); + while (n) { + __t = rb_entry(n, struct trace, rb_node); +-- +2.23.0 + diff --git a/blktrace.spec b/blktrace.spec index ab9569d..863ea75 100644 --- a/blktrace.spec +++ b/blktrace.spec @@ -1,6 +1,6 @@ Name: blktrace Version: 1.3.0 -Release: 2 +Release: 3 Summary: Block IO tracer in the Linux kernel License: GPLv2+ Source: http://brick.kernel.dk/snaps/blktrace-%{version}.tar.bz2 @@ -14,6 +14,7 @@ Requires: python3 Patch1: 0001-blktrace-remove-python2-dedpendency.patch Patch2: 0002-blktrace-Makefile-add-fstack-protector-strong-flag.patch Patch3: 0003-blktrace-fix-exit-directly-when-nthreads-running.patch +Patch4: 0004-blkparse-fix-incorrectly-sized-memset-in-check_cpu_m.patch %description blktrace is a block layer IO tracing mechanism which provides detailed @@ -50,6 +51,9 @@ make dest=%{buildroot} prefix=%{buildroot}/%{_prefix} mandir=%{buildroot}/%{_man %changelog +* Wed Apr 10 2024 kouwenqi - 1.3.0-3 +- blkparse: fix incorrectly sized memset in check_cpu_map + * Mon May 16 2022 Li Jinlin - 1.3.0-2 - provide iowatcher via Provides -- Gitee