From a73ffaf01790e1e3fe9d5a346e94f8aa466f6e81 Mon Sep 17 00:00:00 2001 From: Scott Mayhew Date: Thu, 2 Jul 2026 15:32:10 -0400 Subject: [PATCH] export: Fix rootdir corner case in next_mnt() Resolves: RHEL-182520 Signed-off-by: Scott Mayhew --- ...-Fix-rootdir-corner-case-in-next_mnt.patch | 58 +++++++++++++++++++ nfs-utils.spec | 6 +- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 nfs-utils-2.5.4-export-Fix-rootdir-corner-case-in-next_mnt.patch diff --git a/nfs-utils-2.5.4-export-Fix-rootdir-corner-case-in-next_mnt.patch b/nfs-utils-2.5.4-export-Fix-rootdir-corner-case-in-next_mnt.patch new file mode 100644 index 0000000..e951298 --- /dev/null +++ b/nfs-utils-2.5.4-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.55.0 + diff --git a/nfs-utils.spec b/nfs-utils.spec index 0b872ec..8eda6dc 100644 --- a/nfs-utils.spec +++ b/nfs-utils.spec @@ -2,7 +2,7 @@ Summary: NFS utilities and supporting clients and daemons for the kernel NFS ser Name: nfs-utils URL: http://linux-nfs.org/ Version: 2.5.4 -Release: 43%{?dist} +Release: 44%{?dist} Epoch: 1 # group all 32bit related archs @@ -102,6 +102,7 @@ Patch046: nfs-utils-2.5.4-Fix-access-checks-when-mounting-subdirectories-in-NF.p Patch047: nfs-utils-2.5.4-nfsrahead-enable-event-driven-mountinfo-monitoring-a.patch Patch048: nfs-utils-2.5.4-nfsrahead-zero-initialise-device_info-struct.patch Patch049: nfs-utils-2.5.4-nfsrahead-quieten-misleading-error-for-non-NFS-block.patch +Patch050: nfs-utils-2.5.4-export-Fix-rootdir-corner-case-in-next_mnt.patch Patch100: nfs-utils-1.2.1-statdpath-man.patch Patch101: nfs-utils-1.2.1-exp-subtree-warn-off.patch @@ -549,6 +550,9 @@ fi %{_mandir}/*/nfsiostat.8.gz %changelog +* Thu Jul 2 2026 Scott Mayhew 2.5.4-44 +- export: Fix rootdir corner case in next_mnt() (RHEL-182520) + * Mon Apr 6 2026 Scott Mayhew 2.5.4-43 - nfsrahead: enable event-driven mountinfo monitoring and skip non-NFS devices (RHEL-158527) - nfsrahead: zero-initialise device_info struct (RHEL-158527)