diff --git a/0012-rpcdebug-avoid-buffer-underflow-if-read-returns-0.patch b/0012-rpcdebug-avoid-buffer-underflow-if-read-returns-0.patch new file mode 100644 index 0000000000000000000000000000000000000000..11f90be810d7bf1470ff71904d148aa306ab2a9b --- /dev/null +++ b/0012-rpcdebug-avoid-buffer-underflow-if-read-returns-0.patch @@ -0,0 +1,29 @@ +From a746c35822e557766d1871ec976490a71e6962d9 Mon Sep 17 00:00:00 2001 +From: Zhi Li +Date: Wed, 5 Apr 2023 12:08:10 -0400 +Subject: [PATCH] rpcdebug: avoid buffer underflow if read() returns 0 + +Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2176740 + +Signed-off-by: Zhi Li +Signed-off-by: Steve Dickson +--- + tools/rpcdebug/rpcdebug.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/rpcdebug/rpcdebug.c b/tools/rpcdebug/rpcdebug.c +index 68206cc5..ec05179e 100644 +--- a/tools/rpcdebug/rpcdebug.c ++++ b/tools/rpcdebug/rpcdebug.c +@@ -257,7 +257,7 @@ get_flags(char *module) + perror(filename); + exit(1); + } +- if ((len = read(sysfd, buffer, sizeof(buffer))) < 0) { ++ if ((len = read(sysfd, buffer, sizeof(buffer))) <= 0) { + perror("read"); + exit(1); + } +-- +2.33.0 + diff --git a/0013-export-Fix-rootdir-corner-case-in-next_mnt.patch b/0013-export-Fix-rootdir-corner-case-in-next_mnt.patch new file mode 100644 index 0000000000000000000000000000000000000000..72723d216b5f2421de6837e30974147bc91de7be --- /dev/null +++ b/0013-export-Fix-rootdir-corner-case-in-next_mnt.patch @@ -0,0 +1,58 @@ +From c0bf5895173972a0b86633c7d61d0de46798bbe1 Mon Sep 17 00:00:00 2001 +From: Richard Weinberger +Date: Wed, 5 Apr 2023 12:16:24 -0400 +Subject: [PATCH] export: Fix rootdir corner case in next_mnt() + +Currently the following setup causes failure: +1. /etc/exports: +/ *(rw,crossmnt,no_subtree_check,fsid=root) + +2. /etc/nfs.conf: +[exports] + rootdir=/nfs_srv + +3. Mounts: +/root/fs1.ext4 on /nfs_srv type ext4 (rw,relatime) +/root/fs2.ext4 on /nfs_srv/fs2 type ext4 (rw,relatime) + +4. On the client: +$ ls /nfs_client/fs2 +ls: cannot open directory '/nfs_client/fs2': Stale file handle + +The problem is that next_mnt() misses the corner case that +every mount is a sub-mount of "/". +So it fails to see that /nfs_srv/fs2 is a mountpoint when the +client asks for fs2 it and as consequence the crossmnt mechanism +fails. + +Signed-off-by: Richard Weinberger +Signed-off-by: Steve Dickson +--- + support/export/cache.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/support/export/cache.c b/support/export/cache.c +index 2497d4f4..1c526277 100644 +--- a/support/export/cache.c ++++ b/support/export/cache.c +@@ -410,12 +410,16 @@ static char *next_mnt(void **v, char *p) + *v = f; + } else + f = *v; +- while ((me = getmntent(f)) != NULL && l > 1) { ++ while ((me = getmntent(f)) != NULL && l >= 1) { + char *mnt_dir = nfsd_path_strip_root(me->mnt_dir); + + if (!mnt_dir) + continue; + ++ /* Everything below "/" is a proper sub-mount */ ++ if (strcmp(p, "/") == 0) ++ return mnt_dir; ++ + if (strncmp(mnt_dir, p, l) == 0 && mnt_dir[l] == '/') + return mnt_dir; + } +-- +2.33.0 + diff --git a/nfs-utils.spec b/nfs-utils.spec index bf351b23e9a70b9e4696c58c1eb9e1d11a07e511..5b10a8772d1d04118cb5c09bae89a634d14e1093 100644 --- a/nfs-utils.spec +++ b/nfs-utils.spec @@ -4,7 +4,7 @@ Name: nfs-utils Version: 2.5.4 -Release: 11 +Release: 12 Epoch: 2 Summary: The Linux NFS userland utility package License: MIT and GPLv2 and GPLv2+ and BSD @@ -24,6 +24,8 @@ Patch8: 0008-svcgssd-Fix-use-after-free-bug-config-variables.patch Patch9: 0009-rpc-pipefs-generator-allocate-enough-space-for-pipef.patch Patch10: 0010-nfs-utils-Don-t-allow-junction-tests-to-trigger-auto.patch Patch11: 0011-Covscan-Scan-Wrong-Check-of-Return-Value.patch +Patch12: 0012-rpcdebug-avoid-buffer-underflow-if-read-returns-0.patch +Patch13: 0013-export-Fix-rootdir-corner-case-in-next_mnt.patch BuildRequires: libevent-devel,libcap-devel, libtirpc-devel libblkid-devel BuildRequires: krb5-libs >= 1.4 autoconf >= 2.57 openldap-devel >= 2.2 @@ -292,6 +294,9 @@ fi %{_mandir}/*/* %changelog +* Sun Jun 25 2023 wuguanghao - 2:2.5.4-12 +- backport patches from community + * Thu Mar 23 2023 wuguanghao - 2:2.5.4-11 - backport patches from community