Skip to content

Commit bacef45

Browse files
committed
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 segument of executable files, rejecting them will rendering immutable executable files to stop working. Signed-off-by: WHR <[email protected]>
1 parent e5d70f4 commit bacef45

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

4071-
if ((vm_flags & VM_WRITE) && (zp->z_pflags &
4072-
(ZFS_IMMUTABLE | ZFS_READONLY | ZFS_APPENDONLY))) {
4071+
if ((vm_flags & VM_WRITE) && (vm_flags & VM_SHARED) &&
4072+
(zp->z_pflags & (ZFS_IMMUTABLE | ZFS_READONLY | ZFS_APPENDONLY))) {
40734073
zfs_exit(zfsvfs, FTAG);
40744074
return (SET_ERROR(EPERM));
40754075
}

0 commit comments

Comments
 (0)