28 Sep, 2016

1 commit

  • After 7e8e385aaf6e ("x86/compat: Remove sys32_vm86_warning"), this
    function has become unused, so we can remove it as well.

    Link: http://lkml.kernel.org/r/20160617142903.3070388-1-arnd@arndb.de
    Signed-off-by: Arnd Bergmann
    Cc: Alexander Viro
    Cc: "Theodore Ts'o"
    Cc: Arnaldo Carvalho de Melo
    Signed-off-by: Andrew Morton

    Arnd Bergmann
     

23 Mar, 2016

1 commit

  • A lot of code currently abuses is_compat_task to determine this.

    Signed-off-by: Andy Lutomirski
    Cc: "David S. Miller"
    Cc: "H. Peter Anvin"
    Cc: "Theodore Ts'o"
    Cc: Andreas Dilger
    Cc: Clemens Ladisch
    Cc: David Airlie
    Cc: David Herrmann
    Cc: David Miller
    Cc: Dmitry Torokhov
    Cc: Eric Paris
    Cc: Herbert Xu
    Cc: Ingo Molnar
    Acked-by: Jiri Kosina
    Cc: Matt Fleming
    Cc: Neil Horman
    Cc: Oded Gabbay
    Cc: Oleg Drokin
    Cc: Oleg Nesterov
    Cc: Paul Moore
    Cc: Sam Ravnborg
    Cc: Steffen Klassert
    Cc: Thomas Gleixner
    Cc: Vlad Yasevich
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Lutomirski
     

05 Mar, 2016

1 commit

  • New syscalls that take an flag argument. No flags are added yet in this
    patch.

    Signed-off-by: Milosz Tanski
    [hch: rebased on top of my kiocb changes]
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Stephen Bates
    Tested-by: Stephen Bates
    Acked-by: Jeff Moyer
    Signed-off-by: Al Viro

    Milosz Tanski
     

18 Jul, 2015

1 commit

  • Using __printf attributes helps to detect several format string issues
    at compile time (even though -Wformat-security is currently disabled in
    Makefile). For example it can detect when formatting a pointer as a
    number, like the issue fixed in commit a3fa71c40f18 ("wl18xx: show
    rx_frames_per_rates as an array as it really is"), or when the arguments
    do not match the format string, c.f. for example commit 5ce1aca81435
    ("reiserfs: fix __RASSERT format string").

    To prevent similar bugs in the future, add a __printf attribute to every
    function prototype which needs one in include/linux/ and lib/. These
    functions were mostly found by using gcc's -Wsuggest-attribute=format
    flag.

    Signed-off-by: Nicolas Iooss
    Cc: Greg Kroah-Hartman
    Cc: Felipe Balbi
    Cc: Joel Becker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nicolas Iooss
     

27 Jan, 2015

1 commit


14 Dec, 2014

1 commit

  • This patchset adds execveat(2) for x86, and is derived from Meredydd
    Luff's patch from Sept 2012 (https://lkml.org/lkml/2012/9/11/528).

    The primary aim of adding an execveat syscall is to allow an
    implementation of fexecve(3) that does not rely on the /proc filesystem,
    at least for executables (rather than scripts). The current glibc version
    of fexecve(3) is implemented via /proc, which causes problems in sandboxed
    or otherwise restricted environments.

    Given the desire for a /proc-free fexecve() implementation, HPA suggested
    (https://lkml.org/lkml/2006/7/11/556) that an execveat(2) syscall would be
    an appropriate generalization.

    Also, having a new syscall means that it can take a flags argument without
    back-compatibility concerns. The current implementation just defines the
    AT_EMPTY_PATH and AT_SYMLINK_NOFOLLOW flags, but other flags could be
    added in future -- for example, flags for new namespaces (as suggested at
    https://lkml.org/lkml/2006/7/11/474).

    Related history:
    - https://lkml.org/lkml/2006/12/27/123 is an example of someone
    realizing that fexecve() is likely to fail in a chroot environment.
    - http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=514043 covered
    documenting the /proc requirement of fexecve(3) in its manpage, to
    "prevent other people from wasting their time".
    - https://bugzilla.redhat.com/show_bug.cgi?id=241609 described a
    problem where a process that did setuid() could not fexecve()
    because it no longer had access to /proc/self/fd; this has since
    been fixed.

    This patch (of 4):

    Add a new execveat(2) system call. execveat() is to execve() as openat()
    is to open(): it takes a file descriptor that refers to a directory, and
    resolves the filename relative to that.

    In addition, if the filename is empty and AT_EMPTY_PATH is specified,
    execveat() executes the file to which the file descriptor refers. This
    replicates the functionality of fexecve(), which is a system call in other
    UNIXen, but in Linux glibc it depends on opening "/proc/self/fd/" (and
    so relies on /proc being mounted).

    The filename fed to the executed program as argv[0] (or the name of the
    script fed to a script interpreter) will be of the form "/dev/fd/"
    (for an empty filename) or "/dev/fd//", effectively
    reflecting how the executable was found. This does however mean that
    execution of a script in a /proc-less environment won't work; also, script
    execution via an O_CLOEXEC file descriptor fails (as the file will not be
    accessible after exec).

    Based on patches by Meredydd Luff.

    Signed-off-by: David Drysdale
    Cc: Meredydd Luff
    Cc: Shuah Khan
    Cc: "Eric W. Biederman"
    Cc: Andy Lutomirski
    Cc: Alexander Viro
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Kees Cook
    Cc: Arnd Bergmann
    Cc: Rich Felker
    Cc: Christoph Hellwig
    Cc: Michael Kerrisk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Drysdale
     

03 Apr, 2014

1 commit

  • Pull compat time conversion changes from Peter Anvin:
    "Despite the branch name this is really neither an x86 nor an
    x32-specific patchset, although it the implementation of the
    discussions that followed the x32 security hole a few months ago.

    This removes get/put_compat_timespec/val() and replaces them with
    compat_get/put_timespec/val() which are savvy as to the current status
    of COMPAT_USE_64BIT_TIME.

    It removes several unused and/or incorrect/misleading functions (like
    compat_put_timeval_convert which doesn't in fact do any conversion)
    and also replaces several open-coded implementations what is now
    called compat_convert_timespec() with that function"

    * 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    compat: Fix sparse address space warnings
    compat: Get rid of (get|put)_compat_time(val|spec)

    Linus Torvalds
     

20 Mar, 2014

1 commit

  • linux/compat.h does not include linux/unistd.h but the compat.h header
    file contains various conditional

    #ifdef __ARCH_WANT_COMPAT_...
    asmlinkage long compat...()
    #endif

    compat system call function declarations.
    If linux/unistd.h isn't included it depends on previous includes if those
    __ARCH_WANT_COMPAT_... defines are defined or not. So add an additional
    linux/unistd.h include.

    Should fix this compile error on tile:

    include/uapi/asm-generic/unistd.h:195:1: error: 'compat_sys_getdents64' undeclared
    make[3]: *** [arch/tile/kernel/compat.o] Error 1

    Reported-by: Geert Uytterhoeven
    Acked-by: Geert Uytterhoeven
    Acked-by: Chris Metcalf
    Signed-off-by: Heiko Carstens

    Heiko Carstens
     

06 Mar, 2014

7 commits


04 Mar, 2014

2 commits

  • For consistency reason add a COMPAT_SYSCALL_DEFINE0 macro.
    This macro should be used for compat system calls with zero parameters.

    Signed-off-by: Heiko Carstens

    Heiko Carstens
     
  • For architecture dependent compat syscalls in common code an architecture
    must define something like __ARCH_WANT_ if it wants to use the
    code.
    This however is not true for compat_sys_getdents64 for which architectures
    must define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 if they do not want the code.

    This leads to the situation where all architectures, except mips, get the
    compat code but only x86_64, arm64 and the generic syscall architectures
    actually use it.

    So invert the logic, so that architectures actively must do something to
    get the compat code.

    This way a couple of architectures get rid of otherwise dead code.

    Signed-off-by: Heiko Carstens

    Heiko Carstens
     

03 Feb, 2014

1 commit

  • We have two APIs for compatiblity timespec/val, with confusingly
    similar names. compat_(get|put)_time(val|spec) *do* handle the case
    where COMPAT_USE_64BIT_TIME is set, whereas
    (get|put)_compat_time(val|spec) do not. This is an accident waiting
    to happen.

    Clean it up by favoring the full-service version; the limited version
    is replaced with double-underscore versions static to kernel/compat.c.

    A common pattern is to convert a struct timespec to kernel format in
    an allocation on the user stack. Unfortunately it is open-coded in
    several places. Since this allocation isn't actually needed if
    COMPAT_USE_64BIT_TIME is true (since user format == kernel format)
    encapsulate that whole pattern into the function
    compat_convert_timespec(). An equivalent function should be written
    for struct timeval if it is needed in the future.

    Finally, get rid of compat_(get|put)_timeval_convert(): each was only
    used once, and the latter was not even doing what the function said
    (no conversion actually was being done.) Moving the conversion into
    compat_sys_settimeofday() itself makes the code much more similar to
    sys_settimeofday() itself.

    v3: Remove unused compat_convert_timeval().

    v2: Drop bogus "const" in the destination argument for
    compat_convert_time*().

    Cc: Mauro Carvalho Chehab
    Cc: Alexander Viro
    Cc: Hans Verkuil
    Cc: Andrew Morton
    Cc: Heiko Carstens
    Cc: Manfred Spraul
    Cc: Mateusz Guzik
    Cc: Rafael Aquini
    Cc: Davidlohr Bueso
    Cc: Stephen Rothwell
    Cc: Dan Carpenter
    Cc: Arnd Bergmann
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: Linus Torvalds
    Cc: Catalin Marinas
    Cc: Will Deacon
    Tested-by: H.J. Lu
    Signed-off-by: H. Peter Anvin

    H. Peter Anvin
     

02 Feb, 2014

1 commit


01 Feb, 2014

1 commit


30 Jan, 2014

2 commits

  • Commit d5dc77bfeeab ("consolidate compat lookup_dcookie()") coverted all
    architectures to the new compat_sys_lookup_dcookie() syscall.

    The "len" paramater of the new compat syscall must have the type
    compat_size_t in order to enforce zero extension for architectures where
    the ABI requires that the caller of a function performed zero and/or
    sign extension to 64 bit of all parameters.

    Signed-off-by: Heiko Carstens
    Cc: Al Viro
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Hendrik Brueckner
    Cc: Martin Schwidefsky
    Cc: [v3.10+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     
  • We got a report that the pwritev syscall does not work correctly in
    compat mode on s390.

    It turned out that with commit 72ec35163f9f ("switch compat readv/writev
    variants to COMPAT_SYSCALL_DEFINE") we lost the zero extension of a
    couple of syscall parameters because the some parameter types haven't
    been converted from unsigned long to compat_ulong_t.

    This is needed for architectures where the ABI requires that the caller
    of a function performed zero and/or sign extension to 64 bit of all
    parameters.

    Signed-off-by: Heiko Carstens
    Cc: Al Viro
    Cc: Ingo Molnar
    Cc: "H. Peter Anvin"
    Cc: Hendrik Brueckner
    Cc: Martin Schwidefsky
    Cc: [v3.10+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     

13 Nov, 2013

2 commits

  • Merge first patch-bomb from Andrew Morton:
    "Quite a lot of other stuff is banked up awaiting further
    next->mainline merging, but this batch contains:

    - Lots of random misc patches
    - OCFS2
    - Most of MM
    - backlight updates
    - lib/ updates
    - printk updates
    - checkpatch updates
    - epoll tweaking
    - rtc updates
    - hfs
    - hfsplus
    - documentation
    - procfs
    - update gcov to gcc-4.7 format
    - IPC"

    * emailed patches from Andrew Morton : (269 commits)
    ipc, msg: fix message length check for negative values
    ipc/util.c: remove unnecessary work pending test
    devpts: plug the memory leak in kill_sb
    ./Makefile: export initial ramdisk compression config option
    init/Kconfig: add option to disable kernel compression
    drivers: w1: make w1_slave::flags long to avoid memory corruption
    drivers/w1/masters/ds1wm.cuse dev_get_platdata()
    drivers/memstick/core/ms_block.c: fix unreachable state in h_msb_read_page()
    drivers/memstick/core/mspro_block.c: fix attributes array allocation
    drivers/pps/clients/pps-gpio.c: remove redundant of_match_ptr
    kernel/panic.c: reduce 1 byte usage for print tainted buffer
    gcov: reuse kbasename helper
    kernel/gcov/fs.c: use pr_warn()
    kernel/module.c: use pr_foo()
    gcov: compile specific gcov implementation based on gcc version
    gcov: add support for gcc 4.7 gcov format
    gcov: move gcov structs definitions to a gcc version specific file
    kernel/taskstats.c: return -ENOMEM when alloc memory fails in add_del_listener()
    kernel/taskstats.c: add nla_nest_cancel() for failure processing between nla_nest_start() and nla_nest_end()
    kernel/sysctl_binary.c: use scnprintf() instead of snprintf()
    ...

    Linus Torvalds
     
  • Use standard gcc __attribute__((alias(foo))) to define the syscall aliases
    instead of custom assembler macros.

    This is far cleaner, and also fixes my LTO kernel build.

    Signed-off-by: Andi Kleen
    Cc: Al Viro
    Cc: Geert Uytterhoeven
    Cc: Tetsuo Handa
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     

09 Nov, 2013

1 commit


12 Sep, 2013

1 commit

  • Unclutter -Wmissing-prototypes warning types (enabled at make W=1)

    linux/include/linux/syscalls.h:190:18: warning: no previous prototype for 'SyS_semctl' [-Wmissing-prototypes]
    asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
    ^
    linux/include/linux/syscalls.h:183:2: note: in expansion of macro '__SYSCALL_DEFINEx'
    __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
    ^
    by adding forward declarations right before definitions.

    Signed-off-by: Sergei Trofimovich
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sergei Trofimovich
     

02 Sep, 2013

1 commit

  • For performance reasons, when SMAP is in use, SMAP is left open for an
    entire put_user_try { ... } put_user_catch(); block, however, calling
    __put_user() in the middle of that block will close SMAP as the
    STAC..CLAC constructs intentionally do not nest.

    Furthermore, using __put_user() rather than put_user_ex() here is bad
    for performance.

    Thus, introduce new [compat_]save_altstack_ex() helpers that replace
    __[compat_]save_altstack() for x86, being currently the only
    architecture which supports put_user_try { ... } put_user_catch().

    Reported-by: H. Peter Anvin
    Signed-off-by: Al Viro
    Signed-off-by: H. Peter Anvin
    Cc: # v3.8+
    Link: http://lkml.kernel.org/n/tip-es5p6y64if71k8p5u08agv9n@git.kernel.org

    Al Viro
     

10 May, 2013

1 commit


01 May, 2013

1 commit

  • Pull compat cleanup from Al Viro:
    "Mostly about syscall wrappers this time; there will be another pile
    with patches in the same general area from various people, but I'd
    rather push those after both that and vfs.git pile are in."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal:
    syscalls.h: slightly reduce the jungles of macros
    get rid of union semop in sys_semctl(2) arguments
    make do_mremap() static
    sparc: no need to sign-extend in sync_file_range() wrapper
    ppc compat wrappers for add_key(2) and request_key(2) are pointless
    x86: trim sys_ia32.h
    x86: sys32_kill and sys32_mprotect are pointless
    get rid of compat_sys_semctl() and friends in case of ARCH_WANT_OLD_COMPAT_IPC
    merge compat sys_ipc instances
    consolidate compat lookup_dcookie()
    convert vmsplice to COMPAT_SYSCALL_DEFINE
    switch getrusage() to COMPAT_SYSCALL_DEFINE
    switch epoll_pwait to COMPAT_SYSCALL_DEFINE
    convert sendfile{,64} to COMPAT_SYSCALL_DEFINE
    switch signalfd{,4}() to COMPAT_SYSCALL_DEFINE
    make SYSCALL_DEFINE-generated wrappers do asmlinkage_protect
    make HAVE_SYSCALL_WRAPPERS unconditional
    consolidate cond_syscall and SYSCALL_ALIAS declarations
    teach SYSCALL_DEFINE how to deal with long long/unsigned long long
    get rid of duplicate logics in __SC_....[1-6] definitions

    Linus Torvalds
     

20 Mar, 2013

1 commit

  • MIPS's siginfo handling has been broken since this commit:

    commit 574c4866e33d648520a8bd5bf6f573ea6e554e88
    Author: Al Viro
    Date: Sun Nov 25 22:24:19 2012 -0500
    consolidate kernel-side struct sigaction declarations

    for 64-bit BE MIPS CPUs.

    The UAPI variant looks like this:

    struct sigaction {
    unsigned int sa_flags;
    __sighandler_t sa_handler;
    sigset_t sa_mask;
    };

    but the core kernel's variant looks like this:

    struct sigaction {
    #ifndef __ARCH_HAS_ODD_SIGACTION
    __sighandler_t sa_handler;
    unsigned long sa_flags;
    #else
    unsigned long sa_flags;
    __sighandler_t sa_handler;
    #endif
    #ifdef __ARCH_HAS_SA_RESTORER
    __sigrestore_t sa_restorer;
    #endif
    sigset_t sa_mask;
    };

    The problem is that sa_flags has been changed from an unsigned int to an
    unsigned long.

    Fix this by making sa_flags unsigned int if __ARCH_HAS_ODD_SIGACTION is
    defined.

    Whilst we're at it, rename __ARCH_HAS_ODD_SIGACTION to
    __ARCH_HAS_IRIX_SIGACTION.

    Signed-off-by: David Howells
    Cc: linux-mips@linux-mips.org
    Cc: linux-kernel@vger.kernel.org
    Cc: stable@vger.kernel.org
    Acked-by: Al Viro
    Signed-off-by: Ralf Baechle

    David Howells
     

04 Mar, 2013

7 commits


25 Feb, 2013

1 commit


24 Feb, 2013

1 commit


14 Feb, 2013

1 commit

  • __ARCH_WANT_SYS_RT_SIGACTION,
    __ARCH_WANT_SYS_RT_SIGSUSPEND,
    __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND,
    __ARCH_WANT_COMPAT_SYS_SCHED_RR_GET_INTERVAL - not used anymore
    CONFIG_GENERIC_{SIGALTSTACK,COMPAT_RT_SIG{ACTION,QUEUEINFO,PENDING,PROCMASK}} -
    can be assumed always set.

    Al Viro