Skip to content

Commit f2fe4d5

Browse files
Low-powertonyhutter
authored andcommitted
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 openzfs#15344
1 parent 76663fe commit f2fe4d5

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
@@ -4071,8 +4071,8 @@ zfs_map(struct inode *ip, offset_t off, caddr_t *addrp, size_t len,
40714071
if ((error = zfs_enter_verify_zp(zfsvfs, zp, FTAG)) != 0)
40724072
return (error);
40734073

4074-
if ((vm_flags & VM_WRITE) && (zp->z_pflags &
4075-
(ZFS_IMMUTABLE | ZFS_READONLY | ZFS_APPENDONLY))) {
4074+
if ((vm_flags & VM_WRITE) && (vm_flags & VM_SHARED) &&
4075+
(zp->z_pflags & (ZFS_IMMUTABLE | ZFS_READONLY | ZFS_APPENDONLY))) {
40764076
zfs_exit(zfsvfs, FTAG);
40774077
return (SET_ERROR(EPERM));
40784078
}

0 commit comments

Comments
 (0)