On Tue, 2009-07-07 at 13:40 -0400, Mike Frysinger wrote:
> On Tue, Jul 7, 2009 at 05:32, <[email protected]> wrote:
> > Modified: branches/2009R1/mm/nommu.c (6938 => 6939)
> >
> >             if (!file->f_op->read)
> >                     capabilities &= ~BDI_CAP_MAP_COPY;
> >
> > +            /* The file shall have been opened with read permission. */
> > +           if (!(file->f_mode & FMODE_READ))
> > +                   return -EACCES;
> > +
> >             if (flags & MAP_SHARED) {
> >                     /* do checks for writing, appending and locking */
> >                     if ((prot & PROT_WRITE) &&
> 
> doesnt this reject all mmap()'s if the fd isnt opened for reading ?
> this isnt correct as there is nothing wrong with opening a fd for
> writing only and then mmap()ing it for writing only.
> 
> it should be like the check a few lines below where it checks prot for
> PROT_READ and compares it to the f_mode having FMODE_READ:
>             if ((prot & PROT_WRITE) &&
>                 !(file->f_mode & FMODE_WRITE))
>                 return -EACCES;
> -mike

I found that mmu version of do_mmap_pgoff() imply open the file with
FMODE_READ before mmap. Both the MAP_PRIVATE and MAP_SHARED path will
check the file's read permission. If no, it will return -EACCES.

On the other hand, the POSIX said:
"The implementation shall support at least the following values of prot:
PROT_NONE, PROT_READ, PROT_WRITE, and the bitwise-inclusive OR of
PROT_READ and PROT_WRITE. The file descriptor fildes shall have been
opened with read permission, regardless of the protection options
specified."
-Graff

_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to