!28 fix valgrind error write to uninitialized bytes
From: @hubin95 Reviewed-by: @xiezhipeng1 Signed-off-by: @xiezhipeng1
This commit is contained in:
commit
315efca979
@ -0,0 +1,59 @@
|
||||
From b14d947b3548df94456dd9831d5f969403daf9e4 Mon Sep 17 00:00:00 2001
|
||||
From: Masatake YAMATO <yamato@redhat.com>
|
||||
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 <yamato@redhat.com>
|
||||
---
|
||||
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))
|
||||
@ -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 <hubin73@huawei.com> - 4.93.2-7
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:fix valgrind error write to uninitialized bytes
|
||||
|
||||
* Wed Aug 24 2022 yueyuankun<yueyuankun@kylinos.cn> - 4.93.2-6
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user