1. 15 Feb, 2018 1 commit
  2. 31 Dec, 2017 1 commit
  3. 27 Nov, 2017 1 commit
    • Linus Torvalds's avatar
      Rename superblock flags (MS_xyz -> SB_xyz) · 1751e8a6
      Linus Torvalds authored
      This is a pure automated search-and-replace of the internal kernel
      superblock flags.
      The s_flags are now called SB_*, with the names and the values for the
      moment mirroring the MS_* flags that they're equivalent to.
      Note how the MS_xyz flags are the ones passed to the mount system call,
      while the SB_xyz flags are what we then use in sb->s_flags.
      The script to do this was:
          # places to look in; re security/*: it generally should *not* be
          # touched (that stuff parses mount(2) arguments directly), but
          # there are two places where we really deal with superblock flags.
          FILES="drivers/mtd drivers/staging/lustre fs ipc mm \
                  include/linux/fs.h include/uapi/linux/bfs_fs.h \
                  security/apparmor/apparmorfs.c security/apparmor/include/lib.h"
          # the list of MS_... constants
                ACTIVE NOUSER"
          for i in $SYMS; do SED_PROG="$SED_PROG -e s/MS_$i/SB_$i/g"; done
          # we want files that contain at least one of MS_...,
          # with fs/namespace.c and fs/pnode.c excluded.
          L=$(for i in $SYMS; do git grep -w -l MS_$i $FILES; done| sort|uniq|grep -v '^fs/namespace.c'|grep -v '^fs/pnode.c')
          for f in $L; do sed -i $f $SED_PROG; done
      Requested-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  4. 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>
  5. 06 Jul, 2017 1 commit
  6. 09 May, 2017 1 commit
    • Kirill Tkhai's avatar
      ns: allow ns_entries to have custom symlink content · 25b14e92
      Kirill Tkhai authored
      Patch series "Expose task pid_ns_for_children to userspace".
      pid_ns_for_children set by a task is known only to the task itself, and
      it's impossible to identify it from outside.
      It's a big problem for checkpoint/restore software like CRIU, because it
      can't correctly handle tasks, that do setns(CLONE_NEWPID) in proccess of
      their work.  If they have a custom pid_ns_for_children before dump, they
      must have the same ns after restore.  Otherwise, restored task bumped
      into enviroment it does not expect.
      This patchset solves the problem.  It exposes pid_ns_for_children to ns
      directory in standard way with the name "pid_for_children":
        ~# ls /proc/5531/ns -l | grep pid
        lrwxrwxrwx 1 root root 0 Jan 14 16:38 pid -> pid:[4026531836]
        lrwxrwxrwx 1 root root 0 Jan 14 16:38 pid_for_children -> pid:[4026532286]
      This patch (of 2):
      Make possible to have link content prefix yyy different from the link
      name xxx:
        $ readlink /proc/[pid]/ns/xxx
      This will be used in next patch.
      Link: http://lkml.kernel.org/r/149201120318.6007.7362655181033883000.stgit@localhost.localdomainSigned-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
      Reviewed-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      Acked-by: default avatarAndrei Vagin <avagin@virtuozzo.com>
      Cc: Andreas Gruenbacher <agruenba@redhat.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Serge Hallyn <serge@hallyn.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  7. 19 Apr, 2017 1 commit
    • Cong Wang's avatar
      nsfs: mark dentry with DCACHE_RCUACCESS · 073c516f
      Cong Wang authored
      Andrey reported a use-after-free in __ns_get_path():
        spin_lock include/linux/spinlock.h:299 [inline]
        lockref_get_not_dead+0x19/0x80 lib/lockref.c:179
        __ns_get_path+0x197/0x860 fs/nsfs.c:66
        open_related_ns+0xda/0x200 fs/nsfs.c:143
        sock_ioctl+0x39d/0x440 net/socket.c:1001
        vfs_ioctl fs/ioctl.c:45 [inline]
        do_vfs_ioctl+0x1bf/0x1780 fs/ioctl.c:685
        SYSC_ioctl fs/ioctl.c:700 [inline]
        SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
      We are under rcu read lock protection at that point:
              d = atomic_long_read(&ns->stashed);
              if (!d)
                      goto slow;
              dentry = (struct dentry *)d;
              if (!lockref_get_not_dead(&dentry->d_lockref))
                      goto slow;
      but don't use a proper RCU API on the free path, therefore a parallel
      __d_free() could free it at the same time.  We need to mark the stashed
      dentry with DCACHE_RCUACCESS so that __d_free() will be called after all
      readers leave RCU.
      Fixes: e149ed2b ("take the targets of /proc/*/ns/* symlinks to separate fs")
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  8. 03 Feb, 2017 1 commit
    • Michael Kerrisk (man-pages)'s avatar
      nsfs: Add an ioctl() to return owner UID of a userns · d95fa3c7
      Michael Kerrisk (man-pages) authored
      I'd like to write code that discovers the user namespace hierarchy on a
      running system, and also shows who owns the various user namespaces.
      Currently, there is no way of getting the owner UID of a user namespace.
      Therefore, this patch adds a new NS_GET_CREATOR_UID ioctl() that fetches
      the UID (as seen in the user namespace of the caller) of the creator of
      the user namespace referred to by the specified file descriptor.
      If the supplied file descriptor does not refer to a user namespace,
      the operation fails with the error EINVAL. If the owner UID does
      not have a mapping in the caller's user namespace return the
      overflow UID as that appears easier to deal with in practice
      in user-space applications.
      -- EWB Changed the handling of unmapped UIDs from -EOVERFLOW
         back to the overflow uid.  Per conversation with
         Michael Kerrisk after examining his test code.
      Acked-by: default avatarAndrey Vagin <avagin@openvz.org>
      Signed-off-by: default avatarMichael Kerrisk <mtk-manpages@gmail.com>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
  9. 25 Jan, 2017 1 commit
    • Michael Kerrisk (man-pages)'s avatar
      nsfs: Add an ioctl() to return the namespace type · e5ff5ce6
      Michael Kerrisk (man-pages) authored
      Linux 4.9 added two ioctl() operations that can be used to discover:
      * the parental relationships for hierarchical namespaces (user and PID)
      * the user namespaces that owns a specified non-user-namespace
      For no good reason that I can glean, NS_GET_USERNS was made synonymous
      with NS_GET_PARENT for user namespaces. It might have been better if
      NS_GET_USERNS had returned an error if the supplied file descriptor
      referred to a user namespace, since it suggests that the caller may be
      confused. More particularly, if it had generated an error, then I wouldn't
      need the new ioctl() operation proposed here. (On the other hand, what
      I propose here may be more generally useful.)
      I would like to write code that discovers namespace relationships for
      the purpose of understanding the namespace setup on a running system.
      In particular, given a file descriptor (or pathname) for a namespace,
      N, I'd like to obtain the corresponding user namespace.  Namespace N
      might be a user namespace (in which case my code would just use N) or
      a non-user namespace (in which case my code will use NS_GET_USERNS to
      get the user namespace associated with N). The problem is that there
      is no way to tell the difference by looking at the file descriptor
      (and if I try to use NS_GET_USERNS on an N that is a user namespace, I
      get the parent user namespace of N, which is not what I want).
      This patch therefore adds a new ioctl(), NS_GET_NSTYPE, which, given
      a file descriptor that refers to a user namespace, returns the
      namespace type (one of the CLONE_NEW* constants).
      Signed-off-by: default avatarMichael Kerrisk <mtk-manpages@gmail.com>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
  10. 31 Oct, 2016 1 commit
    • Andrey Vagin's avatar
      net: add an ioctl to get a socket network namespace · c62cce2c
      Andrey Vagin authored
      Each socket operates in a network namespace where it has been created,
      so if we want to dump and restore a socket, we have to know its network
      We have a socket_diag to get information about sockets, it doesn't
      report sockets which are not bound or connected.
      This patch introduces a new socket ioctl, which is called SIOCGSKNS
      and used to get a file descriptor for a socket network namespace.
      A task must have CAP_NET_ADMIN in a target network namespace to
      use this ioctl.
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: default avatarAndrei Vagin <avagin@openvz.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  11. 28 Sep, 2016 1 commit
  12. 23 Sep, 2016 3 commits
  13. 11 Sep, 2015 1 commit
    • Joe Perches's avatar
      fs/seq_file: convert int seq_vprint/seq_printf/etc... returns to void · 6798a8ca
      Joe Perches authored
      The seq_<foo> function return values were frequently misused.
      See: commit 1f33c41c ("seq_file: Rename seq_overflow() to
           seq_has_overflowed() and make public")
      All uses of these return values have been removed, so convert the
      return types to void.
      o Move seq_put_decimal_<type> and seq_escape prototypes closer the
        other seq_vprintf prototypes
      o Reorder seq_putc and seq_puts to return early on overflow
      o Add argument names to seq_vprintf and seq_printf
      o Update the seq_escape kernel-doc
      o Convert a couple of leading spaces to tabs in seq_escape
      Signed-off-by: default avatarJoe Perches <joe@perches.com>
      Cc: Al Viro <viro@ZenIV.linux.org.uk>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Joerg Roedel <jroedel@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  14. 11 Jul, 2015 1 commit
  15. 15 Apr, 2015 1 commit
  16. 11 Dec, 2014 1 commit
    • Al Viro's avatar
      take the targets of /proc/*/ns/* symlinks to separate fs · e149ed2b
      Al Viro authored
      New pseudo-filesystem: nsfs.  Targets of /proc/*/ns/* live there now.
      It's not mountable (not even registered, so it's not in /proc/filesystems,
      etc.).  Files on it *are* bindable - we explicitly permit that in do_loopback().
      This stuff lives in fs/nsfs.c now; proc_ns_fget() moved there as well.
      get_proc_ns() is a macro now (it's simply returning ->i_private; would
      have been an inline, if not for header ordering headache).
      proc_ns_inode() is an ex-parrot.  The interface used in procfs is
      ns_get_path(path, task, ops) and ns_get_name(buf, size, task, ops).
      Dentries and inodes are never hashed; a non-counting reference to dentry
      is stashed in ns_common (removed by ->d_prune()) and reused by ns_get_path()
      if present.  See ns_get_path()/ns_prune_dentry/nsfs_evict() for details
      of that mechanism.
      As the result, proc_ns_follow_link() has stopped poking in nd->path.mnt;
      it does nd_jump_link() on a consistent <vfsmount,dentry> pair it gets
      from ns_get_path().
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>