Skip to content

Commit 325896f

Browse files
committed
device-dax: fix private mapping restriction, permit read-only
Hugh notes in response to commit 4cb1935 "device-dax: fail all private mapping attempts": "I think that is more restrictive than you intended: haven't tried, but I believe it rejects a PROT_READ, MAP_SHARED, O_RDONLY fd mmap, leaving no way to mmap /dev/dax without write permission to it." Indeed it does restrict read-only mappings, switch to checking VM_MAYSHARE, not VM_SHARED. Cc: <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Pawel Lebioda <[email protected]> Fixes: 4cb1935 ("device-dax: fail all private mapping attempts") Reported-by: Hugh Dickins <[email protected]> Signed-off-by: Dan Williams <[email protected]>
1 parent a7de92d commit 325896f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/dax/dax.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static int check_vma(struct dax_dev *dax_dev, struct vm_area_struct *vma,
271271
return -ENXIO;
272272

273273
/* prevent private mappings from being established */
274-
if ((vma->vm_flags & VM_SHARED) != VM_SHARED) {
274+
if ((vma->vm_flags & VM_MAYSHARE) != VM_MAYSHARE) {
275275
dev_info(dev, "%s: %s: fail, attempted private mapping\n",
276276
current->comm, func);
277277
return -EINVAL;

0 commit comments

Comments
 (0)