19 Aug, 2012

1 commit

  • Some of the arguments to {g,s}etsockopt are passed in userland pointers.
    If we try to use the 64bit entry point, we end up sometimes failing.

    For example, dhcpcd doesn't run in x32:
    # dhcpcd eth0
    dhcpcd[1979]: version 5.5.6 starting
    dhcpcd[1979]: eth0: broadcasting for a lease
    dhcpcd[1979]: eth0: open_socket: Invalid argument
    dhcpcd[1979]: eth0: send_raw_packet: Bad file descriptor

    The code in particular is getting back EINVAL when doing:
    struct sock_fprog pf;
    setsockopt(s, SOL_SOCKET, SO_ATTACH_FILTER, &pf, sizeof(pf));

    Diving into the kernel code, we can see:
    include/linux/filter.h:
    struct sock_fprog {
    unsigned short len;
    struct sock_filter __user *filter;
    };

    net/core/sock.c:
    case SO_ATTACH_FILTER:
    ret = -EINVAL;
    if (optlen == sizeof(struct sock_fprog)) {
    struct sock_fprog fprog;

    ret = -EFAULT;
    if (copy_from_user(&fprog, optval, sizeof(fprog)))
    break;

    ret = sk_attach_filter(&fprog, sk);
    }
    break;

    arch/x86/syscalls/syscall_64.tbl:
    54 common setsockopt sys_setsockopt
    55 common getsockopt sys_getsockopt

    So for x64, sizeof(sock_fprog) is 16 bytes. For x86/x32, it's 8 bytes.
    This comes down to the pointer being 32bit for x32, which means we need
    to do structure size translation. But since x32 comes in directly to
    sys_setsockopt, it doesn't get translated like x86.

    After changing the syscall table and rebuilding glibc with the new kernel
    headers, dhcp runs fine in an x32 userland.

    Oddly, it seems like Linus noted the same thing during the initial port,
    but I guess that was missed/lost along the way:
    https://lkml.org/lkml/2011/8/26/452

    [ hpa: tagging for -stable since this is an ABI fix. ]

    Bugzilla: https://bugs.gentoo.org/423649
    Reported-by: Mads
    Signed-off-by: Mike Frysinger
    Link: http://lkml.kernel.org/r/1345320697-15713-1-git-send-email-vapier@gentoo.org
    Cc: H. J. Lu
    Cc: v3.4..v3.5
    Signed-off-by: H. Peter Anvin

    Mike Frysinger
     

02 Aug, 2012

1 commit


01 Jun, 2012

1 commit

  • While doing the checkpoint-restore in the user space one need to determine
    whether various kernel objects (like mm_struct-s of file_struct-s) are
    shared between tasks and restore this state.

    The 2nd step can be solved by using appropriate CLONE_ flags and the
    unshare syscall, while there's currently no ways for solving the 1st one.

    One of the ways for checking whether two tasks share e.g. mm_struct is to
    provide some mm_struct ID of a task to its proc file, but showing such
    info considered to be not that good for security reasons.

    Thus after some debates we end up in conclusion that using that named
    'comparison' syscall might be the best candidate. So here is it --
    __NR_kcmp.

    It takes up to 5 arguments - the pids of the two tasks (which
    characteristics should be compared), the comparison type and (in case of
    comparison of files) two file descriptors.

    Lookups for pids are done in the caller's PID namespace only.

    At moment only x86 is supported and tested.

    [akpm@linux-foundation.org: fix up selftests, warnings]
    [akpm@linux-foundation.org: include errno.h]
    [akpm@linux-foundation.org: tweak comment text]
    Signed-off-by: Cyrill Gorcunov
    Acked-by: "Eric W. Biederman"
    Cc: Pavel Emelyanov
    Cc: Andrey Vagin
    Cc: KOSAKI Motohiro
    Cc: Ingo Molnar
    Cc: H. Peter Anvin
    Cc: Thomas Gleixner
    Cc: Glauber Costa
    Cc: Andi Kleen
    Cc: Tejun Heo
    Cc: Matt Helsley
    Cc: Pekka Enberg
    Cc: Eric Dumazet
    Cc: Vasiliy Kulikov
    Cc: Alexey Dobriyan
    Cc: Valdis.Kletnieks@vt.edu
    Cc: Michal Marek
    Cc: Frederic Weisbecker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Cyrill Gorcunov
     

30 Mar, 2012

1 commit

  • Pull x32 support for x86-64 from Ingo Molnar:
    "This tree introduces the X32 binary format and execution mode for x86:
    32-bit data space binaries using 64-bit instructions and 64-bit kernel
    syscalls.

    This allows applications whose working set fits into a 32 bits address
    space to make use of 64-bit instructions while using a 32-bit address
    space with shorter pointers, more compressed data structures, etc."

    Fix up trivial context conflicts in arch/x86/{Kconfig,vdso/vma.c}

    * 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (71 commits)
    x32: Fix alignment fail in struct compat_siginfo
    x32: Fix stupid ia32/x32 inversion in the siginfo format
    x32: Add ptrace for x32
    x32: Switch to a 64-bit clock_t
    x32: Provide separate is_ia32_task() and is_x32_task() predicates
    x86, mtrr: Use explicit sizing and padding for the 64-bit ioctls
    x86/x32: Fix the binutils auto-detect
    x32: Warn and disable rather than error if binutils too old
    x32: Only clear TIF_X32 flag once
    x32: Make sure TS_COMPAT is cleared for x32 tasks
    fs: Remove missed ->fds_bits from cessation use of fd_set structs internally
    fs: Fix close_on_exec pointer in alloc_fdtable
    x32: Drop non-__vdso weak symbols from the x32 VDSO
    x32: Fix coding style violations in the x32 VDSO code
    x32: Add x32 VDSO support
    x32: Allow x32 to be configured
    x32: If configured, add x32 system calls to system call tables
    x32: Handle process creation
    x32: Signal-related system calls
    x86: Add #ifdef CONFIG_COMPAT to
    ...

    Linus Torvalds
     

23 Mar, 2012

1 commit

  • Syscall 282 was mistakenly named mq_getsetaddr instead of mq_getsetattr.
    When building uClibc against the Linux kernel this would result in a
    shared library that doesn't provide the mq_getattr() and mq_setattr()
    functions.

    Signed-off-by: Thierry Reding
    Link: http://lkml.kernel.org/r/1332366608-2695-2-git-send-email-thierry.reding@avionic-design.de
    Cc: v3.3
    Signed-off-by: H. Peter Anvin

    Thierry Reding
     

06 Mar, 2012

2 commits

  • X32 ptrace is a hybrid of 64bit ptrace and compat ptrace with 32bit
    address and longs. It use 64bit ptrace to access the full 64bit
    registers. PTRACE_PEEKUSR and PTRACE_POKEUSR are only allowed to access
    segment and debug registers. PTRACE_PEEKUSR returns the lower 32bits
    and PTRACE_POKEUSR zero-extends 32bit value to 64bit. It works since
    the upper 32bits of segment and debug registers of x32 process are always
    zero. GDB only uses PTRACE_PEEKUSR and PTRACE_POKEUSR to access
    segment and debug registers.

    [ hpa: changed TIF_X32 test to use !is_ia32_task() instead, and moved
    the system call number to the now-unused 521 slot. ]

    Signed-off-by: "H.J. Lu"
    Signed-off-by: H. Peter Anvin
    Cc: Roland McGrath
    Cc: Oleg Nesterov
    Link: http://lkml.kernel.org/r/1329696488-16970-1-git-send-email-hpa@zytor.com

    H.J. Lu
     
  • clock_t is used mainly to give the number of jiffies a certain process
    has burned. It is entirely feasible for a long-running process to
    consume more than 2^32 jiffies especially in a multiprocess system.
    As such, switch to a 64-bit clock_t for x32, just as we already
    switched to a 64-bit time_t.

    clock_t is only used in a handful of places, and as such it is really
    not a very significant change. The one that has the biggest impact is
    in struct siginfo, but since the *size* of struct siginfo doesn't
    change (it is padded to the hilt) it is fairly easy to make this a
    localized change.

    This also gets rid of sys_x32_times, however since this is a pretty
    late change don't compactify the system call numbers; we can reuse
    system call slot 521 next time we need an x32 system call.

    Reported-by: Gregory M. Lueck
    Signed-off-by: H. Peter Anvin
    Cc: H. J. Lu
    Link: http://lkml.kernel.org/r/1329696488-16970-1-git-send-email-hpa@zytor.com

    H. Peter Anvin
     

21 Feb, 2012

4 commits


19 Nov, 2011

2 commits

  • Allow the specified syscall offset to be symbolic, e.g. a macro. For
    offset system calls, this if nothing else makes the generated code
    easier to read.

    Suggested-by: H. J. Lu
    Link: http://lkml.kernel.org/r/1321569446-20433-7-git-send-email-hpa@linux.intel.com
    Signed-off-by: H. Peter Anvin

    H. Peter Anvin
     
  • Simplify syscallhdr.sh by letting grep sort out the ABIs that we want,
    rather than relying on manual list matching. This is safe since the
    ABI strings already have to consist only of characters which are valid in C
    macro names.

    Suggested-by: Matt Helsley
    Link: http://lkml.kernel.org/r/20111118221558.GA6408@count0.beaverton.ibm.com
    Signed-off-by: H. Peter Anvin

    H. Peter Anvin
     

18 Nov, 2011

1 commit