]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Linux: reject read/write mapping to immutable file only on VM_SHARED
authorLow-power <msl0000023508@gmail.com>
Wed, 8 Nov 2023 20:19:38 +0000 (04:19 +0800)
committerGitHub <noreply@github.com>
Wed, 8 Nov 2023 20:19:38 +0000 (12:19 -0800)
Private read/write mapping can't be used to modify the mapped files, so
they will remain be immutable. Private read/write mappings are usually
used to load the data segment of executable files, rejecting them will
rendering immutable executable files to stop working.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: WHR <msl0000023508@gmail.com>
Closes #15344

module/os/linux/zfs/zfs_vnops_os.c

index 6ad75ace0b5ca88cdba7279dd4a1c98e32bb1efb..1ae8023adc32b6ff2553112765ca842e1ac6ea73 100644 (file)
@@ -4078,8 +4078,8 @@ zfs_map(struct inode *ip, offset_t off, caddr_t *addrp, size_t len,
        if ((error = zfs_enter_verify_zp(zfsvfs, zp, FTAG)) != 0)
                return (error);
 
-       if ((vm_flags & VM_WRITE) && (zp->z_pflags &
-           (ZFS_IMMUTABLE | ZFS_READONLY | ZFS_APPENDONLY))) {
+       if ((vm_flags & VM_WRITE) && (vm_flags & VM_SHARED) &&
+           (zp->z_pflags & (ZFS_IMMUTABLE | ZFS_READONLY | ZFS_APPENDONLY))) {
                zfs_exit(zfsvfs, FTAG);
                return (SET_ERROR(EPERM));
        }