Author: kib
Date: Tue Sep 22 22:43:32 2020
New Revision: 366021
URL: https://svnweb.freebsd.org/changeset/base/366021

Log:
  Change O_BENEATH to handle relative paths same as absolute.
  
  Do not care if path walks out of the topping directory if it returns back.
  
  Requested and reviewed by:    markj
  Tested by:    pho
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week
  Differential revision:        https://reviews.freebsd.org/D25886

Modified:
  head/sys/kern/vfs_lookup.c

Modified: head/sys/kern/vfs_lookup.c
==============================================================================
--- head/sys/kern/vfs_lookup.c  Tue Sep 22 22:36:02 2020        (r366020)
+++ head/sys/kern/vfs_lookup.c  Tue Sep 22 22:43:32 2020        (r366021)
@@ -178,11 +178,13 @@ static void
 nameicap_tracker_add(struct nameidata *ndp, struct vnode *dp)
 {
        struct nameicap_tracker *nt;
+       struct componentname *cnp;
 
        if ((ndp->ni_lcf & NI_LCF_CAP_DOTDOT) == 0 || dp->v_type != VDIR)
                return;
-       if ((ndp->ni_lcf & (NI_LCF_BENEATH_ABS | NI_LCF_BENEATH_LATCHED)) ==
-           NI_LCF_BENEATH_ABS) {
+       cnp = &ndp->ni_cnd;
+       if ((cnp->cn_flags & BENEATH) != 0 &&
+           (ndp->ni_lcf & NI_LCF_BENEATH_LATCHED) == 0) {
                MPASS((ndp->ni_lcf & NI_LCF_LATCH) != 0);
                if (dp != ndp->ni_beneath_latch)
                        return;
@@ -593,8 +595,8 @@ namei(struct nameidata *ndp)
                                namei_cleanup_cnp(cnp);
                        } else
                                cnp->cn_flags |= HASBUF;
-                       if ((ndp->ni_lcf & (NI_LCF_BENEATH_ABS |
-                           NI_LCF_BENEATH_LATCHED)) == NI_LCF_BENEATH_ABS) {
+                       if ((ndp->ni_lcf & (NI_LCF_LATCH |
+                           NI_LCF_BENEATH_LATCHED)) == NI_LCF_LATCH) {
                                NDFREE(ndp, 0);
                                error = ENOTCAPABLE;
                        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to