• Chengguang Xu's avatar
    ovl: skip checking lower file's i_writecount on truncate · b71759ef
    Chengguang Xu authored
    
    
    It is possible that a directory tree is shared between multiple overlay
    instances as a lower layer.  In this case when one instance executes a file
    residing on the lower layer, the other instance denies a truncate(2) call
    on this file.
    
    This only happens for truncate(2) and not for open(2) with the O_TRUNC
    flag.
    
    Fix this interference and inconsistency by removing the preliminary
    i_writecount check before copy-up.
    
    This means that unlike on normal filesystems truncate(argv[0]) will now
    succeed.  If this ever causes a regression in a real world use case this
    needs to be revisited.
    
    One way to fix this properly would be to keep a correct i_writecount in the
    overlay inode, but that is difficult due to memory mapping code only
    dealing with the real file/inode.
    Signed-off-by: default avatarChengguang Xu <cgxu519@mykernel.net>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    b71759ef
overlayfs.rst 27.3 KB