1. 02 Nov, 2017 1 commit
    • 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
      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>
  2. 31 Oct, 2017 1 commit
    • Kees Cook's avatar
      treewide: Fix function prototypes for module_param_call() · e4dca7b7
      Kees Cook authored
      Several function prototypes for the set/get functions defined by
      module_param_call() have a slightly wrong argument types. This fixes
      those in an effort to clean up the calls when running under type-enforced
      compiler instrumentation for CFI. This is the result of running the
      following semantic patch:
      declarer name module_param_call;
      identifier _name, _set_func, _get_func;
      expression _arg, _mode;
       module_param_call(_name, _set_func, _get_func, _arg, _mode);
       depends on match_module_param_call_function@
      identifier match_module_param_call_function._set_func;
      identifier _val, _param;
      type _val_type, _param_type;
       int _set_func(
      -_val_type _val
      +const char * _val
      -_param_type _param
      +const struct kernel_param * _param
       ) { ... }
       depends on match_module_param_call_function@
      identifier match_module_param_call_function._get_func;
      identifier _val, _param;
      type _val_type, _param_type;
       int _get_func(
      -_val_type _val
      +char * _val
      -_param_type _param
      +const struct kernel_param * _param
       ) { ... }
      Two additional by-hand changes are included for places where the above
      Coccinelle script didn't notice them:
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarJessica Yu <jeyu@kernel.org>
  3. 21 Oct, 2017 2 commits
  4. 20 Oct, 2017 4 commits
  5. 04 Oct, 2017 2 commits
    • Todd Kjos's avatar
      binder: fix use-after-free in binder_transaction() · 512cf465
      Todd Kjos authored
      User-space normally keeps the node alive when creating a transaction
      since it has a reference to the target. The local strong ref keeps it
      alive if the sending process dies before the target process processes
      the transaction. If the source process is malicious or has a reference
      counting bug, this can fail.
      In this case, when we attempt to decrement the node in the failure
      path, the node has already been freed.
      This is fixed by taking a tmpref on the node while constructing
      the transaction. To avoid re-acquiring the node lock and inner
      proc lock to increment the proc's tmpref, a helper is used that
      does the ref increments on both the node and proc.
      Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Sherry Yang's avatar
      android: binder: drop lru lock in isolate callback · a1b2289c
      Sherry Yang authored
      Drop the global lru lock in isolate callback before calling
      zap_page_range which calls cond_resched, and re-acquire the global lru
      lock before returning.  Also change return code to LRU_REMOVED_RETRY.
      Use mmput_async when fail to acquire mmap sem in an atomic context.
      Fix "BUG: sleeping function called from invalid context"
      errors when CONFIG_DEBUG_ATOMIC_SLEEP is enabled.
      Also restore mmput_async, which was initially introduced in commit
      ec8d7c14 ("mm, oom_reaper: do not mmput synchronously from the oom
      reaper context"), and was removed in commit 21292580 ("mm: oom: let
      oom_reap_task and exit_mmap run concurrently").
      Link: http://lkml.kernel.org/r/20170914182231.90908-1-sherryy@android.com
      Fixes: f2517eb7 ("android: binder: Add global lru shrinker to binder")
      Signed-off-by: default avatarSherry Yang <sherryy@android.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Reported-by: default avatarKyle Yan <kyan@codeaurora.org>
      Acked-by: default avatarArve Hjønnevåg <arve@android.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Martijn Coenen <maco@google.com>
      Cc: Todd Kjos <tkjos@google.com>
      Cc: Riley Andrews <riandrews@android.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Hoeun Ryu <hoeun.ryu@gmail.com>
      Cc: Christopher Lameter <cl@linux.com>
      Cc: Vegard Nossum <vegard.nossum@oracle.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  6. 18 Sep, 2017 3 commits
    • Xu YiPing's avatar
      binder: fix memory corruption in binder_transaction binder · d53bebdf
      Xu YiPing authored
      commit 7a4408c6 ("binder: make sure accesses to proc/thread are
      safe") made a change to enqueue tcomplete to thread->todo before
      enqueuing the transaction. However, in err_dead_proc_or_thread case,
      the tcomplete is directly freed, without dequeued. It may cause the
      thread->todo list to be corrupted.
      So, dequeue it before freeing.
      Fixes: 7a4408c6 ("binder: make sure accesses to proc/thread are safe")
      Signed-off-by: default avatarXu YiPing <xuyiping@hisilicon.com>
      Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Xu YiPing's avatar
      binder: fix an ret value override · 52b81611
      Xu YiPing authored
      commit 372e3147 ("binder: guarantee txn complete / errors delivered
      in-order") incorrectly defined a local ret value.  This ret value will
      be invalid when out of the if block
      Fixes: 372e3147 ("binder: refactor binder ref inc/dec for thread safety")
      Signed-off-by: default avatarXu YiPing <xuyiping@hislicon.com>
      Signed-off-by: default avatarTodd Kjos <tkjos@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    • Arnd Bergmann's avatar
      android: binder: fix type mismatch warning · 1c363eae
      Arnd Bergmann authored
      Allowing binder to expose the 64-bit API on 32-bit kernels caused a
      build warning:
      drivers/android/binder.c: In function 'binder_transaction_buffer_release':
      drivers/android/binder.c:2220:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
          fd_array = (u32 *)(parent_buffer + fda->parent_offset);
      drivers/android/binder.c: In function 'binder_translate_fd_array':
      drivers/android/binder.c:2445:13: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
        fd_array = (u32 *)(parent_buffer + fda->parent_offset);
      drivers/android/binder.c: In function 'binder_fixup_parent':
      drivers/android/binder.c:2511:18: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
      This adds extra type casts to avoid the warning.
      However, there is another problem with the Kconfig option: turning
      it on or off creates two incompatible ABI versions, a kernel that
      has this enabled cannot run user space that was built without it
      or vice versa. A better solution might be to leave the option hidden
      until the binder code is fixed to deal with both ABI versions.
      Fixes: e8d2ed7d ("Revert "staging: Fix build issues with new binder API"")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
  7. 01 Sep, 2017 8 commits
  8. 28 Aug, 2017 6 commits
  9. 23 Aug, 2017 4 commits
  10. 17 Jul, 2017 9 commits