update version to 4.94.0

This commit is contained in:
zou_lin77 2021-01-23 11:50:10 +08:00
parent 1b36127f50
commit b5d0348d01
7 changed files with 8 additions and 307 deletions

View File

@ -1,82 +0,0 @@
From 7360d80e08abf18dcce61fe033de548ac2378f06 Mon Sep 17 00:00:00 2001
From: kangenbo <kangenbo@huawei.com>
Date: Wed, 17 Apr 2019 12:20:39 -0400
Subject: [PATCH 50/83] endpoint(pipe),fix: list the same fd in a different process
Description: backport patch from github, see following in details:
https://github.com/lsof-org/lsof-linux/commit/28f96d5875086d92b5f1cb3f3473ac1184cf155e
---
dialects/linux/dnode.c | 7 +++++--
proc.c | 4 ++--
proto.h | 2 +-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/dialects/linux/dnode.c b/dialects/linux/dnode.c
index 58288d6..ddd99cf 100644
--- a/dialects/linux/dnode.c
+++ b/dialects/linux/dnode.c
@@ -383,13 +383,15 @@ is_pty_ptmx(dev)
*/
pxinfo_t *
-find_pepti(lf, pp)
+find_pepti(pid, lf, pp)
+ int pid; /* pid of the process owning lf */
struct lfile *lf; /* pipe's lfile */
pxinfo_t *pp; /* previous pipe info (NULL == none) */
{
struct lfile *ef; /* pipe end local file structure */
int h; /* hash result */
pxinfo_t *pi; /* pipe info pointer */
+ struct lproc *ep;
if (Pinfo) {
if (pp)
@@ -401,7 +403,8 @@ find_pepti(lf, pp)
while (pi) {
if (pi->ino == lf->inode) {
ef = pi->lf;
- if (strcmp(lf->fd, ef->fd))
+ ep = &Lproc[pi->lpx];
+ if ((strcmp(lf->fd, ef->fd)) || (pid != ep->pid))
return(pi);
}
pi = pi->next;
diff --git a/proc.c b/proc.c
index 34cb4b8..e4c3591 100644
--- a/proc.c
+++ b/proc.c
@@ -992,7 +992,7 @@ process_pinfo(f)
* its being a pipe. Look up the pipe's endpoints.
*/
do {
- if ((pp = find_pepti(Lf, pp))) {
+ if ((pp = find_pepti(Lp->pid, Lf, pp))) {
/*
* This pipe endpoint is linked to the selected pipe
@@ -1033,7 +1033,7 @@ process_pinfo(f)
Lf->sf = Selflags;
Lp->pss |= PS_SEC;
do {
- if ((pp = find_pepti(Lf, pp))) {
+ if ((pp = find_pepti(Lp->pid, Lf, pp))) {
ep = &Lproc[pp->lpx];
ef = pp->lf;
for (i = 0; i < (FDLEN - 1); i++) {
diff --git a/proto.h b/proto.h
index 75c74a1..7f65d67 100644
--- a/proto.h
+++ b/proto.h
@@ -112,7 +112,7 @@ _PROTOTYPE(extern void find_ch_ino,(void));
# if defined(HASEPTOPTS)
_PROTOTYPE(extern void clear_pinfo,(void));
-_PROTOTYPE(extern pxinfo_t *find_pepti,(struct lfile *lf, pxinfo_t *pp));
+_PROTOTYPE(extern pxinfo_t *find_pepti,(int pid, struct lfile *lf, pxinfo_t *pp));
_PROTOTYPE(extern void process_pinfo,(int f));
# if defined(HASUXSOCKEPT)
_PROTOTYPE(extern void clear_uxsinfo,(void));
--
1.8.3.1

View File

@ -1,92 +0,0 @@
From f8ff9c832d45d44007e936ad3110c227241612d8 Mon Sep 17 00:00:00 2001
From: kangenbo <kangenbo@huawei.com>
Date: Mon, 15 Apr 2019 16:38:23 -0400
Subject: [PATCH 52/83] endpoint(pty),bug fix: list the same fd in a different process
Description: This change is simillar to 28f96d58 (endpoint(pipe),fix: list the same
fd in a different process). 28f96d58 is about pipe. This change is about pty.
Source: backport patch from github, see following in detail:
https://github.com/lsof-org/lsof-linux/commit/cea5e144ee6ac16fd0c82c0a7d25790d5f60b823
---
dialects/linux/dnode.c | 10 +++++-----
proc.c | 4 ++--
proto.h | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dialects/linux/dnode.c b/dialects/linux/dnode.c
index ddd99cf..ee12227 100644
--- a/dialects/linux/dnode.c
+++ b/dialects/linux/dnode.c
@@ -307,7 +307,8 @@ enter_ptmxi(mn)
*/
pxinfo_t *
-find_ptyepti(lf, m, pp)
+find_ptyepti(pid, lf, m, pp)
+ int pid;
struct lfile *lf; /* pseudoterminal's lfile */
int m; /* minor number type:
* 0 == use tty_index
@@ -319,6 +320,7 @@ find_ptyepti(lf, m, pp)
int h; /* hash result */
INODETYPE mn; /* minor number */
pxinfo_t *pi; /* pseudoterminal info pointer */
+ struct lproc *ep;
mn = m ? GET_MIN_DEV(lf->rdev) : lf->tty_index;
@@ -332,12 +334,10 @@ find_ptyepti(lf, m, pp)
while (pi) {
if (pi->ino == mn) {
ef = pi->lf;
- if (((m && is_pty_ptmx(ef->rdev))
+ ep = &Lproc[pi->lpx];
+ if ((m && is_pty_ptmx(ef->rdev))
|| ((!m) && is_pty_slave(GET_MAJ_DEV(ef->rdev))))
- && strcmp(lf->fd, ef->fd)
- ) {
return(pi);
- }
}
pi = pi->next;
}
diff --git a/proc.c b/proc.c
index e4c3591..7fe3998 100644
--- a/proc.c
+++ b/proc.c
@@ -1443,7 +1443,7 @@ process_ptyinfo(f)
*/
pc = 1;
do {
- if ((pp = find_ptyepti(Lf, !mos, pp))) {
+ if ((pp = find_ptyepti(Lp->pid, Lf, !mos, pp))) {
/*
* This pseudoterminal endpoint is linked to the
@@ -1468,7 +1468,7 @@ process_ptyinfo(f)
Lp->pss |= PS_SEC;
pc = 1;
do {
- if ((pp = find_ptyepti(Lf, !mos, pp))) {
+ if ((pp = find_ptyepti(Lp->pid, Lf, !mos, pp))) {
prt_ptyinfo(pp, (mos && pc), 0);
pp = pp->next;
pc = 0;
diff --git a/proto.h b/proto.h
index 7f65d67..2df360a 100644
--- a/proto.h
+++ b/proto.h
@@ -122,7 +122,7 @@ _PROTOTYPE(extern void process_uxsinfo,(int f));
# if defined(HASPTYEPT)
_PROTOTYPE(extern void clear_ptyinfo,(void));
_PROTOTYPE(extern void enter_ptmxi,(int mn));
-_PROTOTYPE(extern pxinfo_t *find_ptyepti,(struct lfile *lf,int m,pxinfo_t *pp));
+_PROTOTYPE(extern pxinfo_t *find_ptyepti,(int pid, struct lfile *lf,int m,pxinfo_t *pp));
_PROTOTYPE(extern int is_pty_slave,(int sm));
_PROTOTYPE(extern int is_pty_ptmx,(dev_t dev));
_PROTOTYPE(extern void process_ptyinfo,(int f));
--
1.8.3.1

View File

@ -1,43 +0,0 @@
From abbcbb099008dfed895adbd54d60f10e4129c7aa Mon Sep 17 00:00:00 2001
From: Masatake YAMATO <yamato@redhat.com>
Date: Wed, 5 Dec 2018 00:12:06 +0900
Subject: [PATCH 60/83] endpoint(pseudoterminal),bug fix: fix wrong Unix98 PTY
slaves major number detection
A typo was in the code detecting Unix98 PTY slave device.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
---
dialects/linux/dnode.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/dialects/linux/dnode.c b/dialects/linux/dnode.c
index 68b6a04..fa60557 100644
--- a/dialects/linux/dnode.c
+++ b/dialects/linux/dnode.c
@@ -354,8 +354,21 @@ int
is_pty_slave(sm)
int sm; /* slave major device number */
{
+ /* linux/Documentation/admin-guide/devices.txt
+ -------------------------------------------
+ 136-143 char Unix98 PTY slaves
+ 0 = /dev/pts/0 First Unix98 pseudo-TTY
+ 1 = /dev/pts/1 Second Unix98 pseudo-TTY
+ ...
+
+ These device nodes are automatically generated with
+ the proper permissions and modes by mounting the
+ devpts filesystem onto /dev/pts with the appropriate
+ mount options (distribution dependent, however, on
+ *most* distributions the appropriate options are
+ "mode=0620,gid=<gid of the "tty" group>".) */
if ((UNIX98_PTY_SLAVE_MAJOR <= sm)
- && (sm < (UNIX98_PTY_SLAVE_MAJOR + UNIX98_PTY_SLAVE_MAJOR))
+ && (sm < (UNIX98_PTY_SLAVE_MAJOR + UNIX98_PTY_MAJOR_COUNT))
) {
return 1;
}
--
1.8.3.1

View File

@ -1,84 +0,0 @@
From e64dc10ea1d5be38681191d9f4d2aa9018ab59dc Mon Sep 17 00:00:00 2001
From: Masatake YAMATO <yamato@redhat.com>
Date: Sun, 4 Oct 2020 03:50:26 +0900
Subject: [PATCH] [linux] handle ffff:ffff in ipv6 addr correctly
Close #102
Close #109
The listen address and port of an AF_INET6 socket were not display if
the socket listened at an ipv6 address including ffff:ffff.
Here is a command session demonstrating the bug:
# ip -6 addr add abcd:ef10:ffff:ffff:ffff:ffff:ffff:ff62 dev lo
# nc -6 -l abcd:ef10:ffff:ffff:ffff:ffff:ffff:ff62 8888 &
[1] 6762
# ./lsof -p 6762 -a -d fd -P -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nc 6762 yamato 0u CHR 136,6 0t0 9 /dev/pts/6
nc 6762 yamato 1u CHR 136,6 0t0 9 /dev/pts/6
nc 6762 yamato 2u CHR 136,6 0t0 9 /dev/pts/6
nc 6762 yamato 3u sock 0,9 0t0 5833594 protocol: TCPv6
The last line should be:
nc 6762 yamato 3u IPv6 5833594 0t0 TCP [abcd:ef10:ffff:ffff:ffff:ffff:ffff:ff62]:8888 (LISTEN)
The original code decoding an ipv6 address uses UINT32_MAX constant
incorrect way.
@zhrf2020 reported this bug in #102.
The test case is based on the report.
@zhrf2020 provided the initial version of fix, #109.
This change is based on the version.
---
dialects/linux/dsock.c | 33 ++++++++++++-
1 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/dialects/linux/dsock.c b/dialects/linux/dsock.c
index 4b71460..0aaaf6d 100644
--- a/dialects/linux/dsock.c
+++ b/dialects/linux/dsock.c
@@ -3632,9 +3632,38 @@ net6a2in6(as, ad)
(void) strncpy(buf, as, 8);
buf[8] = '\0';
ep = (char *)NULL;
- if ((ad->s6_addr32[i] = (uint32_t)strtoul(buf, &ep, 16))
- == (uint32_t)UINT32_MAX || !ep || *ep)
+
+ errno = 0;
+ unsigned long ul_addr = strtoul(buf, &ep, 16);
+ if (!ep || *ep)
+ break;
+ else if (ul_addr == ULONG_MAX && errno == ERANGE)
+ {
+ /* Quoted from strtoul(3)
+ ---------------------------------------------------
+ The strtoul() function returns either the result of
+ the conversion or, if there was a leading minus
+ sign, the negation of the result of the conversion
+ represented as an unsigned value, unless the
+ original (nonnegated) value would overflow; in the
+ latter case, strtoul() returns ULONG_MAX and sets
+ errno to ERANGE.
+ ---------------------------------------------------
+ NOTE: even if the value doesn't overflow, a
+ negative is not acceptable. */
break;
+ }
+ else if (ul_addr > (unsigned long)UINT32_MAX)
+ {
+ /* This will never happen:
+ The maximum length of BUF is 8 characters.
+ The possible maximum value represented by BUF is
+ "FFFFFFFF". This is UINT32_MAX.
+ If you agree with what I write here, make a pull
+ request for removing this block. */
+ break;
+ }
+ ad->s6_addr32[i] = (uint32_t)ul_addr;
}
return((*as || (i != 4) || len) ? 1 : 0);
}

Binary file not shown.

BIN
lsof-4.94.0.tar.gz Normal file

Binary file not shown.

View File

@ -1,14 +1,10 @@
Name: lsof
Version: 4.93.2
Release: 4
Version: 4.94.0
Release: 1
Summary: A tool for list open files
License: zlib and Sendmail and LGPLv2+
URL: https://people.freebsd.org/~abe/
Source0: https://github.com/lsof-org/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
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
BuildRequires: gcc git libtirpc-devel libselinux-devel
@ -46,6 +42,12 @@ install -p -m 0644 Lsof.8 %{buildroot}/%{_mandir}/man1/lsof.1
%{_mandir}/man*/*
%changelog
* Sat Jan 23 2021 zoulin <zoulin13@huawei.com> - 4.94.0-1
- Type: enhancement
- ID: NA
- SUG: NA
- DESC: update version to 4.94.0
* Mon Oct 19 2020 yangshaoxing <yangshaoxing3@huawei.com> - 4.93.2-4
- Handle ffff:ffff in ipv6 addr correctly