1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

The vm_mmap_cdev() explicitely converts absence of both MAP_SHARED and

MAP_PRIVATE flags to MAP_SHARED.  Apparently, some code in tree, in
particular, libgeom, relied on this behaviour, see r271721.  For
regular file types, the absence of the flags is interpreted as
MAP_PRIVATE, and libc nlist used this (fixed in r271723).

Allow the implicit flags for legacy binaries.  Bump __FreeBSD_version
to get the ABI note on new binaries to check for in mmap code.

Remove the test for presence of one of the MAP_ANON, MAP_SHARED or
MAP_PRIVATE flags before fget_mmap().  For MAP_ANON, we already verify
that passed fd == -1.  For fd != -1, test after fget_mmap() (for newer
binaries) covers the case.

Reported by:	bdrewery, pho
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Konstantin Belousov 2014-09-17 21:04:50 +00:00
parent 7eccb93c02
commit 10204535af
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=271724
2 changed files with 8 additions and 3 deletions

View File

@ -58,7 +58,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
#define __FreeBSD_version 1100035 /* Master, propagated to newvers */
#define __FreeBSD_version 1100036 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
@ -80,6 +80,7 @@
#define P_OSREL_SIGWAIT 700000
#define P_OSREL_SIGSEGV 700004
#define P_OSREL_MAP_ANON 800104
#define P_OSREL_MAP_FSTRICT 1100036
#define P_OSREL_MAJOR(x) ((x) / 100000)
#endif

View File

@ -254,8 +254,7 @@ sys_mmap(td, uap)
return (EINVAL);
if ((flags & (MAP_EXCL | MAP_FIXED)) == MAP_EXCL)
return (EINVAL);
if ((flags & (MAP_ANON | MAP_SHARED | MAP_PRIVATE)) == 0 ||
(flags & (MAP_SHARED | MAP_PRIVATE)) == (MAP_SHARED | MAP_PRIVATE))
if ((flags & (MAP_SHARED | MAP_PRIVATE)) == (MAP_SHARED | MAP_PRIVATE))
return (EINVAL);
if (prot != PROT_NONE &&
(prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) != 0)
@ -356,6 +355,11 @@ sys_mmap(td, uap)
error = fget_mmap(td, uap->fd, &rights, &cap_maxprot, &fp);
if (error != 0)
goto done;
if ((flags & (MAP_SHARED | MAP_PRIVATE)) == 0 &&
td->td_proc->p_osrel >= P_OSREL_MAP_FSTRICT) {
error = EINVAL;
goto done;
}
if (fp->f_type == DTYPE_SHM) {
handle = fp->f_data;
handle_type = OBJT_SWAP;