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 3, 2023
1 parent e5d70f4 commit 66fadf0
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 @@ -4068,8 +4068,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))) {

Check failure on line 4072 in module/os/linux/zfs/zfs_vnops_os.c

View workflow job for this annotation

GitHub Actions / checkstyle

indent by spaces instead of tabs
zfs_exit(zfsvfs, FTAG);
return (SET_ERROR(EPERM));
}
Expand Down

0 comments on commit 66fadf0

Please sign in to comment.