Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28d7a6ae authored by Graff Yang's avatar Graff Yang Committed by Linus Torvalds
Browse files

nommu: check fd read permission in validate_mmap_request()



According to the POSIX (1003.1-2008), the file descriptor shall have been
opened with read permission, regardless of the protection options specified to
mmap().  The ltp test cases mmap06/07 need this.

Signed-off-by: default avatarGraff Yang <graff.yang@gmail.com>
Acked-by: default avatarPaul Mundt <lethal@linux-sh.org>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarGreg Ungerer <gerg@snapgear.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 19152975
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -919,6 +919,10 @@ static int validate_mmap_request(struct file *file,
		if (!file->f_op->read)
		if (!file->f_op->read)
			capabilities &= ~BDI_CAP_MAP_COPY;
			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) {
		if (flags & MAP_SHARED) {
			/* do checks for writing, appending and locking */
			/* do checks for writing, appending and locking */
			if ((prot & PROT_WRITE) &&
			if ((prot & PROT_WRITE) &&