>Synopsis: pax(1) gets stuck in a loop creating intermediate directories >Category: user >Environment: System : OpenBSD 5.8 Details : OpenBSD 5.8 (GENERIC.MP) #1236: Sun Aug 16 02:31:04 MDT 2015 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
Architecture: OpenBSD.amd64 Machine : amd64 >Description: Please note I could only test this on a -stable machine. pax(1) gets stuck in an infinite loop when recreating intermediate directories from a pathname ending with '/' while extracting a cpio archive >How-To-Repeat: mkdir -p /tmp/foo/bar # Note the '/' at the end of "/tmp/foo/bar/" below find /tmp/foo/bar/ | pax -wx cpio > /tmp/foobar.cpio # pax -r below never exits rm -r /tmp/foo && pax -r < /tmp/foobar.cpio >Fix: I did some digging and it seems pax gets stuck in a loop after calling node_creat (file_subs.c) to create /tmp/foo/bar: 1. At line 390 of file_subs.c there is a first attempt to create /tmp/foo/bar which fails because /tmp/foo does not exist. This happens in the function node_creat. 390 res = mkdir(nm, file_mode); 2. At line 463 chk_path is called in order to create the missing /tmp/foo. It turns out the first argument of chk_path is "/tmp/foo/bar/" (note the slash at the end) so chk_path creates /tmp, /tmp/foo and /tmp/foo/bar instead of just /tmp and /tmp/foo. 463 if (nodirs || chk_path(nm,arcn->sb.st_uid,arcn->sb.st_gid) < 0) { 464 syswarn(1, oerrno, "Could not create: %s", nm); 465 return(-1); 466 } 3. Now we're back at line 390: creating /tmp/foo/bar fails because this time the directory already exists. 4. At line 457 /tmp/foo/bar is removed: 457 if ((ign = unlnk_exist(nm, arcn->type)) < 0) 458 return(-1); 5. And we're back at line 463 where chk_path creates /tmp/foo/bar ... it's looping ... The first argument of chk_path seems to end with '/' because of the cpio format. I could not reproduce the problem with the ustar format. I did not look any further since I think it is chk_path which is at fault here. The diff below breaks out of the for loop when reaching the terminating '/'. /tmp/foo/bar should be created by node_creat, not by chk_path. (please note this is a diff against -stable, not against -current) Index: file_subs.c =================================================================== RCS file: /cvs/src/bin/pax/file_subs.c,v retrieving revision 1.47 diff -u -p -u -p -r1.47 file_subs.c --- file_subs.c 19 Mar 2015 05:14:24 -0000 1.47 +++ file_subs.c 13 Feb 2016 21:55:34 -0000 @@ -611,7 +611,7 @@ chk_path(char *name, uid_t st_uid, gid_t * work forward from the first / and check each part of the path */ spt = strchr(spt, '/'); - if (spt == NULL) + if (spt == NULL || (*spt == '/' && *(spt+1) == '\0')) break; *spt = '\0'; dmesg: OpenBSD 5.8 (GENERIC.MP) #1236: Sun Aug 16 02:31:04 MDT 2015 dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP real mem = 2120941568 (2022MB) avail mem = 2052829184 (1957MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root bios0 at mainbus0: SMBIOS rev. 2.6 @ 0xfc8b0 (23 entries) bios0: vendor American Megatrends Inc. version "080015" date 05/03/2012 bios0: Standard XS35 acpi0 at bios0: rev 2 acpi0: sleep states S0 S3 S4 S5 acpi0: tables DSDT FACP APIC MCFG SLIC OEMB HPET GSCI acpi0: wakeup devices P0P1(S4) AZAL(S3) P0P4(S4) P0P5(S4) JLAN(S3) P0P6(S4) P0P7(S4) P0P8(S4) P0P9(S4) USB0(S3) USB1(S3) USB2(S3) USB3(S3) EUSB(S3) 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) Atom(TM) CPU D525 @ 1.80GHz, 1795.77 MHz 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,DTES64,MWAIT,DS-CPL,TM2,SSSE3,CX16,xTPR,PDCM,MOVBE,NXE,LONG,LAHF,PERF,SENSOR cpu0: 512KB 64b/line 8-way L2 cache cpu0: smt 0, core 0, package 0 mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges cpu0: apic clock running at 199MHz cpu0: mwait min=64, max=64, C-substates=0.1, IBE cpu1 at mainbus0: apid 2 (application processor) cpu1: Intel(R) Atom(TM) CPU D525 @ 1.80GHz, 1797.40 MHz 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,DTES64,MWAIT,DS-CPL,TM2,SSSE3,CX16,xTPR,PDCM,MOVBE,NXE,LONG,LAHF,PERF,SENSOR cpu1: 512KB 64b/line 8-way L2 cache cpu1: smt 0, core 1, package 0 cpu2 at mainbus0: apid 1 (application processor) cpu2: Intel(R) Atom(TM) CPU D525 @ 1.80GHz, 1797.40 MHz 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,DTES64,MWAIT,DS-CPL,TM2,SSSE3,CX16,xTPR,PDCM,MOVBE,NXE,LONG,LAHF,PERF,SENSOR cpu2: 512KB 64b/line 8-way L2 cache cpu2: smt 1, core 0, package 0 cpu3 at mainbus0: apid 3 (application processor) cpu3: Intel(R) Atom(TM) CPU D525 @ 1.80GHz, 1797.40 MHz 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,DTES64,MWAIT,DS-CPL,TM2,SSSE3,CX16,xTPR,PDCM,MOVBE,NXE,LONG,LAHF,PERF,SENSOR cpu3: 512KB 64b/line 8-way L2 cache cpu3: smt 1, core 1, package 0 ioapic0 at mainbus0: apid 4 pa 0xfec00000, version 20, 24 pins ioapic0: misconfigured as apic 3, remapped to apid 4 acpimcfg0 at acpi0 addr 0xe0000000, bus 0-255 acpihpet0 at acpi0: 14318179 Hz acpiprt0 at acpi0: bus 0 (PCI0) acpiprt1 at acpi0: bus 4 (P0P1) acpiprt2 at acpi0: bus 1 (P0P4) acpiprt3 at acpi0: bus 2 (P0P5) acpiprt4 at acpi0: bus -1 (P0P6) acpiprt5 at acpi0: bus 3 (P0P7) acpiprt6 at acpi0: bus -1 (P0P8) acpiprt7 at acpi0: bus -1 (P0P9) acpiec0 at acpi0 acpicpu0 at acpi0: C1(@1 halt!) acpicpu1 at acpi0: C1(@1 halt!) acpicpu2 at acpi0: C1(@1 halt!) acpicpu3 at acpi0: C1(@1 halt!) acpitz0 at acpi0: critical temperature is 104 degC acpibtn0 at acpi0: SLPB acpibtn1 at acpi0: PWRB acpivideo0 at acpi0: GFX0 acpivout0 at acpivideo0: LCD_ pci0 at mainbus0 bus 0 0:31:2: mem address conflict 0xfc00/0x400 pchb0 at pci0 dev 0 function 0 "Intel Pineview DMI" rev 0x02 vga1 at pci0 dev 2 function 0 "Intel Pineview Video" rev 0x02 intagp0 at vga1 agp0 at intagp0: aperture at 0xd0000000, size 0x10000000 inteldrm0 at vga1 drm0 at inteldrm0 drm: fixme: max PWM is zero inteldrm0: 1024x768 wsdisplay0 at vga1 mux 1: console (std, vt100 emulation) wsdisplay0: screen 1-5 added (std, vt100 emulation) "Intel Pineview Video" rev 0x02 at pci0 dev 2 function 1 not configured azalia0 at pci0 dev 27 function 0 "Intel 82801GB HD Audio" rev 0x02: msi azalia0: codecs: IDT 92HD81B1X audio0 at azalia0 ppb0 at pci0 dev 28 function 0 "Intel 82801GB PCIE" rev 0x02: msi pci1 at ppb0 bus 1 ppb1 at pci0 dev 28 function 1 "Intel 82801GB PCIE" rev 0x02: msi pci2 at ppb1 bus 2 "JMicron SD/MMC" rev 0x80 at pci2 dev 0 function 0 not configured sdhc0 at pci2 dev 0 function 2 "JMicron SD Host Controller" rev 0x80: apic 4 int 18 sdmmc0 at sdhc0 "JMicron Memory Stick" rev 0x80 at pci2 dev 0 function 3 not configured jme0 at pci2 dev 0 function 5 "JMicron JMC250" rev 0x03: msi, address 80:ee:73:3d:3c:eb jmphy0 at jme0 phy 1: JMP211 10/100/1000 PHY, rev. 1 ppb2 at pci0 dev 28 function 3 "Intel 82801GB PCIE" rev 0x02: msi pci3 at ppb2 bus 3 rtwn0 at pci3 dev 0 function 0 "Realtek 8188CE" rev 0x01: msi rtwn0: MAC/BB RTL8188CE, RF 6052 1T1R, address e0:91:53:73:58:ab uhci0 at pci0 dev 29 function 0 "Intel 82801GB USB" rev 0x02: apic 4 int 23 uhci1 at pci0 dev 29 function 1 "Intel 82801GB USB" rev 0x02: apic 4 int 19 uhci2 at pci0 dev 29 function 2 "Intel 82801GB USB" rev 0x02: apic 4 int 18 uhci3 at pci0 dev 29 function 3 "Intel 82801GB USB" rev 0x02: apic 4 int 16 ehci0 at pci0 dev 29 function 7 "Intel 82801GB USB" rev 0x02: apic 4 int 23 usb0 at ehci0: USB revision 2.0 uhub0 at usb0 "Intel EHCI root hub" rev 2.00/1.00 addr 1 ppb3 at pci0 dev 30 function 0 "Intel 82801BAM Hub-to-PCI" rev 0xe2 pci4 at ppb3 bus 4 pcib0 at pci0 dev 31 function 0 "Intel NM10 LPC" rev 0x02 pciide0 at pci0 dev 31 function 2 "Intel 82801GB SATA" rev 0x02: DMA, channel 0 configured to native-PCI, channel 1 configured to native-PCI pciide0: using apic 4 int 19 for native-PCI interrupt wd0 at pciide0 channel 0 drive 0: <WDC WD1600BPVT-22JJ5T0> wd0: 16-sector PIO, LBA48, 152627MB, 312581808 sectors wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 6 ichiic0 at pci0 dev 31 function 3 "Intel 82801GB SMBus" rev 0x02: apic 4 int 19 iic0 at ichiic0 spdmem0 at iic0 addr 0x50: 2GB DDR3 SDRAM PC3-10600 SO-DIMM usb1 at uhci0: USB revision 1.0 uhub1 at usb1 "Intel UHCI root hub" rev 1.00/1.00 addr 1 usb2 at uhci1: USB revision 1.0 uhub2 at usb2 "Intel UHCI root hub" rev 1.00/1.00 addr 1 usb3 at uhci2: USB revision 1.0 uhub3 at usb3 "Intel UHCI root hub" rev 1.00/1.00 addr 1 usb4 at uhci3: USB revision 1.0 uhub4 at usb4 "Intel UHCI root hub" rev 1.00/1.00 addr 1 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 pcppi0 at isa0 port 0x61 spkr0 at pcppi0 vscsi0 at root scsibus1 at vscsi0: 256 targets softraid0 at root scsibus2 at softraid0: 256 targets root on wd0a (17932b8d58a6d0f1.a) swap on wd0b dump on wd0b usbdevs: Controller /dev/usb0: addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), Intel(0x8086), rev 1.00 port 1 powered port 2 powered port 3 powered port 4 powered port 5 powered port 6 powered port 7 powered port 8 powered Controller /dev/usb1: addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x8086), rev 1.00 port 1 powered port 2 powered Controller /dev/usb2: addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x8086), rev 1.00 port 1 powered port 2 powered Controller /dev/usb3: addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x8086), rev 1.00 port 1 powered port 2 powered Controller /dev/usb4: addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x8086), rev 1.00 port 1 powered port 2 powered