Skip to content
Snippets Groups Projects
  1. Mar 10, 2022
  2. Mar 08, 2022
  3. Mar 02, 2022
  4. Jan 22, 2022
  5. Jan 08, 2022
    • Eric W. Biederman's avatar
      signal: Remove the helper signal_group_exit · 49697335
      Eric W. Biederman authored
      This helper is misleading.  It tests for an ongoing exec as well as
      the process having received a fatal signal.
      
      Sometimes it is appropriate to treat an on-going exec differently than
      a process that is shutting down due to a fatal signal.  In particular
      taking the fast path out of exit_signals instead of retargeting
      signals is not appropriate during exec, and not changing the the exit
      code in do_group_exit during exec.
      
      Removing the helper makes it more obvious what is going on as both
      cases must be coded for explicitly.
      
      While removing the helper fix the two cases where I have observed
      using signal_group_exit resulted in the wrong result.
      
      In exit_signals only test for SIGNAL_GROUP_EXIT so that signals are
      retargetted during an exec.
      
      In do_group_exit use 0 as the exit code during an exec as de_thread
      does not set group_exit_code.  As best as I can determine
      group_exit_code has been is set to 0 most of the time during
      de_thread.  During a thread group stop group_exit_code is set to the
      stop signal and when the thread group receives SIGCONT group_exit_code
      is reset to 0.
      
      Link: https://lkml.kernel.org/r/20211213225350.27481-8-ebiederm@xmission.com
      
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      49697335
    • Eric W. Biederman's avatar
      coredump: Stop setting signal->group_exit_task · 6ac79ec5
      Eric W. Biederman authored
      Currently the coredump code sets group_exit_task so that
      signal_group_exit() will return true during a coredump.  Now that the
      coredump code always sets SIGNAL_GROUP_EXIT there is no longer a need
      to set signal->group_exit_task.
      
      Link: https://lkml.kernel.org/r/20211213225350.27481-6-ebiederm@xmission.com
      
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      6ac79ec5
    • Eric W. Biederman's avatar
      signal: Remove SIGNAL_GROUP_COREDUMP · 2f824d4d
      Eric W. Biederman authored
      After the previous cleanups "signal->core_state" is set whenever
      SIGNAL_GROUP_COREDUMP is set and "signal->core_state" is tested
      whenver the code wants to know if a coredump is in progress.  The
      remaining tests of SIGNAL_GROUP_COREDUMP also test to see if
      SIGNAL_GROUP_EXIT is set.  Similarly the only place that sets
      SIGNAL_GROUP_COREDUMP also sets SIGNAL_GROUP_EXIT.
      
      Which makes SIGNAL_GROUP_COREDUMP unecessary and redundant. So stop
      setting SIGNAL_GROUP_COREDUMP, stop testing SIGNAL_GROUP_COREDUMP, and
      remove it's definition.
      
      With the setting of SIGNAL_GROUP_COREDUMP gone, coredump_finish no
      longer needs to clear SIGNAL_GROUP_COREDUMP out of signal->flags
      by setting SIGNAL_GROUP_EXIT.
      
      Link: https://lkml.kernel.org/r/20211213225350.27481-5-ebiederm@xmission.com
      
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      2f824d4d
    • Eric W. Biederman's avatar
      signal: During coredumps set SIGNAL_GROUP_EXIT in zap_process · 752dc970
      Eric W. Biederman authored
      There are only a few places that test SIGNAL_GROUP_EXIT and
      are not also already testing SIGNAL_GROUP_COREDUMP.
      
      This will not affect the callers of signal_group_exit as zap_process
      also sets group_exit_task so signal_group_exit will continue to return
      true at the same times.
      
      This does not affect wait_task_zombie as the none of the threads
      wind up in EXIT_ZOMBIE state during a coredump.
      
      This does not affect oom_kill.c:__task_will_free_mem as
      sig->core_state is tested and handled before SIGNAL_GROUP_EXIT is
      tested for.
      
      This does not affect complete_signal as signal->core_state is tested
      for to ensure the coredump case is handled appropriately.
      
      Link: https://lkml.kernel.org/r/20211213225350.27481-4-ebiederm@xmission.com
      
      
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      752dc970
  6. Oct 08, 2021
    • Eric W. Biederman's avatar
      coredump: Limit coredumps to a single thread group · 0258b5fd
      Eric W. Biederman authored
      
      Today when a signal is delivered with a handler of SIG_DFL whose
      default behavior is to generate a core dump not only that process but
      every process that shares the mm is killed.
      
      In the case of vfork this looks like a real world problem.  Consider
      the following well defined sequence.
      
      	if (vfork() == 0) {
      		execve(...);
      		_exit(EXIT_FAILURE);
      	}
      
      If a signal that generates a core dump is received after vfork but
      before the execve changes the mm the process that called vfork will
      also be killed (as the mm is shared).
      
      Similarly if the execve fails after the point of no return the kernel
      delivers SIGSEGV which will kill both the exec'ing process and because
      the mm is shared the process that called vfork as well.
      
      As far as I can tell this behavior is a violation of people's
      reasonable expectations, POSIX, and is unnecessarily fragile when the
      system is low on memory.
      
      Solve this by making a userspace visible change to only kill a single
      process/thread group.  This is possible because Jann Horn recently
      modified[1] the coredump code so that the mm can safely be modified
      while the coredump is happening.  With LinuxThreads long gone I don't
      expect anyone to have a notice this behavior change in practice.
      
      To accomplish this move the core_state pointer from mm_struct to
      signal_struct, which allows different thread groups to coredump
      simultatenously.
      
      In zap_threads remove the work to kill anything except for the current
      thread group.
      
      v2: Remove core_state from the VM_BUG_ON_MM print to fix
          compile failure when CONFIG_DEBUG_VM is enabled.
      Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      
      [1] a07279c9 ("binfmt_elf, binfmt_elf_fdpic: use a VMA list snapshot")
      Fixes: d89f3847def4 ("[PATCH] thread-aware coredumps, 2.5.43-C3")
      History-tree: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
      Link: https://lkml.kernel.org/r/87y27mvnke.fsf@disp2133
      Link: https://lkml.kernel.org/r/20211007144701.67592574@canb.auug.org.au
      
      
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      0258b5fd
  7. Oct 06, 2021
    • Eric W. Biederman's avatar
      coredump: Don't perform any cleanups before dumping core · 92307383
      Eric W. Biederman authored
      Rename coredump_exit_mm to coredump_task_exit and call it from do_exit
      before PTRACE_EVENT_EXIT, and before any cleanup work for a task
      happens.  This ensures that an accurate copy of the process can be
      captured in the coredump as no cleanup for the process happens before
      the coredump completes.  This also ensures that PTRACE_EVENT_EXIT
      will not be visited by any thread until the coredump is complete.
      
      Add a new flag PF_POSTCOREDUMP so that tasks that have passed through
      coredump_task_exit can be recognized and ignored in zap_process.
      
      Now that all of the coredumping happens before exit_mm remove code to
      test for a coredump in progress from mm_release.
      
      Replace "may_ptrace_stop()" with a simple test of "current->ptrace".
      The other tests in may_ptrace_stop all concern avoiding stopping
      during a coredump.  These tests are no longer necessary as it is now
      guaranteed that fatal_signal_pending will be set if the code enters
      ptrace_stop during a coredump.  The code in ptrace_stop is guaranteed
      not to stop if fatal_signal_pending returns true.
      
      Until this change "ptrace_event(PTRACE_EVENT_EXIT)" could call
      ptrace_stop without fatal_signal_pending being true, as signals are
      dequeued in get_signal before calling do_exit.  This is no longer
      an issue as "ptrace_event(PTRACE_EVENT_EXIT)" is no longer reached
      until after the coredump completes.
      
      Link: https://lkml.kernel.org/r/874kaax26c.fsf@disp2133
      
      
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      92307383
    • Eric W. Biederman's avatar
      exit: Factor coredump_exit_mm out of exit_mm · d67e03e3
      Eric W. Biederman authored
      Separate the coredump logic from the ordinary exit_mm logic
      by moving the coredump logic out of exit_mm into it's own
      function coredump_exit_mm.
      
      Link: https://lkml.kernel.org/r/87a6k2x277.fsf@disp2133
      
      
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      d67e03e3
  8. Sep 08, 2021
  9. Jun 10, 2021
    • Eric W. Biederman's avatar
      coredump: Limit what can interrupt coredumps · 06af8679
      Eric W. Biederman authored
      
      Olivier Langlois has been struggling with coredumps being incompletely written in
      processes using io_uring.
      
      Olivier Langlois <olivier@trillion01.com> writes:
      > io_uring is a big user of task_work and any event that io_uring made a
      > task waiting for that occurs during the core dump generation will
      > generate a TIF_NOTIFY_SIGNAL.
      >
      > Here are the detailed steps of the problem:
      > 1. io_uring calls vfs_poll() to install a task to a file wait queue
      >    with io_async_wake() as the wakeup function cb from io_arm_poll_handler()
      > 2. wakeup function ends up calling task_work_add() with TWA_SIGNAL
      > 3. task_work_add() sets the TIF_NOTIFY_SIGNAL bit by calling
      >    set_notify_signal()
      
      The coredump code deliberately supports being interrupted by SIGKILL,
      and depends upon prepare_signal to filter out all other signals.   Now
      that signal_pending includes wake ups for TIF_NOTIFY_SIGNAL this hack
      in dump_emitted by the coredump code no longer works.
      
      Make the coredump code more robust by explicitly testing for all of
      the wakeup conditions the coredump code supports.  This prevents
      new wakeup conditions from breaking the coredump code, as well
      as fixing the current issue.
      
      The filesystem code that the coredump code uses already limits
      itself to only aborting on fatal_signal_pending.  So it should
      not develop surprising wake-up reasons either.
      
      v2: Don't remove the now unnecessary code in prepare_signal.
      
      Cc: stable@vger.kernel.org
      Fixes: 12db8b69 ("entry: Add support for TIF_NOTIFY_SIGNAL")
      Reported-by: default avatarOlivier Langlois <olivier@trillion01.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      06af8679
  10. Apr 07, 2021
  11. Mar 08, 2021
    • Al Viro's avatar
      coredump: don't bother with do_truncate() · d0f1088b
      Al Viro authored
      
      have dump_skip() just remember how much needs to be skipped,
      leave actual seeks/writing zeroes to the next dump_emit()
      or the end of coredump output, whichever comes first.
      And instead of playing with do_truncate() in the end, just
      write one NUL at the end of the last gap (if any).
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      d0f1088b
  12. Feb 26, 2021
  13. Jan 24, 2021
  14. Dec 10, 2020
  15. Dec 06, 2020
  16. Oct 16, 2020
  17. Aug 12, 2020
  18. Jun 09, 2020
  19. Apr 28, 2020
    • Luis Chamberlain's avatar
      coredump: fix crash when umh is disabled · 3740d93e
      Luis Chamberlain authored
      Commit 64e90a8a ("Introduce STATIC_USERMODEHELPER to mediate
      call_usermodehelper()") added the optiont to disable all
      call_usermodehelper() calls by setting STATIC_USERMODEHELPER_PATH to
      an empty string. When this is done, and crashdump is triggered, it
      will crash on null pointer dereference, since we make assumptions
      over what call_usermodehelper_exec() did.
      
      This has been reported by Sergey when one triggers a a coredump
      with the following configuration:
      
      ```
      CONFIG_STATIC_USERMODEHELPER=y
      CONFIG_STATIC_USERMODEHELPER_PATH=""
      kernel.core_pattern = |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e
      ```
      
      The way disabling the umh was designed was that call_usermodehelper_exec()
      would just return early, without an error. But coredump assumes
      certain variables are set up for us when this happens, and calls
      ile_start_write(cprm.file) with a NULL file.
      
      [    2.819676] BUG: kernel NULL pointer dereference, address: 0000000000000020
      [    2.819859] #PF: supervisor read access in kernel mode
      [    2.820035] #PF: error_code(0x0000) - not-present page
      [    2.820188] PGD 0 P4D 0
      [    2.820305] Oops: 0000 [#1] SMP PTI
      [    2.820436] CPU: 2 PID: 89 Comm: a Not tainted 5.7.0-rc1+ #7
      [    2.820680] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190711_202441-buildvm-armv7-10.arm.fedoraproject.org-2.fc31 04/01/2014
      [    2.821150] RIP: 0010:do_coredump+0xd80/0x1060
      [    2.821385] Code: e8 95 11 ed ff 48 c7 c6 cc a7 b4 81 48 8d bd 28 ff
      ff ff 89 c2 e8 70 f1 ff ff 41 89 c2 85 c0 0f 84 72 f7 ff ff e9 b4 fe ff
      ff <48> 8b 57 20 0f b7 02 66 25 00 f0 66 3d 00 8
      0 0f 84 9c 01 00 00 44
      [    2.822014] RSP: 0000:ffffc9000029bcb8 EFLAGS: 00010246
      [    2.822339] RAX: 0000000000000000 RBX: ffff88803f860000 RCX: 000000000000000a
      [    2.822746] RDX: 0000000000000009 RSI: 0000000000000282 RDI: 0000000000000000
      [    2.823141] RBP: ffffc9000029bde8 R08: 0000000000000000 R09: ffffc9000029bc00
      [    2.823508] R10: 0000000000000001 R11: ffff88803dec90be R12: ffffffff81c39da0
      [    2.823902] R13: ffff88803de84400 R14: 0000000000000000 R15: 0000000000000000
      [    2.824285] FS:  00007fee08183540(0000) GS:ffff88803e480000(0000) knlGS:0000000000000000
      [    2.824767] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    2.825111] CR2: 0000000000000020 CR3: 000000003f856005 CR4: 0000000000060ea0
      [    2.825479] Call Trace:
      [    2.825790]  get_signal+0x11e/0x720
      [    2.826087]  do_signal+0x1d/0x670
      [    2.826361]  ? force_sig_info_to_task+0xc1/0xf0
      [    2.826691]  ? force_sig_fault+0x3c/0x40
      [    2.826996]  ? do_trap+0xc9/0x100
      [    2.827179]  exit_to_usermode_loop+0x49/0x90
      [    2.827359]  prepare_exit_to_usermode+0x77/0xb0
      [    2.827559]  ? invalid_op+0xa/0x30
      [    2.827747]  ret_from_intr+0x20/0x20
      [    2.827921] RIP: 0033:0x55e2c76d2129
      [    2.828107] Code: 2d ff ff ff e8 68 ff ff ff 5d c6 05 18 2f 00 00 01
      c3 0f 1f 80 00 00 00 00 c3 0f 1f 80 00 00 00 00 e9 7b ff ff ff 55 48 89
      e5 <0f> 0b b8 00 00 00 00 5d c3 66 2e 0f 1f 84 0
      0 00 00 00 00 0f 1f 40
      [    2.828603] RSP: 002b:00007fffeba5e080 EFLAGS: 00010246
      [    2.828801] RAX: 000055e2c76d2125 RBX: 0000000000000000 RCX: 00007fee0817c718
      [    2.829034] RDX: 00007fffeba5e188 RSI: 00007fffeba5e178 RDI: 0000000000000001
      [    2.829257] RBP: 00007fffeba5e080 R08: 0000000000000000 R09: 00007fee08193c00
      [    2.829482] R10: 0000000000000009 R11: 0000000000000000 R12: 000055e2c76d2040
      [    2.829727] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
      [    2.829964] CR2: 0000000000000020
      [    2.830149] ---[ end trace ceed83d8c68a1bf1 ]---
      ```
      
      Cc: <stable@vger.kernel.org> # v4.11+
      Fixes: 64e90a8a ("Introduce STATIC_USERMODEHELPER to mediate call_usermodehelper()")
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199795
      
      
      Reported-by: default avatarTony Vroon <chainsaw@gentoo.org>
      Reported-by: default avatarSergey Kvachonok <ravenexp@gmail.com>
      Tested-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Link: https://lore.kernel.org/r/20200416162859.26518-1-mcgrof@kernel.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3740d93e
  20. Apr 21, 2020
  21. Feb 08, 2020
    • Linus Torvalds's avatar
      pipe: use exclusive waits when reading or writing · 0ddad21d
      Linus Torvalds authored
      
      This makes the pipe code use separate wait-queues and exclusive waiting
      for readers and writers, avoiding a nasty thundering herd problem when
      there are lots of readers waiting for data on a pipe (or, less commonly,
      lots of writers waiting for a pipe to have space).
      
      While this isn't a common occurrence in the traditional "use a pipe as a
      data transport" case, where you typically only have a single reader and
      a single writer process, there is one common special case: using a pipe
      as a source of "locking tokens" rather than for data communication.
      
      In particular, the GNU make jobserver code ends up using a pipe as a way
      to limit parallelism, where each job consumes a token by reading a byte
      from the jobserver pipe, and releases the token by writing a byte back
      to the pipe.
      
      This pattern is fairly traditional on Unix, and works very well, but
      will waste a lot of time waking up a lot of processes when only a single
      reader needs to be woken up when a writer releases a new token.
      
      A simplified test-case of just this pipe interaction is to create 64
      processes, and then pass a single token around between them (this
      test-case also intentionally passes another token that gets ignored to
      test the "wake up next" logic too, in case anybody wonders about it):
      
          #include <unistd.h>
      
          int main(int argc, char **argv)
          {
              int fd[2], counters[2];
      
              pipe(fd);
              counters[0] = 0;
              counters[1] = -1;
              write(fd[1], counters, sizeof(counters));
      
              /* 64 processes */
              fork(); fork(); fork(); fork(); fork(); fork();
      
              do {
                      int i;
                      read(fd[0], &i, sizeof(i));
                      if (i < 0)
                              continue;
                      counters[0] = i+1;
                      write(fd[1], counters, (1+(i & 1)) *sizeof(int));
              } while (counters[0] < 1000000);
              return 0;
          }
      
      and in a perfect world, passing that token around should only cause one
      context switch per transfer, when the writer of a token causes a
      directed wakeup of just a single reader.
      
      But with the "writer wakes all readers" model we traditionally had, on
      my test box the above case causes more than an order of magnitude more
      scheduling: instead of the expected ~1M context switches, "perf stat"
      shows
      
              231,852.37 msec task-clock                #   15.857 CPUs utilized
              11,250,961      context-switches          #    0.049 M/sec
                 616,304      cpu-migrations            #    0.003 M/sec
                   1,648      page-faults               #    0.007 K/sec
       1,097,903,998,514      cycles                    #    4.735 GHz
         120,781,778,352      instructions              #    0.11  insn per cycle
          27,997,056,043      branches                  #  120.754 M/sec
             283,581,233      branch-misses             #    1.01% of all branches
      
            14.621273891 seconds time elapsed
      
             0.018243000 seconds user
             3.611468000 seconds sys
      
      before this commit.
      
      After this commit, I get
      
                5,229.55 msec task-clock                #    3.072 CPUs utilized
               1,212,233      context-switches          #    0.232 M/sec
                 103,951      cpu-migrations            #    0.020 M/sec
                   1,328      page-faults               #    0.254 K/sec
          21,307,456,166      cycles                    #    4.074 GHz
          12,947,819,999      instructions              #    0.61  insn per cycle
           2,881,985,678      branches                  #  551.096 M/sec
              64,267,015      branch-misses             #    2.23% of all branches
      
             1.702148350 seconds time elapsed
      
             0.004868000 seconds user
             0.110786000 seconds sys
      
      instead. Much better.
      
      [ Note! This kernel improvement seems to be very good at triggering a
        race condition in the make jobserver (in GNU make 4.2.1) for me. It's
        a long known bug that was fixed back in June 2017 by GNU make commit
        b552b0525198 ("[SV 51159] Use a non-blocking read with pselect to
        avoid hangs.").
      
        But there wasn't a new release of GNU make until 4.3 on Jan 19 2020,
        so a number of distributions may still have the buggy version. Some
        have backported the fix to their 4.2.1 release, though, and even
        without the fix it's quite timing-dependent whether the bug actually
        is hit. ]
      
      Josh Triplett says:
       "I've been hammering on your pipe fix patch (switching to exclusive
        wait queues) for a month or so, on several different systems, and I've
        run into no issues with it. The patch *substantially* improves
        parallel build times on large (~100 CPU) systems, both with parallel
        make and with other things that use make's pipe-based jobserver.
      
        All current distributions (including stable and long-term stable
        distributions) have versions of GNU make that no longer have the
        jobserver bug"
      
      Tested-by: default avatarJosh Triplett <josh@joshtriplett.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0ddad21d
  22. Aug 03, 2019
    • Paul Wise's avatar
      coredump: split pipe command whitespace before expanding template · 315c6926
      Paul Wise authored
      Save the offsets of the start of each argument to avoid having to update
      pointers to each argument after every corename krealloc and to avoid
      having to duplicate the memory for the dump command.
      
      Executable names containing spaces were previously being expanded from
      %e or %E and then split in the middle of the filename.  This is
      incorrect behaviour since an argument list can represent arguments with
      spaces.
      
      The splitting could lead to extra arguments being passed to the core
      dump handler that it might have interpreted as options or ignored
      completely.
      
      Core dump handlers that are not aware of this Linux kernel issue will be
      using %e or %E without considering that it may be split and so they will
      be vulnerable to processes with spaces in their names breaking their
      argument list.  If their internals are otherwise well written, such as
      if they are written in shell but quote arguments, they will work better
      after this change than before.  If they are not well written, then there
      is a slight chance of breakage depending on the details of the code but
      they will already be fairly broken by the split filenames.
      
      Core dump handlers that are aware of this Linux kernel issue will be
      placing %e or %E as the last item in their core_pattern and then
      aggregating all of the remaining arguments into one, separated by
      spaces.  Alternatively they will be obtaining the filename via other
      methods.  Both of these will be compatible with the new arrangement.
      
      A side effect from this change is that unknown template types (for
      example %z) result in an empty argument to the dump handler instead of
      the argument being dropped.  This is a desired change as:
      
      It is easier for dump handlers to process empty arguments than dropped
      ones, especially if they are written in shell or don't pass each
      template item with a preceding command-line option in order to
      differentiate between individual template types.  Most core_patterns in
      the wild do not use options so they can confuse different template types
      (especially numeric ones) if an earlier one gets dropped in old kernels.
      If the kernel introduces a new template type and a core_pattern uses it,
      the core dump handler might not expect that the argument can be dropped
      in old kernels.
      
      For example, this can result in security issues when %d is dropped in
      old kernels.  This happened with the corekeeper package in Debian and
      resulted in the interface between corekeeper and Linux having to be
      rewritten to use command-line options to differentiate between template
      types.
      
      The core_pattern for most core dump handlers is written by the handler
      author who would generally not insert unknown template types so this
      change should be compatible with all the core dump handlers that exist.
      
      Link: http://lkml.kernel.org/r/20190528051142.24939-1-pabs3@bonedaddy.net
      
      
      Fixes: 74aadce9 ("core_pattern: allow passing of arguments to user mode helper when core_pattern is a pipe")
      Signed-off-by: default avatarPaul Wise <pabs3@bonedaddy.net>
      Reported-by: Jakub Wilk <jwilk@jwilk.net> [https://bugs.debian.org/924398]
      Reported-by: Paul Wise <pabs3@bonedaddy.net> [https://lore.kernel.org/linux-fsdevel/c8b7ecb8508895bf4adb62a748e2ea2c71854597.camel@bonedaddy.net/
      
      ]
      Suggested-by: default avatarJakub Wilk <jwilk@jwilk.net>
      Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      315c6926
  23. Oct 03, 2018
    • 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
  24. Nov 10, 2017
  25. Nov 02, 2017
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      
      Many source files in the tree are missing licensing information, which
      makes it harder for compliance tools to determine the correct license.
      
      By default all files without license information are under the default
      license of the kernel, which is GPL version 2.
      
      Update the files which contain no license information with the 'GPL-2.0'
      SPDX license identifier.  The SPDX identifier is a legally binding
      shorthand, which can be used instead of the full boiler plate text.
      
      This patch is based on work done by Thomas Gleixner and Kate Stewart and
      Philippe Ombredanne.
      
      How this work was done:
      
      Patches were generated and checked against linux-4.14-rc6 for a subset of
      the use cases:
       - file had no licensing information it it.
       - file was a */uapi/* one with no licensing information in it,
       - file was a */uapi/* one with existing licensing information,
      
      Further patches will be generated in subsequent months to fix up cases
      where non-standard license headers were used, and references to license
      had to be inferred by heuristics based on keywords.
      
      The analysis to determine which SPDX License Identifier to be applied to
      a file was done in a spreadsheet of side by side results from of the
      output of two independent scanners (ScanCode & Windriver) producing SPDX
      tag:value files created by Philippe Ombredanne.  Philippe prepared the
      base worksheet, and did an initial spot review of a few 1000 files.
      
      The 4.13 kernel was the starting point of the analysis with 60,537 files
      assessed.  Kate Stewart did a file by file comparison of the scanner
      results in the spreadsheet to determine which SPDX license identifier(s)
      to be applied to the file. She confirmed any determination that was not
      immediately clear with lawyers working with the Linux Foundation.
      
      Criteria used to select files for SPDX license identifier tagging was:
       - Files considered eligible had to be source code files.
       - Make and config files were included as candidates if they contained >5
         lines of source
       - File already had some variant of a license header in it (even if <5
         lines).
      
      All documentation files were explicitly excluded.
      
      The following heuristics were used to determine which SPDX license
      identifiers to apply.
      
       - when both scanners couldn't find any license traces, file was
         considered to have no license information in it, and the top level
         COPYING file license applied.
      
         For non */uapi/* files that summary was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0                                              11139
      
         and resulted in the first patch in this series.
      
         If that file was a */uapi/* path one, it was "GPL-2.0 WITH
         Linux-syscall-note" otherwise it was "GPL-2.0".  Results of that was:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|-------
         GPL-2.0 WITH Linux-syscall-note                        930
      
         and resulted in the second patch in this series.
      
       - if a file had some form of licensing information in it, and was one
         of the */uapi/* ones, it was denoted with the Linux-syscall-note if
         any GPL family license was found in the file or had no licensing in
         it (per prior point).  Results summary:
      
         SPDX license identifier                            # files
         ---------------------------------------------------|------
         GPL-2.0 WITH Linux-syscall-note                       270
         GPL-2.0+ WITH Linux-syscall-note                      169
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause)    21
         ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)    17
         LGPL-2.1+ WITH Linux-syscall-note                      15
         GPL-1.0+ WITH Linux-syscall-note                       14
         ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause)    5
         LGPL-2.0+ WITH Linux-syscall-note                       4
         LGPL-2.1 WITH Linux-syscall-note                        3
         ((GPL-2.0 WITH Linux-syscall-note) OR MIT)              3
         ((GPL-2.0 WITH Linux-syscall-note) AND MIT)             1
      
         and that resulted in the third patch in this series.
      
       - when the two scanners agreed on the detected license(s), that became
         the concluded license(s).
      
       - when there was disagreement between the two scanners (one detected a
         license but the other didn't, or they both detected different
         licenses) a manual inspection of the file occurred.
      
       - In most cases a manual inspection of the information in the file
         resulted in a clear resolution of the license that should apply (and
         which scanner probably needed to revisit its heuristics).
      
       - When it was not immediately clear, the license identifier was
         confirmed with lawyers working with the Linux Foundation.
      
       - If there was any question as to the appropriate license identifier,
         the file was flagged for further research and to be revisited later
         in time.
      
      In total, over 70 hours of logged manual review was done on the
      spreadsheet to determine the SPDX license identifiers to apply to the
      source files by Kate, Philippe, Thomas and, in some cases, confirmation
      by lawyers working with the Linux Foundation.
      
      Kate also obtained a third independent scan of the 4.13 code base from
      FOSSology, and compared selected files where the other two scanners
      disagreed against that SPDX file, to see if there was new insights.  The
      Windriver scanner is based on an older version of FOSSology in part, so
      they are related.
      
      Thomas did random spot checks in about 500 files from the spreadsheets
      for the uapi headers and agreed with SPDX license identifier in the
      files he inspected. For the non-uapi files Thomas did random spot checks
      in about 15000 files.
      
      In initial set of patches against 4.14-rc6, 3 files were found to have
      copy/paste license identifier errors, and have been fixed to reflect the
      correct identifier.
      
      Additionally Philippe spent 10 hours this week doing a detailed manual
      inspection and review of the 12,461 patched files from the initial patch
      version early this week with:
       - a full scancode scan run, collecting the matched texts, detected
         license ids and scores
       - reviewing anything where there was a license detected (about 500+
         files) to ensure that the applied SPDX license was correct
       - reviewing anything where there was no detection but the patch license
         was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
         SPDX license was correct
      
      This produced a worksheet with 20 files needing minor correction.  This
      worksheet was then exported into 3 different .csv files for the
      different types of files to be modified.
      
      These .csv files were then reviewed by Greg.  Thomas wrote a script to
      parse the csv files and add the proper SPDX tag to the file, in the
      format that the file expected.  This script was further refined by Greg
      based on the output to detect more types of files automatically and to
      distinguish between header and source .c files (which need different
      comment types.)  Finally Greg ran the script using the .csv files to
      generate the patches.
      
      Reviewed-by: default avatarKate Stewart <kstewart@linuxfoundation.org>
      Reviewed-by: default avatarPhilippe Ombredanne <pombredanne@nexb.com>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2441318
  26. Sep 14, 2017
    • Michal Hocko's avatar
      mm: treewide: remove GFP_TEMPORARY allocation flag · 0ee931c4
      Michal Hocko authored
      GFP_TEMPORARY was introduced by commit e12ba74d ("Group short-lived
      and reclaimable kernel allocations") along with __GFP_RECLAIMABLE.  It's
      primary motivation was to allow users to tell that an allocation is
      short lived and so the allocator can try to place such allocations close
      together and prevent long term fragmentation.  As much as this sounds
      like a reasonable semantic it becomes much less clear when to use the
      highlevel GFP_TEMPORARY allocation flag.  How long is temporary? Can the
      context holding that memory sleep? Can it take locks? It seems there is
      no good answer for those questions.
      
      The current implementation of GFP_TEMPORARY is basically GFP_KERNEL |
      __GFP_RECLAIMABLE which in itself is tricky because basically none of
      the existing caller provide a way to reclaim the allocated memory.  So
      this is rather misleading and hard to evaluate for any benefits.
      
      I have checked some random users and none of them has added the flag
      with a specific justification.  I suspect most of them just copied from
      other existing users and others just thought it might be a good idea to
      use without any measuring.  This suggests that GFP_TEMPORARY just
      motivates for cargo cult usage without any reasoning.
      
      I believe that our gfp flags are quite complex already and especially
      those with highlevel semantic should be clearly defined to prevent from
      confusion and abuse.  Therefore I propose dropping GFP_TEMPORARY and
      replace all existing users to simply use GFP_KERNEL.  Please note that
      SLAB users with shrinkers will still get __GFP_RECLAIMABLE heuristic and
      so they will be placed properly for memory fragmentation prevention.
      
      I can see reasons we might want some gfp flag to reflect shorterm
      allocations but I propose starting from a clear semantic definition and
      only then add users with proper justification.
      
      This was been brought up before LSF this year by Matthew [1] and it
      turned out that GFP_TEMPORARY really doesn't have a clear semantic.  It
      seems to be a heuristic without any measured advantage for most (if not
      all) its current users.  The follow up discussion has revealed that
      opinions on what might be temporary allocation differ a lot between
      developers.  So rather than trying to tweak existing users into a
      semantic which they haven't expected I propose to simply remove the flag
      and start from scratch if we really need a semantic for short term
      allocations.
      
      [1] http://lkml.kernel.org/r/20170118054945.GD18349@bombadil.infradead.org
      
      [akpm@linux-foundation.org: fix typo]
      [akpm@linux-foundation.org: coding-style fixes]
      [sfr@canb.auug.org.au: drm/i915: fix up]
        Link: http://lkml.kernel.org/r/20170816144703.378d4f4d@canb.auug.org.au
      Link: http://lkml.kernel.org/r/20170728091904.14627-1-mhocko@kernel.org
      
      
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Acked-by: default avatarMel Gorman <mgorman@suse.de>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Neil Brown <neilb@suse.de>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0ee931c4
  27. Mar 02, 2017
Loading