Skip to content

Commit

Permalink
Linux: reject read/write mapping to immutable file only on VM_SHARED
Browse files Browse the repository at this point in the history
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 <msl0000023508@gmail.com>
  • Loading branch information
Low-power committed Oct 31, 2023
1 parent 799e09f commit 0cf4aad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions module/os/linux/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 0cf4aad

Please sign in to comment.