Page MenuHomeFreeBSD

vfs_lookup: correct comments around .. special cases
Needs ReviewPublic

Authored by emaste on Feb 1 2021, 3:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 24 2024, 3:44 AM
Unknown Object (File)
Sep 11 2024, 5:08 AM
Unknown Object (File)
Sep 4 2024, 7:41 AM
Unknown Object (File)
Aug 20 2024, 1:56 AM
Unknown Object (File)
Jul 29 2024, 10:27 PM
Unknown Object (File)
Jul 2 2024, 2:31 PM
Unknown Object (File)
Jun 30 2024, 12:10 PM
Unknown Object (File)
Jun 29 2024, 5:58 AM
Subscribers

Details

Reviewers
kib
Summary

Start list with item 1, update the introductory number of items in the list, include NI_LCF_STRICTRELATIVE, and reformat.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

emaste requested review of this revision.Feb 1 2021, 3:57 PM
emaste created this revision.
sys/kern/vfs_lookup.c
990

It is NI_LCF_STRICTRELATIVE. Also, the NI_LCF_CAP_DOTDOT should be not set for ENOTCAPABLE.

This has some non-trivial intersection with the rule 6.

some history,

  • two special cases date to 4.4 Lite (now 3 and 4 after my renumbering)
  • 2fe5bd8bb8393 added my case 5 (3 when added)
  • bea7a8d75cae152fcf7fb18225ad92c8ee2ba1cc added what I've now numbered 2 (1 when committed), and updated comment from "two special cases" (but actually three) to four
  • 0304c7316344d7e2d1dee3aa0249724ec629e8ef added hierarchical jails and introduced the for (pr = cnp->cn_cred->cr_prison; pr != NULL; pr = pr->pr_parent) loop and pr != NULL clause in the following if (but no new item in the list)
  • 69d377fe1bd79cb7e932275504af3120791960bd added my case 1 (0 when committed)
  • 7359fdcf5ffab47dfde9b469afc6a7d8488a77aa removed part of case 1 and added case 6 (0 and 5 when committed)

from 4.4 Lite the two special cases clearly mapped to the conditions inside the for (;;) loop:

/*
 * Handle "..": two special cases.
 * 1. If at root directory (e.g. after chroot)
 *    or at absolute root directory
 *    then ignore it so can't get out.
 * 2. If this vnode is the root of a mounted
 *    filesystem, then replace it with the
 *    vnode which was mounted on so we take the
 *    .. in the other file system.
 */
if (cnp->cn_flags & ISDOTDOT) {
        for (;;) {
                if (dp == ndp->ni_rootdir || dp == rootvnode) {
                        ndp->ni_dvp = dp;
                        ndp->ni_vp = dp;
                        VREF(dp);
                        goto nextname;
                }
                if ((dp->v_flag & VROOT) == 0 ||
                    (cnp->cn_flags & NOCROSSMOUNT))
                        break;
                tdp = dp;
                dp = dp->v_mount->mnt_vnodecovered;
                vput(tdp);
                VREF(dp);
                VOP_LOCK(dp);
        }
}

2fe5bd8bb8393 added nameidata::ni_topdir for case 5

sys/kern/vfs_lookup.c
990

Ah, yes. I don't want to just repeat the code in comments. Is NI_LCF_STRICTRELATIVE used only for capability mode or also for O_BENEATH handling?

sys/kern/vfs_lookup.c
990

Also for BENEATH. They are only differentiated at setup.

@kib I added comments to match the various cases; if this is correct it seems we should swap 4 and 5.

sys/kern/vfs_lookup.c
1006

Case 1

1015

Case 2

1021

For case 5

1025

Case 3 and 5

1036

Case 4

1049

Case 6