0
0
mirror of https://mirrors.bfsu.edu.cn/git/linux.git synced 2024-12-21 10:05:00 +08:00
linux/arch/xtensa/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
byteorder.h
ioctls.h tty: Fix TIOCGPTPEER ioctl definition 2017-07-17 17:04:41 +02:00
ipcbuf.h
Kbuild xtensa: move generic-y of exported headers to uapi/asm/Kbuild 2017-07-11 21:33:53 +09: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
param.h
poll.h
posix_types.h
ptrace.h xtensa: move internal ptrace definitions from uapi/asm to asm 2017-05-01 07:00:10 -07:00
sembuf.h
setup.h
shmbuf.h
sigcontext.h
signal.h xtensa: pull signal definitions from signal-defs.h 2013-02-23 19:12:52 -08:00
socket.h sock: add SOCK_ZEROCOPY sockopt 2017-08-03 21:37:29 -07:00
sockios.h
stat.h
swab.h
termbits.h
types.h xtensa: add alternative kernel memory layouts 2016-07-24 06:33:58 +03:00
unistd.h xtensa: wire up statx system call 2017-03-31 16:26:21 -07:00