Bug 1749860

Summary: mkisofs should not create hardlinked directories
Product: Red Hat Enterprise Linux 8 Reporter: Frank Sorenson <fsorenso>
Component: cdrkitAssignee: Jiri Kucera <jkucera>
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: jkucera, ovasik, swhiteho
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-03-12 21:12:56 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:

Description Frank Sorenson 2019-09-06 15:18:09 UTC
Description of problem:


    Certain directory structures inside the directory from which the iso is created can result in mkisofs creating hardlinked directories.

    hardlinked directories should never be created.


Version-Release number of selected component (if applicable):

    all versions


How reproducible:

    easy; see steps below


Steps to Reproduce:


    # cd /var/tmp
    # mkdir -p iso_root/dir{1,2,3}
    # mkdir -p iso_root/dir3/subdir
    # touch iso_root/dir1/testfile{1,2,3}
    # mount -obind iso_root/dir1 iso_root/dir2
    # mount -obind iso_root/dir3 iso_root/dir3/subdir

    # mkisofs -o out.iso -fRJ iso_root

    # mount -oloop out.iso /mnt/tmp >/dev/null 2>&1

    # ls -lid /mnt/tmp/dir1 /mnt/tmp/dir2 /mnt/tmp/dir3 /mnt/tmp/dir3/subdir


Actual results:

    # ls -lid /mnt/tmp/dir1 /mnt/tmp/dir2 /mnt/tmp/dir3 /mnt/tmp/dir3/subdir
    1856 drwxr-xr-x. 2 root root 2048 Sep  5 13:43 /mnt/tmp/dir1
    1856 drwxr-xr-x. 2 root root 2048 Sep  5 13:43 /mnt/tmp/dir2
    1984 drwxr-xr-x. 3 root root 2048 Sep  5 10:27 /mnt/tmp/dir3
    1984 drwxr-xr-x. 3 root root 2048 Sep  5 10:27 /mnt/tmp/dir3/subdir

    this results in two instances of hardinked directories:
    both dir1 and dir2 have the same inode
    both dir3 and dir3/subdir have the same inode, so this is a true directory loop


    when mounted in linux, depending on the kernel running on the system on which the iso is mounted, the kernel may return EIO when a second (or 3rd+) is encountered, or may silently handle the duplicated inode.


Expected results:

    hardlinked directories should never be created

    mkisofs should refuse to create hardlinked directories with a fatal error.

    Alternately, mkisofs could transform subsequent instances of a directory into a symlink to the first, or perhaps create a second directory, but still hardlink the file contents



Additional info:

    an alternate way to create the root (without bind mounts) is the following:
    # mkdir -p iso_root/release-{1.0,1.1,1.2,latest}
    # mount server:/exports/rpms/rpms-1.0 iso_root/release-1.0
    # mount server:/exports/rpms/rpms-1.1 iso_root/release-1.1
    # mount server:/exports/rpms/rpms-1.2 iso_root/release-1.2
    # mount server:/exports/rpms/rpms-1.2 iso_root/release-latest

    release-1.2 and release-latest will both have the same inode


    note that bz1749390 has also been raised to address some in-kernel handling of the duplicate directory inodes in some rhel 7 kernels