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
     

06 Mar, 2014

2 commits


03 Feb, 2014

2 commits

  • In compat_sys_old_getrlimit() we pass a kernel pointer to
    sys_old_getrlimit() inside a set_fs() bracket. This is okay, so we
    can safely cast the affected pointer to __user.

    In compat_clock_nanosleep_restart(), the variable "rmtp" holds a user
    pointer. Annotate it as such.

    Both of these warnings are ancient, but were reported by Fengguang
    Wu's test system due to other changes.

    Signed-off-by: H. Peter Anvin
    Cc: Toyo Abe
    Link: http://lkml.kernel.org/n/tip-507h7cq5e45eg6ygtykon3bf@git.kernel.org

    H. Peter Anvin
     
  • 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
     

01 May, 2013

2 commits

  • 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
     
  • The only use outside of kernel/timer.c was in kernel/compat.c, so move
    compat_sys_sysinfo() next to sys_sysinfo() in kernel/timer.c.

    Signed-off-by: Stephen Rothwell
    Cc: Thomas Gleixner
    Cc: Guenter Roeck
    Cc: Al Viro
    Acked-by: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stephen Rothwell
     

04 Mar, 2013

1 commit


24 Feb, 2013

1 commit

  • Pull signal handling cleanups from Al Viro:
    "This is the first pile; another one will come a bit later and will
    contain SYSCALL_DEFINE-related patches.

    - a bunch of signal-related syscalls (both native and compat)
    unified.

    - a bunch of compat syscalls switched to COMPAT_SYSCALL_DEFINE
    (fixing several potential problems with missing argument
    validation, while we are at it)

    - a lot of now-pointless wrappers killed

    - a couple of architectures (cris and hexagon) forgot to save
    altstack settings into sigframe, even though they used the
    (uninitialized) values in sigreturn; fixed.

    - microblaze fixes for delivery of multiple signals arriving at once

    - saner set of helpers for signal delivery introduced, several
    architectures switched to using those."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal: (143 commits)
    x86: convert to ksignal
    sparc: convert to ksignal
    arm: switch to struct ksignal * passing
    alpha: pass k_sigaction and siginfo_t using ksignal pointer
    burying unused conditionals
    make do_sigaltstack() static
    arm64: switch to generic old sigaction() (compat-only)
    arm64: switch to generic compat rt_sigaction()
    arm64: switch compat to generic old sigsuspend
    arm64: switch to generic compat rt_sigqueueinfo()
    arm64: switch to generic compat rt_sigpending()
    arm64: switch to generic compat rt_sigprocmask()
    arm64: switch to generic sigaltstack
    sparc: switch to generic old sigsuspend
    sparc: COMPAT_SYSCALL_DEFINE does all sign-extension as well as SYSCALL_DEFINE
    sparc: kill sign-extending wrappers for native syscalls
    kill sparc32_open()
    sparc: switch to use of generic old sigaction
    sparc: switch sys_compat_rt_sigaction() to COMPAT_SYSCALL_DEFINE
    mips: switch to generic sys_fork() and sys_clone()
    ...

    Linus Torvalds
     

22 Feb, 2013

1 commit


04 Feb, 2013

7 commits


26 Dec, 2012

3 commits

  • It needs 64bit timespec. As it is, we end up truncating the timeout
    to whole seconds; usually it doesn't matter, but for having all
    sub-second timeouts truncated to one jiffy is visibly wrong.

    Signed-off-by: Al Viro

    Al Viro
     
  • It needs 64bit rusage and 32bit siginfo. glibc never calls it with
    non-NULL rusage pointer, or we would've seen breakage already...

    Signed-off-by: Al Viro

    Al Viro
     
  • Strictly speaking, ppc64 needs it for C ABI compliance. Realistically
    I would be very surprised if e.g. passing 0xffffffff as 'options'
    argument to waitid() from 32bit task would cause problems, but yes,
    it puts us into undefined behaviour territory. ppc64 expects int
    argument to be passed in 64bit register with bits 31..63 containing
    the same value. SYSCALL_DEFINE on ppc provides a wrapper that normalizes
    the value passed from userland; so does COMPAT_SYSCALL_DEFINE. Plain
    declaration of compat_sys_something() with an int argument obviously
    doesn't. Again, for wait4 and waitid I would be extremely surprised
    if gcc started to produce code depending on that value having been
    properly sign-extended - the argument(s) in question end up passed
    blindly to sys_wait4 and sys_waitid resp. and normalization for native
    syscalls takes care of their use there. Still, better to use
    COMPAT_SYSCALL_DEFINE here than worry about nasal daemons...

    Signed-off-by: Al Viro

    Al Viro
     

18 Dec, 2012

1 commit

  • This function is used by sparc, powerpc tile and arm64 for compat support.
    The patch adds a generic implementation with a wrapper for PowerPC to do
    the u32->int sign extension.

    The reason for a single patch covering powerpc, tile, sparc and arm64 is
    to keep it bisectable, otherwise kernel building may fail with mismatched
    function declarations.

    Signed-off-by: Catalin Marinas
    Acked-by: Chris Metcalf [for tile]
    Acked-by: David S. Miller
    Acked-by: Arnd Bergmann
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Alexander Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Catalin Marinas
     

22 May, 2012

1 commit


10 May, 2012

1 commit

  • compat_sys_sigprocmask reads a smaller signal mask from userspace than
    sigprogmask accepts for setting. So the high word of blocked.sig[0]
    will be cleared, releasing any potentially blocked RT signal.

    This was discovered via userspace code that relies on get/setcontext.
    glibc's i386 versions of those functions use sigprogmask instead of
    rt_sigprogmask to save/restore signal mask and caused RT signal
    unblocking this way.

    As suggested by Linus, this replaces the sys_sigprocmask based compat
    version with one that open-codes the required logic, including the merge
    of the existing blocked set with the new one provided on SIG_SETMASK.

    Signed-off-by: Jan Kiszka
    Signed-off-by: Linus Torvalds

    Jan Kiszka
     

21 Feb, 2012

1 commit

  • Add helper functions to read and write struct timeval and struct
    timespec from userspace. We already had helper functions for reading
    and writing struct compat_timespec; add a set of functions to do the
    same with struct timeval, and add a second suite of functions which
    can be sensitive to COMPAT_USE_64BIT_TIME and access either 32- or
    64-bit time structures.

    This also exports these helper functions to modules.

    Rename the existing inlines for converting between struct
    compat_timeval and native struct timespec so we can have a saner
    naming convention for the exported functions.

    Suggested-by: Linus Torvalds
    Signed-off-by: H. Peter Anvin

    H. Peter Anvin
     

01 Nov, 2011

1 commit


30 Jul, 2011

1 commit

  • * 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (430 commits)
    [media] ir-mce_kbd-decoder: include module.h for its facilities
    [media] ov5642: include module.h for its facilities
    [media] em28xx: Fix DVB-C maxsize for em2884
    [media] tda18271c2dd: Fix saw filter configuration for DVB-C @6MHz
    [media] v4l: mt9v032: Fix Bayer pattern
    [media] V4L: mt9m111: rewrite set_pixfmt
    [media] V4L: mt9m111: fix missing return value check mt9m111_reg_clear
    [media] V4L: initial driver for ov5642 CMOS sensor
    [media] V4L: sh_mobile_ceu_camera: fix Oops when USERPTR mapping fails
    [media] V4L: soc-camera: remove soc-camera bus and devices on it
    [media] V4L: soc-camera: un-export the soc-camera bus
    [media] V4L: sh_mobile_csi2: switch away from using the soc-camera bus notifier
    [media] V4L: add media bus configuration subdev operations
    [media] V4L: soc-camera: group struct field initialisations together
    [media] V4L: soc-camera: remove now unused soc-camera specific PM hooks
    [media] V4L: pxa-camera: switch to using standard PM hooks
    [media] NetUP Dual DVB-T/C CI RF: force card hardware revision by module param
    [media] Don't OOPS if videobuf_dvb_get_frontend return NULL
    [media] NetUP Dual DVB-T/C CI RF: load firmware according card revision
    [media] omap3isp: Support configurable HS/VS polarities
    ...

    Fix up conflicts:
    - arch/arm/mach-omap2/board-rx51-peripherals.c:
    cleanup regulator supply definitions in mach-omap2
    vs
    OMAP3: RX-51: define vdds_csib regulator supply
    - drivers/staging/tm6000/tm6000-alsa.c (trivial)

    Linus Torvalds
     

28 Jul, 2011

2 commits


12 Jul, 2011

1 commit

  • KVM has an ioctl to define which signal mask should be used while running
    inside VCPU_RUN. At least for big endian systems, this mask is different
    on 32-bit and 64-bit systems (though the size is identical).

    Add a compat wrapper that converts the mask to whatever the kernel accepts,
    allowing 32-bit kvm user space to set signal masks.

    This patch fixes qemu with --enable-io-thread on ppc64 hosts when running
    32-bit user land.

    Signed-off-by: Alexander Graf
    Signed-off-by: Avi Kivity

    Alexander Graf
     

26 May, 2011

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile: (26 commits)
    arch/tile: prefer "tilepro" as the name of the 32-bit architecture
    compat: include aio_abi.h for aio_context_t
    arch/tile: cleanups for tilegx compat mode
    arch/tile: allocate PCI IRQs later in boot
    arch/tile: support signal "exception-trace" hook
    arch/tile: use better definitions of xchg() and cmpxchg()
    include/linux/compat.h: coding-style fixes
    tile: add an RTC driver for the Tilera hypervisor
    arch/tile: finish enabling support for TILE-Gx 64-bit chip
    compat: fixes to allow working with tile arch
    arch/tile: update defconfig file to something more useful
    tile: do_hardwall_trap: do not play with task->sighand
    tile: replace mm->cpu_vm_mask with mm_cpumask()
    tile,mn10300: add device parameter to dma_cache_sync()
    audit: support the "standard"
    arch/tile: clarify flush_buffer()/finv_buffer() function names
    arch/tile: kernel-related cleanups from removing static page size
    arch/tile: various header improvements for building drivers
    arch/tile: disable GX prefetcher during cache flush
    arch/tile: tolerate disabling CONFIG_BLK_DEV_INITRD
    ...

    Linus Torvalds
     

13 May, 2011

1 commit

  • The existing mechanism doesn't really provide
    enough to create the 64-bit "compat" ABI properly in a generic way,
    since the compat ABI is a mix of things were you can re-use the 64-bit
    versions of syscalls and things where you need a compat wrapper.

    To provide this in the most direct way possible, I added two new macros
    to go along with the existing __SYSCALL and __SC_3264 macros: __SC_COMP
    and SC_COMP_3264. These macros take an additional argument, typically a
    "compat_sys_xxx" function, which is passed to __SYSCALL if you define
    __SYSCALL_COMPAT when including the header, resulting in a pointer to
    the compat function being placed in the generated syscall table.

    The change also adds some missing definitions to so that
    it actually has declarations for all the compat syscalls, since the
    "[nr] = ##call" approach requires proper C declarations for all the
    functions included in the syscall table.

    Finally, compat.c defines compat_sys_sigpending() and
    compat_sys_sigprocmask() even if the underlying architecture doesn't
    request it, which tries to pull in undefined compat_old_sigset_t defines.
    We need to guard those compat syscall definitions with appropriate
    __ARCH_WANT_SYS_xxx ifdefs.

    Acked-by: Arnd Bergmann
    Signed-off-by: Chris Metcalf

    Chris Metcalf
     

28 Apr, 2011

2 commits

  • Factor out the common code in sys_rt_sigtimedwait/compat_sys_rt_sigtimedwait
    to the new helper, do_sigtimedwait().

    Add the comment to document the extra tick we add to timespec_to_jiffies(ts),
    thanks to Linus who explained this to me.

    Perhaps it would be better to move compat_sys_rt_sigtimedwait() into
    signal.c under CONFIG_COMPAT, then we can make do_sigtimedwait() static.

    Signed-off-by: Oleg Nesterov
    Acked-by: Tejun Heo
    Reviewed-by: Matt Fleming

    Oleg Nesterov
     
  • No functional changes, cleanup compat_sys_rt_sigtimedwait() and
    sys_rt_sigtimedwait().

    Calculate the timeout before we take ->siglock, this simplifies and
    lessens the code. Use timespec_valid() to check the timespec.

    Signed-off-by: Oleg Nesterov
    Acked-by: Tejun Heo
    Reviewed-by: Matt Fleming

    Oleg Nesterov
     

02 Feb, 2011

2 commits

  • A new syscall is introduced that allows tuning of a POSIX clock. The
    new call, clock_adjtime, takes two parameters, the clock ID and a
    pointer to a struct timex. Any ADJTIMEX(2) operation may be requested
    via this system call, but various POSIX clocks may or may not support
    tuning.

    [ tglx: Adapted to the posix-timer cleanup series. Avoid copy_to_user
    in the error case ]

    Signed-off-by: Richard Cochran
    Acked-by: John Stultz
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Richard Cochran
     
  • Split out the compat timex accessors into separate
    functions. Preparatory patch for a new syscall.

    [ tglx: Split that patch from Richards "posix-timers: Introduce a
    syscall for clock tuning.". Keeps the changes strictly
    separate ]

    Originally-from: Richard Cochran
    Acked-by: John Stultz
    Signed-off-by: Thomas Gleixner
    LKML-Reference:

    Richard Cochran
     

15 Sep, 2010

1 commit

  • compat_alloc_user_space() expects the caller to independently call
    access_ok() to verify the returned area. A missing call could
    introduce problems on some architectures.

    This patch incorporates the access_ok() check into
    compat_alloc_user_space() and also adds a sanity check on the length.
    The existing compat_alloc_user_space() implementations are renamed
    arch_compat_alloc_user_space() and are used as part of the
    implementation of the new global function.

    This patch assumes NULL will cause __get_user()/__put_user() to either
    fail or access userspace on all architectures. This should be
    followed by checking the return value of compat_access_user_space()
    for NULL in the callers, at which time the access_ok() in the callers
    can also be removed.

    Reported-by: Ben Hawkes
    Signed-off-by: H. Peter Anvin
    Acked-by: Benjamin Herrenschmidt
    Acked-by: Chris Metcalf
    Acked-by: David S. Miller
    Acked-by: Ingo Molnar
    Acked-by: Thomas Gleixner
    Acked-by: Tony Luck
    Cc: Andrew Morton
    Cc: Arnd Bergmann
    Cc: Fenghua Yu
    Cc: H. Peter Anvin
    Cc: Heiko Carstens
    Cc: Helge Deller
    Cc: James Bottomley
    Cc: Kyle McMartin
    Cc: Martin Schwidefsky
    Cc: Paul Mackerras
    Cc: Ralf Baechle
    Cc:

    H. Peter Anvin
     

16 Jul, 2010

1 commit


20 May, 2010

1 commit

  • Commit a45185d2d "cpumask: convert kernel/compat.c" broke libnuma, which
    abuses sched_getaffinity to find out NR_CPUS in order to parse
    /sys/devices/system/node/node*/cpumap.

    On NUMA systems with less than 32 possibly CPUs, the current
    compat_sys_sched_getaffinity now returns '4' instead of the actual
    NR_CPUS/8, which makes libnuma bail out when parsing the cpumap.

    The libnuma call sched_getaffinity(0, bitmap, 4096) at first. It mean
    the libnuma expect the return value of sched_getaffinity() is either len
    argument or NR_CPUS. But it doesn't expect to return nr_cpu_ids.

    Strictly speaking, userland requirement are

    1) Glibc assume the return value mean the lengh of initialized
    of mask argument. E.g. if sched_getaffinity(1024) return 128,
    glibc make zero fill rest 896 byte.
    2) Libnuma assume the return value can be used to guess NR_CPUS
    in kernel. It assume len-arg
    Acked-by: Rusty Russell
    Acked-by: Arnd Bergmann
    Reported-by: Ken Werner
    Cc: stable@kernel.org
    Cc: Andi Kleen
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

01 May, 2009

1 commit

  • sys_kill has the per thread counterpart sys_tgkill. sigqueueinfo is
    missing a thread directed counterpart. Such an interface is important
    for migrating applications from other OSes which have the per thread
    delivery implemented.

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Oleg Nesterov
    Acked-by: Roland McGrath
    Acked-by: Ulrich Drepper

    Thomas Gleixner