1. 03 Oct, 2018 6 commits
    • Eric W. Biederman's avatar
      signal: Use a smaller struct siginfo in the kernel · 4ce5f9c9
      Eric W. Biederman authored
      We reserve 128 bytes for struct siginfo but only use about 48 bytes on
      64bit and 32 bytes on 32bit.  Someday we might use more but it is unlikely
      to be anytime soon.
      
      Userspace seems content with just enough bytes of siginfo to implement
      sigqueue.  Or in the case of checkpoint/restart reinjecting signals
      the kernel has sent.
      
      Reducing the stack footprint and the work to copy siginfo around from
      2 cachelines to 1 cachelines seems worth doing even if I don't have
      benchmarks to show a performance difference.
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      4ce5f9c9
    • Eric W. Biederman's avatar
      signal: Distinguish between kernel_siginfo and siginfo · ae7795bc
      Eric W. Biederman authored
      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: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      ae7795bc
    • Eric W. Biederman's avatar
      signal: Introduce copy_siginfo_from_user and use it's return value · 4cd2e0e7
      Eric W. Biederman authored
      In preparation for using a smaller version of siginfo in the kernel
      introduce copy_siginfo_from_user and use it when siginfo is copied from
      userspace.
      
      Make the pattern for using copy_siginfo_from_user and
      copy_siginfo_from_user32 to capture the return value and return that
      value on error.
      
      This is a necessary prerequisite for using a smaller siginfo
      in the kernel than the kernel exports to userspace.
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      4cd2e0e7
    • Eric W. Biederman's avatar
      signal: Remove the need for __ARCH_SI_PREABLE_SIZE and SI_PAD_SIZE · f2838018
      Eric W. Biederman authored
      Rework the defintion of struct siginfo so that the array padding
      struct siginfo to SI_MAX_SIZE can be placed in a union along side of
      the rest of the struct siginfo members.  The result is that we no
      longer need the __ARCH_SI_PREAMBLE_SIZE or SI_PAD_SIZE definitions.
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      f2838018
    • Eric W. Biederman's avatar
      signal: Fail sigqueueinfo if si_signo != sig · e75dc036
      Eric W. Biederman authored
      The kernel needs to validate that the contents of struct siginfo make
      sense as siginfo is copied into the kernel, so that the proper union
      members can be put in the appropriate locations.  The field si_signo
      is a fundamental part of that validation.  As such changing the
      contents of si_signo after the validation make no sense and can result
      in nonsense values in the kernel.
      
      As such simply fail if someone is silly enough to set si_signo out of
      sync with the signal number passed to sigqueueinfo.
      
      I don't expect a problem as glibc's sigqueue implementation sets
      "si_signo = sig" and CRIU just returns to the kernel what the kernel
      gave to it.
      
      If there is some application that calls sigqueueinfo directly that has
      a problem with this added sanity check we can revisit this when we see
      what kind of crazy that application is doing.
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      e75dc036
    • Eric W. Biederman's avatar
      signal/sparc: Move EMT_TAGOVF into the generic siginfo.h · 018303a9
      Eric W. Biederman authored
      When moving all of the architectures specific si_codes into
      siginfo.h, I apparently overlooked EMT_TAGOVF.  Move it now.
      
      Remove the now redundant test in siginfo_layout for SIGEMT
      as now NSIGEMT is always defined.
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      018303a9
  2. 27 Sep, 2018 27 commits
  3. 21 Sep, 2018 7 commits