29 Nov, 2019

1 commit

  • commit ba31c1a48538992316cc71ce94fa9cd3e7b427c0 upstream.

    The futex exit handling is #ifdeffed into mm_release() which is not pretty
    to begin with. But upcoming changes to address futex exit races need to add
    more functionality to this exit code.

    Split it out into a function, move it into futex code and make the various
    futex exit functions static.

    Preparatory only and no functional change.

    Folded build fix from Borislav.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Ingo Molnar
    Acked-by: Peter Zijlstra (Intel)
    Link: https://lkml.kernel.org/r/20191106224556.049705556@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

17 Jul, 2019

1 commit

  • task->saved_sigmask and ->restore_sigmask are only used in the ret-from-
    syscall paths. This means that set_user_sigmask() can save ->blocked in
    ->saved_sigmask and do set_restore_sigmask() to indicate that ->blocked
    was modified.

    This way the callers do not need 2 sigset_t's passed to set/restore and
    restore_user_sigmask() renamed to restore_saved_sigmask_unless() turns
    into the trivial helper which just calls restore_saved_sigmask().

    Link: http://lkml.kernel.org/r/20190606113206.GA9464@redhat.com
    Signed-off-by: Oleg Nesterov
    Cc: Deepa Dinamani
    Cc: Arnd Bergmann
    Cc: Jens Axboe
    Cc: Davidlohr Bueso
    Cc: Eric Wong
    Cc: Jason Baron
    Cc: Thomas Gleixner
    Cc: Al Viro
    Cc: Eric W. Biederman
    Cc: David Laight
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     

07 Feb, 2019

2 commits

  • A lot of system calls that pass a time_t somewhere have an implementation
    using a COMPAT_SYSCALL_DEFINEx() on 64-bit architectures, and have
    been reworked so that this implementation can now be used on 32-bit
    architectures as well.

    The missing step is to redefine them using the regular SYSCALL_DEFINEx()
    to get them out of the compat namespace and make it possible to build them
    on 32-bit architectures.

    Any system call that ends in 'time' gets a '32' suffix on its name for
    that version, while the others get a '_time32' suffix, to distinguish
    them from the normal version, which takes a 64-bit time argument in the
    future.

    In this step, only 64-bit architectures are changed, doing this rename
    first lets us avoid touching the 32-bit architectures twice.

    Acked-by: Catalin Marinas
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     
  • We want to reuse the compat_timex handling on 32-bit architectures the
    same way we are using the compat handling for timespec when moving to
    64-bit time_t.

    Move all definitions related to compat_timex out of the compat code
    into the normal timekeeping code, along with a rename to old_timex32,
    corresponding to the timespec/timeval structures, and make it controlled
    by CONFIG_COMPAT_32BIT_TIME, which 32-bit architectures will then select.

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

18 Dec, 2018

2 commits

  • Now that 32-bit architectures have two variants of sys_rt_sigtimedwaid()
    for 32-bit and 64-bit time_t, we also need to have a second compat system
    call entry point on the corresponding 64-bit architectures.

    The traditional system call keeps getting handled
    by compat_sys_rt_sigtimedwait(), and this adds a new
    compat_sys_rt_sigtimedwait_time64() that differs only in the timeout
    argument type.

    The naming remains a bit asymmetric for the moment. Ideally we would
    want to have compat_sys_rt_sigtimedwait_time32() for the old version
    and compat_sys_rt_sigtimedwait() for the new one to mirror the names
    of the native entry points, but renaming the existing system call
    tables causes unnecessary churn. I would suggest renaming all such
    system calls together at a later point.

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     
  • recvmmsg() takes two arguments to pointers of structures that differ
    between 32-bit and 64-bit architectures: mmsghdr and timespec.

    For y2038 compatbility, we are changing the native system call from
    timespec to __kernel_timespec with a 64-bit time_t (in another patch),
    and use the existing compat system call on both 32-bit and 64-bit
    architectures for compatibility with traditional 32-bit user space.

    As we now have two variants of recvmmsg() for 32-bit tasks that are both
    different from the variant that we use on 64-bit tasks, this means we
    also require two compat system calls!

    The solution I picked is to flip things around: The existing
    compat_sys_recvmmsg() call gets moved from net/compat.c into net/socket.c
    and now handles the case for old user space on all architectures that
    have set CONFIG_COMPAT_32BIT_TIME. A new compat_sys_recvmmsg_time64()
    call gets added in the old place for 64-bit architectures only, this
    one handles the case of a compat mmsghdr structure combined with
    __kernel_timespec.

    In the indirect sys_socketcall(), we now need to call either
    do_sys_recvmmsg() or __compat_sys_recvmmsg(), depending on what kind of
    architecture we are on. For compat_sys_socketcall(), no such change is
    needed, we always call __compat_sys_recvmmsg().

    I decided to not add a new SYS_RECVMMSG_TIME64 socketcall: Any libc
    implementation for 64-bit time_t will need significant changes including
    an updated asm/unistd.h, and it seems better to consistently use the
    separate syscalls that configuration, leaving the socketcall only for
    backward compatibility with 32-bit time_t based libc.

    The naming is asymmetric for the moment, so both existing syscalls
    entry points keep their names, while the new ones are recvmmsg_time32
    and compat_recvmmsg_time64 respectively. I expect that we will rename
    the compat syscalls later as we start using generated syscall tables
    everywhere and add these entry points.

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

07 Dec, 2018

4 commits

  • struct timespec is not y2038 safe.
    struct __kernel_timespec is the new y2038 safe structure for all
    syscalls that are using struct timespec.
    Update io_pgetevents interfaces to use struct __kernel_timespec.

    sigset_t also has different representations on 32 bit and 64 bit
    architectures. Hence, we need to support the following different
    syscalls:

    New y2038 safe syscalls:
    (Controlled by CONFIG_64BIT_TIME for 32 bit ABIs)

    Native 64 bit(unchanged) and native 32 bit : sys_io_pgetevents
    Compat : compat_sys_io_pgetevents_time64

    Older y2038 unsafe syscalls:
    (Controlled by CONFIG_32BIT_COMPAT_TIME for 32 bit ABIs)

    Native 32 bit : sys_io_pgetevents_time32
    Compat : compat_sys_io_pgetevents

    Note that io_getevents syscalls do not have a y2038 safe solution.

    Signed-off-by: Deepa Dinamani
    Signed-off-by: Arnd Bergmann

    Deepa Dinamani
     
  • struct timespec is not y2038 safe.
    struct __kernel_timespec is the new y2038 safe structure for all
    syscalls that are using struct timespec.
    Update pselect interfaces to use struct __kernel_timespec.

    sigset_t also has different representations on 32 bit and 64 bit
    architectures. Hence, we need to support the following different
    syscalls:

    New y2038 safe syscalls:
    (Controlled by CONFIG_64BIT_TIME for 32 bit ABIs)

    Native 64 bit(unchanged) and native 32 bit : sys_pselect6
    Compat : compat_sys_pselect6_time64

    Older y2038 unsafe syscalls:
    (Controlled by CONFIG_32BIT_COMPAT_TIME for 32 bit ABIs)

    Native 32 bit : pselect6_time32
    Compat : compat_sys_pselect6

    Note that all other versions of select syscalls will not have
    y2038 safe versions.

    Signed-off-by: Deepa Dinamani
    Signed-off-by: Arnd Bergmann

    Deepa Dinamani
     
  • struct timespec is not y2038 safe.
    struct __kernel_timespec is the new y2038 safe structure for all
    syscalls that are using struct timespec.
    Update ppoll interfaces to use struct __kernel_timespec.

    sigset_t also has different representations on 32 bit and 64 bit
    architectures. Hence, we need to support the following different
    syscalls:

    New y2038 safe syscalls:
    (Controlled by CONFIG_64BIT_TIME for 32 bit ABIs)

    Native 64 bit(unchanged) and native 32 bit : sys_ppoll
    Compat : compat_sys_ppoll_time64

    Older y2038 unsafe syscalls:
    (Controlled by CONFIG_32BIT_COMPAT_TIME for 32 bit ABIs)

    Native 32 bit : ppoll_time32
    Compat : compat_sys_ppoll

    Signed-off-by: Deepa Dinamani
    Signed-off-by: Arnd Bergmann

    Deepa Dinamani
     
  • Refactor reading sigset from userspace and updating sigmask
    into an api.

    This is useful for versions of syscalls that pass in the
    sigmask and expect the current->sigmask to be changed during,
    and restored after, the execution of the syscall.

    With the advent of new y2038 syscalls in the subsequent patches,
    we add two more new versions of the syscalls (for pselect, ppoll,
    and io_pgetevents) in addition to the existing native and compat
    versions. Adding such an api reduces the logic that would need to
    be replicated otherwise.

    Note that the calls to sigprocmask() ignored the return value
    from the api as the function only returns an error on an invalid
    first argument that is hardcoded at these call sites.
    The updated logic uses set_current_blocked() instead.

    Signed-off-by: Deepa Dinamani
    Signed-off-by: Arnd Bergmann

    Deepa Dinamani
     

04 Nov, 2018

1 commit


01 Nov, 2018

1 commit

  • The result of in_compat_syscall() can be pictured as:

    x86 platform:
    ---------------------------------------------------
    | Arch\syscall | 64-bit | ia32 | x32 |
    |-------------------------------------------------|
    | x86_64 | false | true | true |
    |-------------------------------------------------|
    | i686 | | | |
    ---------------------------------------------------

    Other platforms:
    -------------------------------------------
    | Arch\syscall | 64-bit | compat |
    |-----------------------------------------|
    | 64-bit | false | true |
    |-----------------------------------------|
    | 32-bit(?) | | |
    -------------------------------------------

    As seen, the result of in_compat_syscall() on generic 32-bit platform
    differs from i686.

    There is no reason for in_compat_syscall() == true on native i686. It also
    easy to misread code if the result on native 32-bit platform differs
    between arches.

    Because of that non arch-specific code has many places with:
    if (IS_ENABLED(CONFIG_COMPAT) && in_compat_syscall())
    in different variations.

    It looks-like the only non-x86 code which uses in_compat_syscall() not
    under CONFIG_COMPAT guard is in amd/amdkfd. But according to the commit
    a18069c132cb ("amdkfd: Disable support for 32-bit user processes"), it
    actually should be disabled on native i686.

    Rename in_compat_syscall() to in_32bit_syscall() for x86-specific code
    and make in_compat_syscall() false under !CONFIG_COMPAT.

    A follow on patch will clean up generic users which were forced to check
    IS_ENABLED(CONFIG_COMPAT) with in_compat_syscall().

    Signed-off-by: Dmitry Safonov
    Signed-off-by: Thomas Gleixner
    Reviewed-by: Andy Lutomirski
    Cc: Dmitry Safonov
    Cc: Ard Biesheuvel
    Cc: "David S. Miller"
    Cc: Herbert Xu
    Cc: "H. Peter Anvin"
    Cc: John Stultz
    Cc: "Kirill A. Shutemov"
    Cc: Oleg Nesterov
    Cc: Steffen Klassert
    Cc: Stephen Boyd
    Cc: Steven Rostedt
    Cc: linux-efi@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Link: https://lkml.kernel.org/r/20181012134253.23266-2-dima@arista.com

    Dmitry Safonov
     

31 Oct, 2018

1 commit


26 Oct, 2018

1 commit

  • Pull timekeeping updates from Thomas Gleixner:
    "The timers and timekeeping departement provides:

    - Another large y2038 update with further preparations for providing
    the y2038 safe timespecs closer to the syscalls.

    - An overhaul of the SHCMT clocksource driver

    - SPDX license identifier updates

    - Small cleanups and fixes all over the place"

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (31 commits)
    tick/sched : Remove redundant cpu_online() check
    clocksource/drivers/dw_apb: Add reset control
    clocksource: Remove obsolete CLOCKSOURCE_OF_DECLARE
    clocksource/drivers: Unify the names to timer-* format
    clocksource/drivers/sh_cmt: Add R-Car gen3 support
    dt-bindings: timer: renesas: cmt: document R-Car gen3 support
    clocksource/drivers/sh_cmt: Properly line-wrap sh_cmt_of_table[] initializer
    clocksource/drivers/sh_cmt: Fix clocksource width for 32-bit machines
    clocksource/drivers/sh_cmt: Fixup for 64-bit machines
    clocksource/drivers/sh_tmu: Convert to SPDX identifiers
    clocksource/drivers/sh_mtu2: Convert to SPDX identifiers
    clocksource/drivers/sh_cmt: Convert to SPDX identifiers
    clocksource/drivers/renesas-ostm: Convert to SPDX identifiers
    clocksource: Convert to using %pOFn instead of device_node.name
    tick/broadcast: Remove redundant check
    RISC-V: Request newstat syscalls
    y2038: signal: Change rt_sigtimedwait to use __kernel_timespec
    y2038: socket: Change recvmmsg to use __kernel_timespec
    y2038: sched: Change sched_rr_get_interval to use __kernel_timespec
    y2038: utimes: Rework #ifdef guards for compat syscalls
    ...

    Linus Torvalds
     

24 Oct, 2018

1 commit

  • …iederm/user-namespace

    Pull siginfo updates from Eric Biederman:
    "I have been slowly sorting out siginfo and this is the culmination of
    that work.

    The primary result is in several ways the signal infrastructure has
    been made less error prone. The code has been updated so that manually
    specifying SEND_SIG_FORCED is never necessary. The conversion to the
    new siginfo sending functions is now complete, which makes it
    difficult to send a signal without filling in the proper siginfo
    fields.

    At the tail end of the patchset comes the optimization of decreasing
    the size of struct siginfo in the kernel from 128 bytes to about 48
    bytes on 64bit. The fundamental observation that enables this is by
    definition none of the known ways to use struct siginfo uses the extra
    bytes.

    This comes at the cost of a small user space observable difference.
    For the rare case of siginfo being injected into the kernel only what
    can be copied into kernel_siginfo is delivered to the destination, the
    rest of the bytes are set to 0. For cases where the signal and the
    si_code are known this is safe, because we know those bytes are not
    used. For cases where the signal and si_code combination is unknown
    the bits that won't fit into struct kernel_siginfo are tested to
    verify they are zero, and the send fails if they are not.

    I made an extensive search through userspace code and I could not find
    anything that would break because of the above change. If it turns out
    I did break something it will take just the revert of a single change
    to restore kernel_siginfo to the same size as userspace siginfo.

    Testing did reveal dependencies on preferring the signo passed to
    sigqueueinfo over si->signo, so bit the bullet and added the
    complexity necessary to handle that case.

    Testing also revealed bad things can happen if a negative signal
    number is passed into the system calls. Something no sane application
    will do but something a malicious program or a fuzzer might do. So I
    have fixed the code that performs the bounds checks to ensure negative
    signal numbers are handled"

    * 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (80 commits)
    signal: Guard against negative signal numbers in copy_siginfo_from_user32
    signal: Guard against negative signal numbers in copy_siginfo_from_user
    signal: In sigqueueinfo prefer sig not si_signo
    signal: Use a smaller struct siginfo in the kernel
    signal: Distinguish between kernel_siginfo and siginfo
    signal: Introduce copy_siginfo_from_user and use it's return value
    signal: Remove the need for __ARCH_SI_PREABLE_SIZE and SI_PAD_SIZE
    signal: Fail sigqueueinfo if si_signo != sig
    signal/sparc: Move EMT_TAGOVF into the generic siginfo.h
    signal/unicore32: Use force_sig_fault where appropriate
    signal/unicore32: Generate siginfo in ucs32_notify_die
    signal/unicore32: Use send_sig_fault where appropriate
    signal/arc: Use force_sig_fault where appropriate
    signal/arc: Push siginfo generation into unhandled_exception
    signal/ia64: Use force_sig_fault where appropriate
    signal/ia64: Use the force_sig(SIGSEGV,...) in ia64_rt_sigreturn
    signal/ia64: Use the generic force_sigsegv in setup_frame
    signal/arm/kvm: Use send_sig_mceerr
    signal/arm: Use send_sig_fault where appropriate
    signal/arm: Use force_sig_fault where appropriate
    ...

    Linus Torvalds
     

03 Oct, 2018

1 commit

  • Linus recently observed that if we did not worry about the padding
    member in struct siginfo it is only about 48 bytes, and 48 bytes is
    much nicer than 128 bytes for allocating on the stack and copying
    around in the kernel.

    The obvious thing of only adding the padding when userspace is
    including siginfo.h won't work as there are sigframe definitions in
    the kernel that embed struct siginfo.

    So split siginfo in two; kernel_siginfo and siginfo. Keeping the
    traditional name for the userspace definition. While the version that
    is used internally to the kernel and ultimately will not be padded to
    128 bytes is called kernel_siginfo.

    The definition of struct kernel_siginfo I have put in include/signal_types.h

    A set of buildtime checks has been added to verify the two structures have
    the same field offsets.

    To make it easy to verify the change kernel_siginfo retains the same
    size as siginfo. The reduction in size comes in a following change.

    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

01 Oct, 2018

1 commit

  • The sigaltstack(2) system call fails with -ENOMEM if the new alternative
    signal stack is found to be smaller than SIGMINSTKSZ. On architectures
    such as arm64, where the native value for SIGMINSTKSZ is larger than
    the compat value, this can result in an unexpected error being reported
    to a compat task. See, for example:

    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=904385

    This patch fixes the problem by extending do_sigaltstack to take the
    minimum signal stack size as an additional parameter, allowing the
    native and compat system call entry code to pass in their respective
    values. COMPAT_SIGMINSTKSZ is just defined as SIGMINSTKSZ if it has not
    been defined by the architecture.

    Cc: Arnd Bergmann
    Cc: Dominik Brodowski
    Cc: "Eric W. Biederman"
    Cc: Andrew Morton
    Cc: Al Viro
    Cc: Oleg Nesterov
    Reported-by: Steve McIntyre
    Tested-by: Steve McIntyre
    Signed-off-by: Will Deacon
    Signed-off-by: Catalin Marinas

    Will Deacon
     

29 Aug, 2018

2 commits

  • After changing over to 64-bit time_t syscalls, many architectures will
    want compat_sys_utimensat() but not respective handlers for utime(),
    utimes() and futimesat(). This adds a new __ARCH_WANT_SYS_UTIME32 to
    complement __ARCH_WANT_SYS_UTIME. For now, all 64-bit architectures that
    support CONFIG_COMPAT set it, but future 64-bit architectures will not
    (tile would not have needed it either, but got removed).

    As older 32-bit architectures get converted to using CONFIG_64BIT_TIME,
    they will have to use __ARCH_WANT_SYS_UTIME32 instead of
    __ARCH_WANT_SYS_UTIME. Architectures using the generic syscall ABI don't
    need either of them as they never had a utime syscall.

    Since the compat_utimbuf structure is now required outside of
    CONFIG_COMPAT, I'm moving it into compat_time.h.

    Signed-off-by: Arnd Bergmann
    ---
    changed from last version:
    - renamed __ARCH_WANT_COMPAT_SYS_UTIME to __ARCH_WANT_SYS_UTIME32

    Arnd Bergmann
     
  • While converting compat system call handlers to work on 32-bit
    architectures, I found a number of types used in those handlers
    that are identical between all architectures.

    Let's move all the identical ones into asm-generic/compat.h to avoid
    having to add even more identical definitions of those types.

    For unknown reasons, mips defines __compat_gid32_t, __compat_uid32_t
    and compat_caddr_t as signed, while all others have them unsigned.
    This seems to be a mistake, but I'm leaving it alone here. The other
    types all differ by size or alignment on at least on architecture.

    compat_aio_context_t is currently defined in linux/compat.h but
    also needed for compat_sys_io_getevents(), so let's move it into
    the same place.

    While we still have not decided whether the 32-bit time handling
    will always use the compat syscalls, or in which form, I think this
    is a useful cleanup that we can merge regardless.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

27 Aug, 2018

1 commit

  • Christoph Hellwig suggested a slightly different path for handling
    backwards compatibility with the 32-bit time_t based system calls:

    Rather than simply reusing the compat_sys_* entry points on 32-bit
    architectures unchanged, we get rid of those entry points and the
    compat_time types by renaming them to something that makes more sense
    on 32-bit architectures (which don't have a compat mode otherwise),
    and then share the entry points under the new name with the 64-bit
    architectures that use them for implementing the compatibility.

    The following types and interfaces are renamed here, and moved
    from linux/compat_time.h to linux/time32.h:

    old new
    --- ---
    compat_time_t old_time32_t
    struct compat_timeval struct old_timeval32
    struct compat_timespec struct old_timespec32
    struct compat_itimerspec struct old_itimerspec32
    ns_to_compat_timeval() ns_to_old_timeval32()
    get_compat_itimerspec64() get_old_itimerspec32()
    put_compat_itimerspec64() put_old_itimerspec32()
    compat_get_timespec64() get_old_timespec32()
    compat_put_timespec64() put_old_timespec32()

    As we already have aliases in place, this patch addresses only the
    instances that are relevant to the system call interface in particular,
    not those that occur in device drivers and other modules. Those
    will get handled separately, while providing the 64-bit version
    of the respective interfaces.

    I'm not renaming the timex, rusage and itimerval structures, as we are
    still debating what the new interface will look like, and whether we
    will need a replacement at all.

    This also doesn't change the names of the syscall entry points, which can
    be done more easily when we actually switch over the 32-bit architectures
    to use them, at that point we need to change COMPAT_SYSCALL_DEFINEx to
    SYSCALL_DEFINEx with a new name, e.g. with a _time32 suffix.

    Suggested-by: Christoph Hellwig
    Link: https://lore.kernel.org/lkml/20180705222110.GA5698@infradead.org/
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

15 Aug, 2018

1 commit

  • Pull arm64 updates from Will Deacon:
    "A bunch of good stuff in here. Worth noting is that we've pulled in
    the x86/mm branch from -tip so that we can make use of the core
    ioremap changes which allow us to put down huge mappings in the
    vmalloc area without screwing up the TLB. Much of the positive
    diffstat is because of the rseq selftest for arm64.

    Summary:

    - Wire up support for qspinlock, replacing our trusty ticket lock
    code

    - Add an IPI to flush_icache_range() to ensure that stale
    instructions fetched into the pipeline are discarded along with the
    I-cache lines

    - Support for the GCC "stackleak" plugin

    - Support for restartable sequences, plus an arm64 port for the
    selftest

    - Kexec/kdump support on systems booting with ACPI

    - Rewrite of our syscall entry code in C, which allows us to zero the
    GPRs on entry from userspace

    - Support for chained PMU counters, allowing 64-bit event counters to
    be constructed on current CPUs

    - Ensure scheduler topology information is kept up-to-date with CPU
    hotplug events

    - Re-enable support for huge vmalloc/IO mappings now that the core
    code has the correct hooks to use break-before-make sequences

    - Miscellaneous, non-critical fixes and cleanups"

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (90 commits)
    arm64: alternative: Use true and false for boolean values
    arm64: kexec: Add comment to explain use of __flush_icache_range()
    arm64: sdei: Mark sdei stack helper functions as static
    arm64, kaslr: export offset in VMCOREINFO ELF notes
    arm64: perf: Add cap_user_time aarch64
    efi/libstub: Only disable stackleak plugin for arm64
    arm64: drop unused kernel_neon_begin_partial() macro
    arm64: kexec: machine_kexec should call __flush_icache_range
    arm64: svc: Ensure hardirq tracing is updated before return
    arm64: mm: Export __sync_icache_dcache() for xen-privcmd
    drivers/perf: arm-ccn: Use devm_ioremap_resource() to map memory
    arm64: Add support for STACKLEAK gcc plugin
    arm64: Add stack information to on_accessible_stack
    drivers/perf: hisi: update the sccl_id/ccl_id when MT is supported
    arm64: fix ACPI dependencies
    rseq/selftests: Add support for arm64
    arm64: acpi: fix alignment fault in accessing ACPI
    efi/arm: map UEFI memory map even w/o runtime services enabled
    efi/arm: preserve early mapping of UEFI memory map longer for BGRT
    drivers: acpi: add dependency of EFI for arm64
    ...

    Linus Torvalds
     

13 Jul, 2018

1 commit


12 Jul, 2018

1 commit

  • Using this helper allows us to avoid the in-kernel calls to the
    compat_sys_{f,}statfs64() sycalls, as are necessary for parameter
    mangling in arm64's compat handling.

    Following the example of ksys_* functions, kcompat_sys_* functions are
    intended to be a drop-in replacement for their compat_sys_*
    counterparts, with the same calling convention.

    This is necessary to enable conversion of arm64's syscall handling to
    use pt_regs wrappers.

    Signed-off-by: Mark Rutland
    Reviewed-by: Dominik Brodowski
    Cc: Al Viro
    Cc: linux-fsdevel@vger.kernel.org
    Signed-off-by: Will Deacon

    Mark Rutland
     

25 Jun, 2018

1 commit

  • gcc-8 warns for every single definition of a system call entry
    point, e.g.:

    include/linux/compat.h:56:18: error: 'compat_sys_rt_sigprocmask' alias between functions of incompatible types 'long int(int, compat_sigset_t *, compat_sigset_t *, compat_size_t)' {aka 'long int(int, struct *, struct *, unsigned int)'} and 'long int(long int, long int, long int, long int)' [-Werror=attribute-alias]
    asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\
    ^~~~~~~~~~
    include/linux/compat.h:45:2: note: in expansion of macro 'COMPAT_SYSCALL_DEFINEx'
    COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
    ^~~~~~~~~~~~~~~~~~~~~~
    kernel/signal.c:2601:1: note: in expansion of macro 'COMPAT_SYSCALL_DEFINE4'
    COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, nset,
    ^~~~~~~~~~~~~~~~~~~~~~
    include/linux/compat.h:60:18: note: aliased declaration here
    asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\
    ^~~~~~~~~~

    The new warning seems reasonable in principle, but it doesn't
    help us here, since we rely on the type mismatch to sanitize the
    system call arguments. After I reported this as GCC PR82435, a new
    -Wno-attribute-alias option was added that could be used to turn the
    warning off globally on the command line, but I'd prefer to do it a
    little more fine-grained.

    Interestingly, turning a warning off and on again inside of
    a single macro doesn't always work, in this case I had to add
    an extra statement inbetween and decided to copy the __SC_TEST
    one from the native syscall to the compat syscall macro. See
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83256 for more details
    about this.

    [paul.burton@mips.com:
    - Rebase atop current master.
    - Split GCC & version arguments to __diag_ignore() in order to match
    changes to the preceding patch.
    - Add the comment argument to match the preceding patch.]

    Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82435
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Paul Burton
    Tested-by: Christophe Leroy
    Tested-by: Stafford Horne
    Signed-off-by: Masahiro Yamada

    Arnd Bergmann
     

24 Jun, 2018

1 commit

  • This will aid in enabling the compat syscalls on 32-bit architectures later
    on.

    Also move compat_itimerspec and related defines to compat_time.h. The
    compat_time.h file will eventually be deleted.

    Signed-off-by: Deepa Dinamani
    Signed-off-by: Thomas Gleixner
    Cc: arnd@arndb.de
    Cc: viro@zeniv.linux.org.uk
    Cc: linux-fsdevel@vger.kernel.org
    Cc: linux-api@vger.kernel.org
    Cc: y2038@lists.linaro.org
    Link: https://lkml.kernel.org/r/20180617051144.29756-3-deepa.kernel@gmail.com

    Deepa Dinamani
     

05 Jun, 2018

1 commit

  • Pull timers and timekeeping updates from Thomas Gleixner:

    - Core infrastucture work for Y2038 to address the COMPAT interfaces:

    + Add a new Y2038 safe __kernel_timespec and use it in the core
    code

    + Introduce config switches which allow to control the various
    compat mechanisms

    + Use the new config switch in the posix timer code to control the
    32bit compat syscall implementation.

    - Prevent bogus selection of CPU local clocksources which causes an
    endless reselection loop

    - Remove the extra kthread in the clocksource code which has no value
    and just adds another level of indirection

    - The usual bunch of trivial updates, cleanups and fixlets all over the
    place

    - More SPDX conversions

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (24 commits)
    clocksource/drivers/mxs_timer: Switch to SPDX identifier
    clocksource/drivers/timer-imx-tpm: Switch to SPDX identifier
    clocksource/drivers/timer-imx-gpt: Switch to SPDX identifier
    clocksource/drivers/timer-imx-gpt: Remove outdated file path
    clocksource/drivers/arc_timer: Add comments about locking while read GFRC
    clocksource/drivers/mips-gic-timer: Add pr_fmt and reword pr_* messages
    clocksource/drivers/sprd: Fix Kconfig dependency
    clocksource: Move inline keyword to the beginning of function declarations
    timer_list: Remove unused function pointer typedef
    timers: Adjust a kernel-doc comment
    tick: Prefer a lower rating device only if it's CPU local device
    clocksource: Remove kthread
    time: Change nanosleep to safe __kernel_* types
    time: Change types to new y2038 safe __kernel_* types
    time: Fix get_timespec64() for y2038 safe compat interfaces
    time: Add new y2038 safe __kernel_timespec
    posix-timers: Make compat syscalls depend on CONFIG_COMPAT_32BIT_TIME
    time: Introduce CONFIG_COMPAT_32BIT_TIME
    time: Introduce CONFIG_64BIT_TIME in architectures
    compat: Enable compat_get/put_timespec64 always
    ...

    Linus Torvalds
     

03 May, 2018

1 commit

  • This is the io_getevents equivalent of ppoll/pselect and allows to
    properly mix signals and aio completions (especially with IOCB_CMD_POLL)
    and atomically executes the following sequence:

    sigset_t origmask;

    pthread_sigmask(SIG_SETMASK, &sigmask, &origmask);
    ret = io_getevents(ctx, min_nr, nr, events, timeout);
    pthread_sigmask(SIG_SETMASK, &origmask, NULL);

    Note that unlike many other signal related calls we do not pass a sigmask
    size, as that would get us to 7 arguments, which aren't easily supported
    by the syscall infrastructure. It seems a lot less painful to just add a
    new syscall variant in the unlikely case we're going to increase the
    sigset size.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Greg Kroah-Hartman
    Reviewed-by: Darrick J. Wong

    Christoph Hellwig
     

19 Apr, 2018

4 commits

  • These functions are used in the repurposed compat syscalls
    to provide backward compatibility for using 32 bit time_t
    on 32 bit systems.

    Signed-off-by: Deepa Dinamani
    Signed-off-by: Arnd Bergmann

    Deepa Dinamani
     
  • All the current architecture specific defines for these
    are the same. Refactor these common defines to a common
    header file.

    The new common linux/compat_time.h is also useful as it
    will eventually be used to hold all the defines that
    are needed for compat time types that support non y2038
    safe types. New architectures need not have to define these
    new types as they will only use new y2038 safe syscalls.
    This file can be deleted after y2038 when we stop supporting
    non y2038 safe syscalls.

    The patch also requires an operation similar to:

    git grep "asm/compat\.h" | cut -d ":" -f 1 | xargs -n 1 sed -i -e "s%asm/compat.h%linux/compat.h%g"

    Cc: acme@kernel.org
    Cc: benh@kernel.crashing.org
    Cc: borntraeger@de.ibm.com
    Cc: catalin.marinas@arm.com
    Cc: cmetcalf@mellanox.com
    Cc: cohuck@redhat.com
    Cc: davem@davemloft.net
    Cc: deller@gmx.de
    Cc: devel@driverdev.osuosl.org
    Cc: gerald.schaefer@de.ibm.com
    Cc: gregkh@linuxfoundation.org
    Cc: heiko.carstens@de.ibm.com
    Cc: hoeppner@linux.vnet.ibm.com
    Cc: hpa@zytor.com
    Cc: jejb@parisc-linux.org
    Cc: jwi@linux.vnet.ibm.com
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-mips@linux-mips.org
    Cc: linux-parisc@vger.kernel.org
    Cc: linuxppc-dev@lists.ozlabs.org
    Cc: linux-s390@vger.kernel.org
    Cc: mark.rutland@arm.com
    Cc: mingo@redhat.com
    Cc: mpe@ellerman.id.au
    Cc: oberpar@linux.vnet.ibm.com
    Cc: oprofile-list@lists.sf.net
    Cc: paulus@samba.org
    Cc: peterz@infradead.org
    Cc: ralf@linux-mips.org
    Cc: rostedt@goodmis.org
    Cc: rric@kernel.org
    Cc: schwidefsky@de.ibm.com
    Cc: sebott@linux.vnet.ibm.com
    Cc: sparclinux@vger.kernel.org
    Cc: sth@linux.vnet.ibm.com
    Cc: ubraun@linux.vnet.ibm.com
    Cc: will.deacon@arm.com
    Cc: x86@kernel.org
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Deepa Dinamani
    Acked-by: Steven Rostedt (VMware)
    Acked-by: Catalin Marinas
    Acked-by: James Hogan
    Acked-by: Helge Deller
    Signed-off-by: Arnd Bergmann

    Deepa Dinamani
     
  • We have a couple of files that try to include asm/compat.h on
    architectures where this is available. Those should generally use the
    higher-level linux/compat.h file, but that in turn fails to include
    asm/compat.h when CONFIG_COMPAT is disabled, unless we can provide
    that header on all architectures.

    This adds the asm/compat.h for all remaining architectures to
    simplify the dependencies.

    Architectures that are getting removed in linux-4.17 are not changed
    here, to avoid needless conflicts with the removal patches. Those
    architectures are broken by this patch, but we have already shown
    that they have no users.

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     
  • Many of the compat time syscalls are also repurposed as 32 bit
    native syscalls to provide backward compatibility while adding
    new y2038 safe sycalls.
    Enabling the helpers makes this possible.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Deepa Dinamani
    Signed-off-by: Arnd Bergmann

    Deepa Dinamani
     

16 Apr, 2018

1 commit

  • Pull x86 fixes from Thomas Gleixner:
    "A set of fixes and updates for x86:

    - Address a swiotlb regression which was caused by the recent DMA
    rework and made driver fail because dma_direct_supported() returned
    false

    - Fix a signedness bug in the APIC ID validation which caused invalid
    APIC IDs to be detected as valid thereby bloating the CPU possible
    space.

    - Fix inconsisten config dependcy/select magic for the MFD_CS5535
    driver.

    - Fix a corruption of the physical address space bits when encryption
    has reduced the address space and late cpuinfo updates overwrite
    the reduced bit information with the original value.

    - Dominiks syscall rework which consolidates the architecture
    specific syscall functions so all syscalls can be wrapped with the
    same macros. This allows to switch x86/64 to struct pt_regs based
    syscalls. Extend the clearing of user space controlled registers in
    the entry patch to the lower registers"

    * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    x86/apic: Fix signedness bug in APIC ID validity checks
    x86/cpu: Prevent cpuinfo_x86::x86_phys_bits adjustment corruption
    x86/olpc: Fix inconsistent MFD_CS5535 configuration
    swiotlb: Use dma_direct_supported() for swiotlb_ops
    syscalls/x86: Adapt syscall_wrapper.h to the new syscall stub naming convention
    syscalls/core, syscalls/x86: Rename struct pt_regs-based sys_*() to __x64_sys_*()
    syscalls/core, syscalls/x86: Clean up compat syscall stub naming convention
    syscalls/core, syscalls/x86: Clean up syscall stub naming convention
    syscalls/x86: Extend register clearing on syscall entry to lower registers
    syscalls/x86: Unconditionally enable 'struct pt_regs' based syscalls on x86_64
    syscalls/x86: Use 'struct pt_regs' based syscall calling for IA32_EMULATION and x32
    syscalls/core: Prepare CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y for compat syscalls
    syscalls/x86: Use 'struct pt_regs' based syscall calling convention for 64-bit syscalls
    syscalls/core: Introduce CONFIG_ARCH_HAS_SYSCALL_WRAPPER=y
    x86/syscalls: Don't pointlessly reload the system call number
    x86/mm: Fix documentation of module mapping range with 4-level paging
    x86/cpuid: Switch to 'static const' specifier

    Linus Torvalds
     

09 Apr, 2018

1 commit

  • Tidy the naming convention for compat syscall subs. Hints which describe
    the purpose of the stub go in front and receive a double underscore to
    denote that they are generated on-the-fly by the COMPAT_SYSCALL_DEFINEx()
    macro.

    For the generic case, this means:

    t kernel_waitid # common C function (see kernel/exit.c)

    __do_compat_sys_waitid # inlined helper doing the actual work
    # (takes original parameters as declared)

    T __se_compat_sys_waitid # sign-extending C function calling inlined
    # helper (takes parameters of type long,
    # casts them to unsigned long and then to
    # the declared type)

    T compat_sys_waitid # alias to __se_compat_sys_waitid()
    # (taking parameters as declared), to
    # be included in syscall table

    For x86, the naming is as follows:

    t kernel_waitid # common C function (see kernel/exit.c)

    __do_compat_sys_waitid # inlined helper doing the actual work
    # (takes original parameters as declared)

    t __se_compat_sys_waitid # sign-extending C function calling inlined
    # helper (takes parameters of type long,
    # casts them to unsigned long and then to
    # the declared type)

    T __ia32_compat_sys_waitid # IA32_EMULATION 32-bit-ptregs -> C stub,
    # calls __se_compat_sys_waitid(); to be
    # included in syscall table

    T __x32_compat_sys_waitid # x32 64-bit-ptregs -> C stub, calls
    # __se_compat_sys_waitid(); to be included
    # in syscall table

    If only one of IA32_EMULATION and x32 is enabled, __se_compat_sys_waitid()
    may be inlined into the stub __{ia32,x32}_compat_sys_waitid().

    Suggested-by: Ingo Molnar
    Signed-off-by: Dominik Brodowski
    Cc: Al Viro
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: Josh Poimboeuf
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20180409105145.5364-3-linux@dominikbrodowski.net
    Signed-off-by: Ingo Molnar

    Dominik Brodowski
     

06 Apr, 2018

1 commit

  • …iederm/user-namespace

    Pull siginfo updates from Eric Biederman:
    "The work on cleaning up and getting the bugs out of siginfo generation
    was largely stalled this round. The progress that was made was the
    definition of FPE_FLTUNK. Which is usable to fix many of the cases
    where siginfo generation is erroneously generating SI_USER by setting
    si_code to 0, that has recently been tagged as FPE_FIXME.

    You already have the change by way of the arm64 tree as that
    definition was pulled into the arm64 tree to allow fixing the problem
    there.

    What remains is the second round of fixing for what I thought was a
    trivial change to the struct siginfo when put the union in _sigfault
    where it belongs. Do to historical reasons 32bit m68k only ensures
    that pointers are 2 byte aligned. So I have added a m68k test case
    made of BUILD_BUG_ONs to verify I have this fix correct and possibly
    catch problems, and I have computed the number of bytes of padding
    needed for the _addr_bnd and _addr_pkey cases and just use an array of
    characters that size.

    For pure paranoia I have written the code so if there is an
    architecture out there that does not perform any alignment of
    structures it should still work.

    With the removal of all of the stale arechitectures this cycle future
    work on cleaning up struct siginfo should be much easier. Almost all
    of the conflicting si_code definitions have been removed with the
    removal of (blackfin, tile, and frv). Plus some of the most difficult
    to test cases have simply been removed from the tree.

    Which means that with a little luck copy_siginfo_to_user can become a
    light weight wrapper around copy_to_user in the next cycle"

    * 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
    m68k: Verify the offsets in struct siginfo never change.
    signal: Correct the offset of si_pkey and si_lower in struct siginfo on m68k

    Linus Torvalds
     

05 Apr, 2018

1 commit

  • It may be useful for an architecture to override the definitions of the
    COMPAT_SYSCALL_DEFINE0() and __COMPAT_SYSCALL_DEFINEx() macros in
    , in particular to use a different calling convention
    for syscalls. This patch provides a mechanism to do so, based on the
    previously introduced CONFIG_ARCH_HAS_SYSCALL_WRAPPER. If it is enabled,
    is included in and may be used
    to define the macros mentioned above. Moreover, as the syscall calling
    convention may be different if CONFIG_ARCH_HAS_SYSCALL_WRAPPER is set,
    the compat syscall function prototypes in are #ifndef'd
    out in that case.

    As some of the syscalls and/or compat syscalls may not be present,
    the COND_SYSCALL() and COND_SYSCALL_COMPAT() macros in kernel/sys_ni.c
    as well as the SYS_NI() and COMPAT_SYS_NI() macros in
    kernel/time/posix-stubs.c can be re-defined in iff
    CONFIG_ARCH_HAS_SYSCALL_WRAPPER is enabled.

    Signed-off-by: Dominik Brodowski
    Acked-by: Linus Torvalds
    Cc: Al Viro
    Cc: Andrew Morton
    Cc: Andy Lutomirski
    Cc: Borislav Petkov
    Cc: Brian Gerst
    Cc: Denys Vlasenko
    Cc: H. Peter Anvin
    Cc: Josh Poimboeuf
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20180405095307.3730-5-linux@dominikbrodowski.net
    Signed-off-by: Ingo Molnar

    Dominik Brodowski
     

03 Apr, 2018

5 commits

  • The change moving addr_lsb into the _sigfault union failed to take
    into account that _sigfault._addr_bnd._lower being a pointer forced
    the entire union to have pointer alignment. The fix for
    _sigfault._addr_bnd._lower having pointer alignment failed to take
    into account that m68k has a pointer alignment less than the size
    of a pointer. So simply making the padding members pointers changed
    the location of later members in the structure.

    Fix this by directly computing the needed size of the padding members,
    and making the padding members char arrays of the needed size. AKA
    if __alignof__(void *) is 1 sizeof(short) otherwise __alignof__(void *).
    Which should be exactly the same rules the compiler whould have
    used when computing the padding.

    I have tested this change by adding BUILD_BUG_ONs to m68k to verify
    the offset of every member of struct siginfo, and with those testing
    that the offsets of the fields in struct siginfo is the same before
    I changed the generic _sigfault member and after the correction
    to the _sigfault member.

    I have also verified that the x86 with it's own BUILD_BUG_ONs to verify
    the offsets of the siginfo members also compiles cleanly.

    Cc: stable@vger.kernel.org
    Reported-by: Eugene Syromiatnikov
    Fixes: 859d880cf544 ("signal: Correct the offset of si_pkey in struct siginfo")
    Fixes: b68a68d3dcc1 ("signal: Move addr_lsb into the _sigfault union for clarity")
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     
  • Error injection is a useful mechanism to fail arbitrary kernel
    functions. However, it is often hard to guarantee an error propagates
    appropriately to user space programs. By injecting into syscalls, we can
    return arbitrary values to user space directly; this increases
    flexibility and robustness in testing, allowing us to test user space
    error paths effectively.

    The following script, for example, fails calls to sys_open() from a
    given pid:

    from bcc import BPF
    from sys import argv

    pid = argv[1]

    prog = r"""

    int kprobe__SyS_open(struct pt_regs *ctx, const char *pathname, int flags)
    {
    u32 pid = bpf_get_current_pid_tgid();
    if (pid == %s)
    bpf_override_return(ctx, -ENOMEM);
    return 0;
    }
    """ % pid

    b = BPF(text=prog)
    while 1:
    b.perf_buffer_poll()

    This patch whitelists all syscalls defined with SYSCALL_DEFINE and
    COMPAT_SYSCALL_DEFINE for error injection. These changes are not
    intended to be considered stable, and would normally be configured off.

    Signed-off-by: Howard McLauchlan
    Signed-off-by: Dominik Brodowski

    Howard McLauchlan
     
  • compat_sys_*() functions are no longer called from within the kernel on
    x86 except from the system call table. Linking the system call does not
    require compat_sys_*() function prototypes at least on x86. Therefore,
    generate compat_sys_*() prototypes on-the-fly within the
    COMPAT_SYSCALL_DEFINEx() macro, and remove x86-specific prototypes from
    various header files.

    Suggested-by: Andy Lutomirski
    Cc: Arnd Bergmann
    Cc: David S. Miller
    Cc: netdev@vger.kernel.org
    Cc: Thomas Gleixner
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Andrew Morton
    Cc: Al Viro
    Cc: x86@kernel.org
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski
     
  • Shuffle the syscall prototypes in include/linux/compat.h around so
    that they are kept in the same order as in
    include/uapi/asm-generic/unistd.h. The individual entries are kept
    the same, and neither modified to bring them in line with kernel coding
    style nor wrapped in proper ifdefs -- as an exception to this, add the
    prefix "asmlinkage" where it was missing.

    Cc: Arnd Bergmann
    Cc: Andrew Morton
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski
     
  • While sys32_quotactl() is only needed on x86, it can use the recommended
    COMPAT_SYSCALL_DEFINEx() machinery for its setup.

    Acked-by: Jan Kara
    Cc: Christoph Hellwig
    Signed-off-by: Dominik Brodowski

    Dominik Brodowski