Skip to content

Commit

Permalink
device-dax: fix private mapping restriction, permit read-only
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
djbw committed Dec 7, 2016
1 parent a7de92d commit 325896f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/dax/dax.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static int check_vma(struct dax_dev *dax_dev, struct vm_area_struct *vma,
return -ENXIO;

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

0 comments on commit 325896f

Please sign in to comment.