>Synopsis:      Permission denied from ls [mountpoint]/.. when mountpoint have 
>no permissions before mount(8)
>Category:      library
>Environment:
        System      : OpenBSD 6.5
        Details     : OpenBSD 6.5 (GENERIC.MP) #1: Mon May 27 18:27:59 CEST 2019
                         
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP

        Architecture: OpenBSD.amd64
        Machine     : amd64
>Description:
        In this machine /usr/src is a mount point without any permission. I 
mount a filesystem at
        directory /usr/src. The mounted filesystem do have permissions to the 
mount point directory
        for my user through group wsrc.
        However, "ls /usr/src/.." returns the message "Permission denied" 
instead of listing the
        contents of /usr, as I would expect.

>How-To-Repeat:
        In this machine every user has read and search access to /usr, and 
/usr/src is a mount point
        without any permission at all (before mount(8)):

        $ df | grep /usr/src            (<- the filesystem is not mounted yet)

        $ ls -ld /usr
        drwxr-xr-x  18 root  wheel  512 Jun  9 19:06 /usr
        
        $ ls -ld /usr/src
        d---------  2 root  wsrc  512 Jun  9 12:47 /usr/src

        In this scenario, I can get the listing of /usr using "ls /usr" but not 
using "/usr/src/..",
        which seems ok to me:

        $ id
        uid=1000(rafa) gid=1000(rafa) groups=1000(rafa), 0(wheel), 9(wsrc), 
21(wobj)

        $ ls /usr
        X11R6    games    lib      libexec  mdec     ports    share    xenocara
        bin      include  libdata  local    obj      sbin     src      xobj

        $ ls /usr/src/..
        ls: /usr/src/..: Permission denied

        Now I mount a filesystem at directory /usr/src. After the mount(8), 
/usr/src has the permissions
        I want it to have:

        $ grep /usr/src /etc/fstab
        2ae1c772b7608e2a.f /usr/src ffs rw,wxallowed,nodev 1 2

        # mount -a

        $ df | grep /usr/src
        /dev/sd0f      7437692   2123632   4942176    30%    /usr/src

        $ ls -ld /usr/src
        drwxrwxr-x  17 root  wsrc  512 Jun 17 20:58 /usr/src

        With this configuration I still get a "Permission denied" message when 
trying to access "/usr/src/..",
        which I think is not correct:

        $ ls /usr
        X11R6    games    lib      libexec  mdec     ports    share    xenocara
        bin      include  libdata  local    obj      sbin     src      xobj

        $ ls /usr/src/..
        ls: /usr/src/..: Permission denied

        However, if the mount point has permissions (let's say 550) before the 
mount(8), access to "/usr/src/.." gives
        the result I expect:

        # umount /usr/src

        $ ls -ld /usr/src
        d---------  2 root  wsrc  512 Jun  9 12:47 /usr/src

        # chmod ug+rx /usr/src

        $ ls -ld /usr/src
        dr-xr-x---  2 root  wsrc  512 Jun  9 12:47 /usr/src

        # mount -a

        $ df | grep /usr/src
        /dev/sd0f      7437692   2123632   4942176    30%    /usr/src

        $ ls -ld /usr/src
        drwxrwxr-x  17 root  wsrc  512 Jun 17 20:58 /usr/src

        $ ls /usr/src/..
        X11R6    games    lib      libexec  mdec     ports    share    xenocara
        bin      include  libdata  local    obj      sbin     src      xobj

>Fix:
        I have followed the execution flow up to the FTSENT * fts_children(FTS 
*sp, int instr) function in
        /usr/src/lib/libc/gen/fts.c but, unfortunately, I am not skilled enough 
to go any further.


dmesg:
OpenBSD 6.5 (GENERIC.MP) #1: Mon May 27 18:27:59 CEST 2019
    
[email protected]:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8488615936 (8095MB)
avail mem = 8221712384 (7840MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0x8d313000 (41 entries)
bios0: vendor American Megatrends Inc. version "5.12" date 02/17/2017
bios0: Notebook N24_25BU
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC FPDT MCFG SSDT FIDT SSDT HPET SSDT UEFI SSDT LPIT 
WSMT SSDT SSDT DBGP DBG2 BGRT DMAR TPM2 ASF!
acpi0: wakeup devices PXSX(S4) RP21(S4) PXSX(S4) RP22(S4) PXSX(S4) RP23(S4) 
PXSX(S4) RP24(S4) PXSX(S4) RP17(S4) PXSX(S4) RP18(S4) PXSX(S4) RP19(S4) 
PXSX(S4) RP20(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz, 2176.88 MHz, 06-8e-09
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu0: 256KB 64b/line 8-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 23MHz
cpu0: mwait min=64, max=64, C-substates=0.2.1.2.4.1.1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz, 2394.39 MHz, 06-8e-09
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu1: 256KB 64b/line 8-way L2 cache
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 1 (application processor)
cpu2: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz, 2394.39 MHz, 06-8e-09
cpu2: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu2: 256KB 64b/line 8-way L2 cache
cpu2: smt 1, core 0, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz, 2394.39 MHz, 06-8e-09
cpu3: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,FMA3,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,AVX,F16C,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,ABM,3DNOWP,PERF,ITSC,FSGSBASE,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PT,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES,MELTDOWN
cpu3: 256KB 64b/line 8-way L2 cache
cpu3: smt 1, core 1, package 0
ioapic0 at mainbus0: apid 2 pa 0xfec00000, version 20, 120 pins
acpimcfg0 at acpi0
acpimcfg0: addr 0xe0000000, bus 0-255
acpihpet0 at acpi0: 23999999 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PEG0)
acpiprt2 at acpi0: bus -1 (PEG1)
acpiprt3 at acpi0: bus -1 (PEG2)
acpiprt4 at acpi0: bus -1 (RP17)
acpiprt5 at acpi0: bus -1 (RP18)
acpiprt6 at acpi0: bus -1 (RP19)
acpiprt7 at acpi0: bus -1 (RP20)
acpiprt8 at acpi0: bus 1 (RP01)
acpiprt9 at acpi0: bus -1 (RP02)
acpiprt10 at acpi0: bus 2 (RP03)
acpiprt11 at acpi0: bus -1 (RP04)
acpiprt12 at acpi0: bus -1 (RP05)
acpiprt13 at acpi0: bus 3 (RP06)
acpiprt14 at acpi0: bus -1 (RP07)
acpiprt15 at acpi0: bus -1 (RP08)
acpiprt16 at acpi0: bus -1 (RP09)
acpiprt17 at acpi0: bus -1 (RP10)
acpiprt18 at acpi0: bus -1 (RP11)
acpiprt19 at acpi0: bus -1 (RP12)
acpiprt20 at acpi0: bus -1 (RP13)
acpiprt21 at acpi0: bus -1 (RP14)
acpiprt22 at acpi0: bus -1 (RP15)
acpiprt23 at acpi0: bus -1 (RP16)
acpiec0 at acpi0
acpicpu0 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu1 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu2 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpicpu3 at acpi0: C3(200@1034 mwait.1@0x60), C2(200@151 mwait.1@0x33), 
C1(1000@1 mwait.1), PSS
acpitz0 at acpi0: critical temperature is 120 degC
acpipci0 at acpi0 PCI0: 0x00000004 0x00000011 0x00000001
acpicmos0 at acpi0
"INT33A1" at acpi0 not configured
"MSFT0101" at acpi0 not configured
"PNPC000" at acpi0 not configured
acpibtn0 at acpi0: PWRB
acpibtn1 at acpi0: SLPB
acpibtn2 at acpi0: LID0
acpiac0 at acpi0: AC unit offline
acpibat0 at acpi0: BAT0 model "BAT" serial 0001 type LION oem "Notebook"
"PNP0C14" at acpi0 not configured
acpivideo0 at acpi0: GFX0
acpivout0 at acpivideo0: DD1F
cpu0: using Skylake AVX MDS workaround
cpu0: Enhanced SpeedStep 2176 MHz: speeds: 2601, 2600, 2500, 2400, 2200, 2000, 
1900, 1700, 1500, 1400, 1200, 1100, 800, 700, 600, 400 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "Intel Core 7G Host" rev 0x02
inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 620" rev 0x02
drm0 at inteldrm0
inteldrm0: msi
error: [drm:pid0:i915_firmware_load_error_print] *ERROR* failed to load 
firmware i915/kbl_dmc_ver1.bin (-22)
inteldrm0: 1920x1080, 32bpp
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation)
wsdisplay0: screen 1-5 added (std, vt100 emulation)
"Intel Core GMM" rev 0x00 at pci0 dev 8 function 0 not configured
xhci0 at pci0 dev 20 function 0 "Intel 100 Series xHCI" rev 0x21: msi, xHCI 1.0
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 "Intel xHCI root hub" rev 3.00/1.00 
addr 1
pchtemp0 at pci0 dev 20 function 2 "Intel 100 Series Thermal" rev 0x21
"Intel 100 Series MEI" rev 0x21 at pci0 dev 22 function 0 not configured
ahci0 at pci0 dev 23 function 0 "Intel 100 Series AHCI" rev 0x21: msi, AHCI 
1.3.1
ahci0: PHY offline on port 0
ahci0: port 2: 6.0Gb/s
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 2 lun 0: <ATA, WDC WDS240G1G0B-, Z331> SCSI3 0/direct 
fixed naa.5001b448b4de6980
sd0: 228936MB, 512 bytes/sector, 468862128 sectors, thin
ppb0 at pci0 dev 28 function 0 "Intel 100 Series PCIE" rev 0xf1: msi
pci1 at ppb0 bus 1
xhci1 at pci1 dev 0 function 0 "ASMedia ASM1042AE xHCI" rev 0x00: msi, xHCI 1.10
usb1 at xhci1: USB revision 3.0
uhub1 at usb1 configuration 1 interface 0 "ASMedia xHCI root hub" rev 3.00/1.00 
addr 1
ppb1 at pci0 dev 28 function 2 "Intel 100 Series PCIE" rev 0xf1: msi
pci2 at ppb1 bus 2
iwm0 at pci2 dev 0 function 0 "Intel Dual Band Wireless-AC 8265" rev 0x78, msi
ppb2 at pci0 dev 28 function 5 "Intel 100 Series PCIE" rev 0xf1: msi
pci3 at ppb2 bus 3
rtsx0 at pci3 dev 0 function 0 "Realtek RTL8411B Card Reader" rev 0x01: msi
sdmmc0 at rtsx0: 4-bit, dma
re0 at pci3 dev 0 function 1 "Realtek 8168" rev 0x12: RTL8411B (0x5c80), msi, 
address 80:fa:5b:43:62:91
rgephy0 at re0 phy 7: RTL8251 PHY, rev. 0
pcib0 at pci0 dev 31 function 0 "Intel 200 Series LPC" rev 0x21
"Intel 100 Series PMC" rev 0x21 at pci0 dev 31 function 2 not configured
azalia0 at pci0 dev 31 function 3 "Intel 200 Series HD Audio" rev 0x21: msi
azalia0: codecs: Realtek ALC269, Intel/0x280b, using Realtek ALC269
audio0 at azalia0
ichiic0 at pci0 dev 31 function 4 "Intel 100 Series SMBus" rev 0x21: apic 2 int 
16
iic0 at ichiic0
iic0: addr 0x2c 80=04 81=04 82=04 83=04 84=04 85=04 86=04 87=04 fd=01 words 
00=ffff 01=ffff 02=ffff 03=ffff 04=ffff 05=ffff 06=ffff 07=ffff
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pckbd0 at pckbc0 (kbd slot)
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pms0 at pckbc0 (aux slot)
wsmouse0 at pms0 mux 0
pms0: Synaptics touchpad, firmware 8.2, 0x1e2b1 0x840300
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
vmm0 at mainbus0: VMX/EPT (using slow L1TF mitigation)
efifb at mainbus0 not configured
ugen0 at uhub0 port 5 "Intel Bluetooth" rev 2.00/0.10 addr 2
uvideo0 at uhub0 port 6 configuration 1 interface 0 "Chicony Electronics 
Co.,Ltd. Chicony USB2.0 Camera" rev 2.00/10.19 addr 3
video0 at uvideo0
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on sd0a (2ae1c772b7608e2a.a) swap on sd0b dump on sd0b
iwm0: hw rev 0x230, fw ver 22.361476.0, address 00:28:f8:73:b3:3d

usbdevs:
Controller /dev/usb0:
addr 01: 8086:0000 Intel, xHCI root hub
         super speed, self powered, config 1, rev 1.00
         driver: uhub0
addr 02: 8087:0a2b Intel, Bluetooth
         full speed, self powered, config 1, rev 0.10
         driver: ugen0
addr 03: 04f2:b59e Chicony Electronics Co.,Ltd., Chicony USB2.0 Camera
         high speed, power 500 mA, config 1, rev 10.19, iSerial 200901010001
         driver: uvideo0
Controller /dev/usb1:
addr 01: 1b21:0000 ASMedia, xHCI root hub
         super speed, self powered, config 1, rev 1.00
         driver: uhub1

Attachment: signature.asc
Description: PGP signature

Reply via email to