Bug 1944119
| Summary: | exportfs: unable to unexport root | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Roberto Bergantinos <rbergant> | |
| Component: | nfs-utils | Assignee: | Steve Dickson <steved> | |
| Status: | CLOSED ERRATA | QA Contact: | Yongcheng Yang <yoyang> | |
| Severity: | medium | Docs Contact: | ||
| Priority: | unspecified | |||
| Version: | 8.3 | CC: | ajmitchell, dwysocha, ssahsrab, steved, xzhou, yieli, yoyang | |
| Target Milestone: | rc | Keywords: | Patch, Reproducer, Triaged | |
| Target Release: | --- | Flags: | pm-rhel:
mirror+
|
|
| Hardware: | All | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | nfs-utils-2.3.3-42.el8 | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 1958975 1975049 (view as bug list) | Environment: | ||
| Last Closed: | 2021-11-09 19:40:03 UTC | Type: | Bug | |
| Regression: | --- | Mount Type: | --- | |
| Documentation: | --- | CRM: | ||
| Verified Versions: | Category: | --- | ||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
| Cloudforms Team: | --- | Target Upstream Version: | ||
| Embargoed: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 1958975 | |||
(In reply to Roberto Bergantinos from comment #0) > I think problem is here : > > 355 static void > 356 unexportfs_parsed(char *hname, char *path, int verbose) > 357 { > ... > 369 /* > 370 * It's possible the specified path ends with a '/'. But > 371 * the entry from exportlist won't has the trailing '/', > 372 * so need to deal with it. > 373 */ > 374 size_t nlen = strlen(path); > 375 while (path[nlen - 1] == '/') <<--- [*] > 376 nlen--; .. > while removing the trailing "/" from the path, for root case, we'll leave > nlen at 0, > so we will loop through exportlist without finding "/". Yeah, that's the problem! Thanks a lot for the report! Would you mind sending this patch to upstream "Linux NFS Mailing list <linux-nfs.org>" and cc "Steve Dickson <steved>". IMO we cannot make it 8.4 now and it has been there for 5 years. Let's defer it to 8.5 for now.
>
> Would you mind sending this patch to upstream "Linux NFS Mailing list
> <linux-nfs.org>" and cc "Steve Dickson <steved>".
hi Yongcheng
yeah I sent the patch yesterday
thanks for taking a look !
rgds
roberto
commit ac266e2edc4f40eef810d52c72657b645e4010db
Author: Ondrej Mosnacek <omosnace>
Date: Tue Apr 6 15:57:37 2021 -0400
exportfs: fix unexporting of '/'
RHEL7 clone - https://bugzilla.redhat.com/show_bug.cgi?id=1958975 Verified on nfs-utils-2.3.3-42.el8. ~~~~~~~~ [23:24:24 root@ ~~]# exportfs -s / localhost(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash) [23:24:24 root@ ~~]# exportfs -v -u localhost:/ unexporting localhost:/ [23:24:24 root@ ~~]# exportfs -s [23:24:24 root@ ~~]# Compared with nfs-utils-2.3.3-41.el8 ~~~~~~~~ [11:42:27 root@ ~~]# exportfs -s / localhost(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash) [11:42:27 root@ ~~]# exportfs -v -u localhost:/ exportfs: Could not find 'localhost:/' to unexport. [11:42:27 root@ ~~]# exportfs -s / localhost(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash) [11:42:27 root@ ~~]# exportfs -ua P.s. clear the unneeded needinfo flag. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (nfs-utils bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2021:4403 |
Description of problem: If root is exported, we're unable to unexport it individually : [root@rhel8 ~]# exportfs -s /opt/mydir 172.23.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash) /opt/mydir/subdir 172.23.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash) /opt/mydir *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash) /opt/mydir/subdir *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash) [root@rhel8 ~]# exportfs -i -o rw,sync 172.23.1.247:/ [root@rhel8 ~]# exportfs -s / 172.23.1.247(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash) /opt/mydir/subdir 172.23.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash) /opt/mydir 172.23.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,ro,secure,root_squash,no_all_squash) /opt/mydir/subdir *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash) /opt/mydir *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash) [root@rhel8 ~]# exportfs -v -u 172.23.1.247:/ exportfs: Could not find '172.23.1.247:/' to unexport. - exportfs -au works - exporting a bind mount of root & unexport it works I think problem is here : 355 static void 356 unexportfs_parsed(char *hname, char *path, int verbose) 357 { ... 369 /* 370 * It's possible the specified path ends with a '/'. But 371 * the entry from exportlist won't has the trailing '/', 372 * so need to deal with it. 373 */ 374 size_t nlen = strlen(path); 375 while (path[nlen - 1] == '/') <<--- [*] 376 nlen--; 377 378 for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) { 379 if (strlen(exp->m_export.e_path) != nlen) 380 continue; 381 if (path && strncmp(path, exp->m_export.e_path, nlen)) 382 continue; while removing the trailing "/" from the path, for root case, we'll leave nlen at 0, so we will loop through exportlist without finding "/". quick patch : diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index 262dd19a..40813fb8 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -383,7 +383,7 @@ unexportfs_parsed(char *hname, char *path, int verbose) * so need to deal with it. */ size_t nlen = strlen(path); - while (path[nlen - 1] == '/') + while ((path[nlen - 1] == '/') && (nlen > 1)) nlen--; for (exp = exportlist[htype].p_head; exp; exp = exp->m_next) { seems to work : [root@f-rawhide exportfs]# ./exportfs -i -o rw,sync *:/ [root@f-rawhide exportfs]# ./exportfs -s / *(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,root_squash,no_all_squash) [root@f-rawhide exportfs]# ./exportfs -v -u *:/ unexporting *:/ [root@f-rawhide exportfs]# ./exportfs -s [root@f-rawhide exportfs]# Version-Release number of selected component (if applicable): How reproducible: 100% Steps to Reproduce: 1. see above 2. 3. Actual results: not able to indivually unexport root Expected results: able to indivually unexport root Additional info: