linux/arch/mips/include/uapi/asm
Dan Williams 1c97259740 mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flags
The mmap(2) syscall suffers from the ABI anti-pattern of not validating
unknown flags. However, proposals like MAP_SYNC need a mechanism to
define new behavior that is known to fail on older kernels without the
support. Define a new MAP_SHARED_VALIDATE flag pattern that is
guaranteed to fail on all legacy mmap implementations.

It is worth noting that the original proposal was for a standalone
MAP_VALIDATE flag. However, when that  could not be supported by all
archs Linus observed:

    I see why you *think* you want a bitmap. You think you want
    a bitmap because you want to make MAP_VALIDATE be part of MAP_SYNC
    etc, so that people can do

    ret = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED
		    | MAP_SYNC, fd, 0);

    and "know" that MAP_SYNC actually takes.

    And I'm saying that whole wish is bogus. You're fundamentally
    depending on special semantics, just make it explicit. It's already
    not portable, so don't try to make it so.

    Rename that MAP_VALIDATE as MAP_SHARED_VALIDATE, make it have a value
    of 0x3, and make people do

    ret = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED_VALIDATE
		    | MAP_SYNC, fd, 0);

    and then the kernel side is easier too (none of that random garbage
    playing games with looking at the "MAP_VALIDATE bit", but just another
    case statement in that map type thing.

    Boom. Done.

Similar to ->fallocate() we also want the ability to validate the
support for new flags on a per ->mmap() 'struct file_operations'
instance basis.  Towards that end arrange for flags to be generically
validated against a mmap_supported_flags exported by 'struct
file_operations'. By default all existing flags are implicitly
supported, but new flags require MAP_SHARED_VALIDATE and
per-instance-opt-in.

Cc: Jan Kara <jack@suse.cz>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Christoph Hellwig <hch@lst.de>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2017-11-03 06:26:22 -07:00
..
auxvec.h MIPS: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO 2016-07-28 12:06:16 +02:00
bitfield.h MIPS: Move definition of __BITFIELD_FIELD to sharable header. 2014-05-21 11:12:45 +02:00
bitsperlong.h
break.h MIPS: Add uprobes support. 2015-09-03 12:08:05 +02:00
byteorder.h
cachectl.h MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
errno.h errno.h: remove "NFS" from descriptions in comments 2013-11-13 12:09:12 +09:00
fcntl.h Merge branch '3.10-fixes' into mips-for-linux-next 2013-07-12 18:11:43 +02:00
hwcap.h MIPS: AT_HWCAP aux vector infrastructure 2015-09-03 12:07:59 +02:00
inst.h MIPS: microMIPS: Fix decoding of swsp16 instruction 2017-09-06 13:20:25 +02:00
ioctl.h
ioctls.h tty: Fix TIOCGPTPEER ioctl definition 2017-07-17 17:04:41 +02:00
Kbuild uapi: export all headers under uapi directories 2017-05-11 00:21:54 +09:00
kvm_para.h MIPS: Add functions for hypervisor call 2014-05-30 21:01:11 +02:00
kvm.h kvm: make KVM_COALESCED_MMIO_PAGE_OFFSET public 2017-04-07 16:49:01 +02:00
mman.h mm: introduce MAP_SHARED_VALIDATE, a mechanism to safely define new mmap flags 2017-11-03 06:26:22 -07:00
msgbuf.h MIPS: <uapi/asm/msgbuf.h>: Don't reference CONFIG_* symbols. 2013-06-18 16:28:16 +02:00
param.h
poll.h
posix_types.h
ptrace.h MIPS: ptrace.h: Add a missing include 2014-10-23 13:23:08 +02:00
reg.h MIPS: asm/reg.h: Move to uapi 2014-08-02 00:06:38 +02:00
resource.h MIPS: <uapi/asm/resource.h: Don't reference CONFIG_* symbols. 2013-06-18 16:28:15 +02:00
sembuf.h MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
setup.h
sgidefs.h
shmbuf.h
sigcontext.h MIPS: Add definitions for extended context 2015-09-03 12:07:58 +02:00
siginfo.h mips/signal: In force_fcr31_sig return in the impossible case 2017-08-17 17:31:27 -05:00
signal.h MIPS: Delete definition of SA_RESTORER. 2013-04-05 15:10:51 +02:00
socket.h sock: add SOCK_ZEROCOPY sockopt 2017-08-03 21:37:29 -07:00
sockios.h MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
stat.h MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
statfs.h MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
swab.h MIPS: UAPI: Ignore __arch_swab{16,32,64} when using MIPS16 2015-10-05 11:30:23 +02:00
sysmips.h MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
termbits.h MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
termios.h MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
types.h MIPS: Add __SANE_USERSPACE_TYPES__ to asm/types.h for LL64 2014-05-28 10:51:13 +02:00
ucontext.h MIPS: Add definitions for extended context 2015-09-03 12:07:58 +02:00
unistd.h MIPS: Wire up statx system call 2017-03-08 12:11:13 +01:00