diff --git a/backport-Fill-the-buffer-using-pipe-communication-with-zero.patch b/backport-Fill-the-buffer-using-pipe-communication-with-zero.patch new file mode 100644 index 0000000000000000000000000000000000000000..114a8b148575b30a6f8c739767f8855530f7adfb --- /dev/null +++ b/backport-Fill-the-buffer-using-pipe-communication-with-zero.patch @@ -0,0 +1,59 @@ +From b14d947b3548df94456dd9831d5f969403daf9e4 Mon Sep 17 00:00:00 2001 +From: Masatake YAMATO +Date: Tue, 24 Dec 2019 21:26:26 +0900 +Subject: [PATCH] Fill the buffer using pipe communication with zero + +Lsof runs sub processes for implementing non-blocking +stat, lstat, and readlink. Lsof main process uses pipes fo +for coummunicating with the sub processes. + +Valgrind reports a buffer used in the pipe communication +isn't initialized: + + $ sudo valgrind -v --track-origins=yes ./lsof > /dev/null + ==13857== Memcheck, a memory error detector + ==13857== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. + ==13857== Using Valgrind-3.14.0-353a3587bb-20181007X and LibVEX; rerun with -h for copyright info + ==13857== Command: ./lsof + ... + ==13858== Rerun with --leak-check=full to see details of leaked memory + ==13858== + ==13858== ERROR SUMMARY: 199 errors from 1 contexts (suppressed: 0 from 0) + ==13858== + ==13858== 199 errors in context 1 of 1: + ==13858== Syscall param write(buf) points to uninitialised byte(s) + ==13858== at 0x5380E34: write (write.c:27) + ==13858== by 0x41E477: doinchild (misc.c:369) + ==13858== by 0x41FB11: Readlink (misc.c:1108) + ==13858== by 0x403FBD: readmnt (dmnt.c:512) + ==13858== by 0x4071D9: initialize (dproc.c:655) + ==13858== by 0x41C99D: main (main.c:1253) + ==13858== Address 0x1ffeff9e60 is on thread 1's stack + ==13858== in frame #1, created by doinchild (misc.c:247) + ==13858== Uninitialised value was created by a stack allocation + ==13858== at 0x41E149: doinchild (misc.c:247) + ==13858== + ==13858== ERROR SUMMARY: 199 errors from 1 contexts (suppressed: 0 from 0) + +The code causing the erros seems harmless. However, keeping the output +of valgrind clean may be good for continuing maintaining lsof. + +No update for 00DIST because this change is invisble to users. + +Signed-off-by: Masatake YAMATO +--- + misc.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/misc.c b/misc.c +index be051609..3bebdc58 100644 +--- a/misc.c ++++ b/misc.c +@@ -360,6 +360,7 @@ doinchild(fn, fp, rbuf, rbln) + != (int)sizeof(r_rbln) + || r_rbln < 1 || r_rbln > (int)sizeof(r_rbuf)) + break; ++ zeromem (r_rbuf, r_rbln); + rv = r_fn(r_arg, r_rbuf, r_rbln); + en = errno; + if (write(Pipes[3], (char *)&rv, sizeof(rv)) diff --git a/lsof.spec b/lsof.spec index 02f0eddf493f48bde5772ff840b5705df246acb4..448e8cdd4926f5394bd19e08e84ef0407032da79 100644 --- a/lsof.spec +++ b/lsof.spec @@ -1,6 +1,6 @@ Name: lsof Version: 4.93.2 -Release: 6 +Release: 7 Summary: A tool for list open files License: zlib and Sendmail and LGPLv2+ URL: https://people.freebsd.org/~abe/ @@ -9,6 +9,7 @@ Patch0: 0050-endpoint-pipe-fix-list-the-same-fd-in-a-different-pr.patch Patch1: 0052-endpoint-pty-bug-fix-list-the-same-fd-in-a-different.patch Patch2: 0060-endpoint-pseudoterminal-bug-fix-fix-wrong-Unix98-PTY.patch Patch3: Handle-ffff-ffff-in-ipv6-addr-correctly.patch +Patch4: backport-Fill-the-buffer-using-pipe-communication-with-zero.patch BuildRequires: gcc git libtirpc-devel libselinux-devel @@ -47,6 +48,12 @@ install -p -m 0644 lsof.1 %{buildroot}/%{_mandir}/man1/lsof.1 %{_mandir}/man*/* %changelog +* Tue Nov 15 2022 Bin Hu - 4.93.2-7 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:fix valgrind error write to uninitialized bytes + * Wed Aug 24 2022 yueyuankun - 4.93.2-6 - Type:bugfix - ID:NA