1. 21 Jul, 2014 1 commit
    • Mike Frysinger's avatar
      x86, x32: Use compat shims for io_{setup,submit} · e7bef68b
      Mike Frysinger authored
      commit 7fd44dac
      
       upstream.
      
      The io_setup takes a pointer to a context id of type aio_context_t.
      This in turn is typed to a __kernel_ulong_t.  We could tweak the
      exported headers to define this as a 64bit quantity for specific
      ABIs, but since we already have a 32bit compat shim for the x86 ABI,
      let's just re-use that logic.  The libaio package is also written to
      expect this as a pointer type, so a compat shim would simplify that.
      
      The io_submit func operates on an array of pointers to iocb structs.
      Padding out the array to be 64bit aligned is a huge pain, so convert
      it over to the existing compat shim too.
      
      We don't convert io_getevents to the compat func as its only purpose
      is to handle the timespec struct, and the x32 ABI uses 64bit times.
      
      With this change, the libaio package can now pass its testsuite when
      built for the x32 ABI.
      Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
      Link: http://lkml.kernel.org/r/1399250595-5005-1-git-send-email-vapier@gentoo.org
      
      
      Cc: H.J. Lu <hjl.tools@gmail.com>
      Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
      Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
      e7bef68b
  2. 19 Dec, 2012 2 commits
  3. 14 Dec, 2012 1 commit
    • Kees Cook's avatar
      module: add syscall to load module from fd · 34e1169d
      Kees Cook authored
      As part of the effort to create a stronger boundary between root and
      kernel, Chrome OS wants to be able to enforce that kernel modules are
      being loaded only from our read-only crypto-hash verified (dm_verity)
      root filesystem. Since the init_module syscall hands the kernel a module
      as a memory blob, no reasoning about the origin of the blob can be made.
      
      Earlier proposals for appending signatures to kernel modules would not be
      useful in Chrome OS, since it would involve adding an additional set of
      keys to our kernel and builds for no good reason: we already trust the
      contents of our root filesystem. We don't need to verify those kernel
      modules a second time. Having to do signature checking on module loading
      would slow us down and be redundant. All we need to know is where a
      module is coming from so we can say yes/no to loading it.
      
      If a file descriptor is used as the source of a kernel module, many more
      things can be reasoned about. In Chrome OS's case, we could e...
      34e1169d
  4. 18 Aug, 2012 1 commit
    • Mike Frysinger's avatar
      x32: Use compat shims for {g,s}etsockopt · 515c7af8
      Mike Frysinger authored
      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: default avatarMads <mads@ab3.no>
      Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
      Link: http://lkml.kernel.org/r/1345320697-15713-1-git-send-email-vapier@gentoo.org
      
      
      Cc: H. J. Lu <hjl.tools@gmail.com>
      Cc: <stable@vger.kernel.org> v3.4..v3.5
      Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
      515c7af8
  5. 01 Aug, 2012 1 commit
  6. 01 Jun, 2012 1 commit
    • Cyrill Gorcunov's avatar
      syscalls, x86: add __NR_kcmp syscall · d97b46a6
      Cyrill Gorcunov authored
      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...
      d97b46a6
  7. 05 Mar, 2012 2 commits
    • H.J. Lu's avatar
      x32: Add ptrace for x32 · 55283e25
      H.J. Lu authored
      
      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: default avatar"H.J. Lu" <hjl.tools@gmail.com>
      Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
      Cc: Roland McGrath <roland@hack.frob.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Link: http://lkml.kernel.org/r/1329696488-16970-1-git-send-email-hpa@zytor.com
      55283e25
    • H. Peter Anvin's avatar
      x32: Switch to a 64-bit clock_t · e7084fd5
      H. Peter Anvin authored
      
      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: default avatarGregory M. Lueck <gregory.m.lueck@intel.com>
      Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
      Cc: H. J. Lu <hjl.tools@gmail.com>
      Link: http://lkml.kernel.org/r/1329696488-16970-1-git-send-email-hpa@zytor.com
      e7084fd5
  8. 20 Feb, 2012 1 commit
  9. 17 Nov, 2011 1 commit