Skip to content

Commit a160c15

Browse files
authored
Linux: reject read/write mapping to immutable file only on VM_SHARED
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 <[email protected]> Signed-off-by: WHR <[email protected]> Closes #15344
1 parent 3a81bf4 commit a160c15

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

module/os/linux/zfs/zfs_vnops_os.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4078,8 +4078,8 @@ zfs_map(struct inode *ip, offset_t off, caddr_t *addrp, size_t len,
40784078
if ((error = zfs_enter_verify_zp(zfsvfs, zp, FTAG)) != 0)
40794079
return (error);
40804080

4081-
if ((vm_flags & VM_WRITE) && (zp->z_pflags &
4082-
(ZFS_IMMUTABLE | ZFS_READONLY | ZFS_APPENDONLY))) {
4081+
if ((vm_flags & VM_WRITE) && (vm_flags & VM_SHARED) &&
4082+
(zp->z_pflags & (ZFS_IMMUTABLE | ZFS_READONLY | ZFS_APPENDONLY))) {
40834083
zfs_exit(zfsvfs, FTAG);
40844084
return (SET_ERROR(EPERM));
40854085
}

0 commit comments

Comments
 (0)