08 Jun, 2018

1 commit


27 May, 2018

2 commits


23 May, 2018

1 commit


07 Feb, 2018

1 commit

  • PROC_NUMBUF is 13 which is enough for "negative int + \n + \0".

    However PIDs and TGIDs are never negative and newline is not a concern,
    so use just 10 per integer.

    Link: http://lkml.kernel.org/r/20171120203005.GA27743@avx2
    Signed-off-by: Alexey Dobriyan
    Cc: Alexander Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

02 Nov, 2017

1 commit

  • 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
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

02 Mar, 2017

1 commit


24 Jan, 2017

1 commit


15 Nov, 2016

1 commit

  • Pass the file mode of the proc inode to be created to
    proc_pid_make_inode. In proc_pid_make_inode, initialize inode->i_mode
    before calling security_task_to_inode. This allows selinux to set
    isec->sclass right away without introducing "half-initialized" inode
    security structs.

    Signed-off-by: Andreas Gruenbacher
    Signed-off-by: Paul Moore

    Andreas Gruenbacher
     

28 Sep, 2016

1 commit


03 May, 2016

1 commit


09 Jan, 2016

1 commit

  • User can pass an arbitrary large buffer to getdents().

    It is typically a 32KB buffer used by libc scandir() implementation.

    When scanning /proc/{pid}/fd, we can hold cpu way too long,
    so add a cond_resched() to be kind with other tasks.

    We've seen latencies of more than 50ms on real workloads.

    Signed-off-by: Eric Dumazet
    Cc: Alexander Viro
    Signed-off-by: Al Viro

    Eric Dumazet
     

07 Nov, 2015

1 commit

  • The commit 96d0df79f264 ("proc: make proc_fd_permission() thread-friendly")
    fixed the access to /proc/self/fd from sub-threads, but introduced another
    problem: a sub-thread can't access /proc//fd/ or /proc/thread-self/fd
    if generic_permission() fails.

    Change proc_fd_permission() to check same_thread_group(pid_task(), current).

    Fixes: 96d0df79f264 ("proc: make proc_fd_permission() thread-friendly")
    Reported-by: "Jin, Yihua"
    Signed-off-by: Oleg Nesterov
    Cc: "Eric W. Biederman"
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     

27 Apr, 2015

1 commit

  • Pull fourth vfs update from Al Viro:
    "d_inode() annotations from David Howells (sat in for-next since before
    the beginning of merge window) + four assorted fixes"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    RCU pathwalk breakage when running into a symlink overmounting something
    fix I_DIO_WAKEUP definition
    direct-io: only inc/dec inode->i_dio_count for file systems
    fs/9p: fix readdir()
    VFS: assorted d_backing_inode() annotations
    VFS: fs/inode.c helpers: d_inode() annotations
    VFS: fs/cachefiles: d_backing_inode() annotations
    VFS: fs library helpers: d_inode() annotations
    VFS: assorted weird filesystems: d_inode() annotations
    VFS: normal filesystems (and lustre): d_inode() annotations
    VFS: security/: d_inode() annotations
    VFS: security/: d_backing_inode() annotations
    VFS: net/: d_inode() annotations
    VFS: net/unix: d_backing_inode() annotations
    VFS: kernel/: d_inode() annotations
    VFS: audit: d_backing_inode() annotations
    VFS: Fix up some ->d_inode accesses in the chelsio driver
    VFS: Cachefiles should perform fs modifications on the top layer only
    VFS: AF_UNIX sockets should call mknod on the top layer only

    Linus Torvalds
     

17 Apr, 2015

1 commit

  • Let's show locks which are associated with a file descriptor in
    its fdinfo file.

    Currently we don't have a reliable way to determine who holds a lock. We
    can find some information in /proc/locks, but PID which is reported there
    can be wrong. For example, a process takes a lock, then forks a child and
    dies. In this case /proc/locks contains the parent pid, which can be
    reused by another process.

    $ cat /proc/locks
    ...
    6: FLOCK ADVISORY WRITE 324 00:13:13431 0 EOF
    ...

    $ ps -C rpcbind
    PID TTY TIME CMD
    332 ? 00:00:00 rpcbind

    $ cat /proc/332/fdinfo/4
    pos: 0
    flags: 0100000
    mnt_id: 22
    lock: 1: FLOCK ADVISORY WRITE 324 00:13:13431 0 EOF

    $ ls -l /proc/332/fd/4
    lr-x------ 1 root root 64 Mar 5 14:43 /proc/332/fd/4 -> /run/rpcbind.lock

    $ ls -l /proc/324/fd/
    total 0
    lrwx------ 1 root root 64 Feb 27 14:50 0 -> /dev/pts/0
    lrwx------ 1 root root 64 Feb 27 14:50 1 -> /dev/pts/0
    lrwx------ 1 root root 64 Feb 27 14:49 2 -> /dev/pts/0

    You can see that the process with the 324 pid doesn't hold the lock.

    This information is required for proper dumping and restoring file
    locks.

    Signed-off-by: Andrey Vagin
    Cc: Jonathan Corbet
    Cc: Alexander Viro
    Acked-by: Jeff Layton
    Acked-by: "J. Bruce Fields"
    Acked-by: Cyrill Gorcunov
    Cc: Pavel Emelyanov
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Vagin
     

16 Apr, 2015

1 commit


06 Nov, 2014

1 commit

  • seq_printf functions shouldn't really check the return value.
    Checking seq_has_overflowed() occasionally is used instead.

    Update vfs documentation.

    Link: http://lkml.kernel.org/p/e37e6e7b76acbdcc3bb4ab2a57c8f8ca1ae11b9a.1412031505.git.joe@perches.com

    Cc: David S. Miller
    Cc: Al Viro
    Signed-off-by: Joe Perches
    [ did a few clean ups ]
    Signed-off-by: Steven Rostedt

    Joe Perches
     

09 Oct, 2014

1 commit

  • Now that d_invalidate always succeeds it is not longer necessary or
    desirable to hard code d_drop calls into filesystem specific
    d_revalidate implementations.

    Remove the unnecessary d_drop calls and rely on d_invalidate
    to drop the dentries. Using d_invalidate ensures that paths
    to mount points will not be dropped.

    Reviewed-by: Miklos Szeredi
    Signed-off-by: "Eric W. Biederman"
    Signed-off-by: Al Viro

    Eric W. Biederman
     

09 Aug, 2014

1 commit

  • * remove proc_create(NULL, ...) check, let it oops

    * warn about proc_create("", ...) and proc_create("very very long name", ...)
    proc code keeps length as u8, no 256+ name length possible

    * warn about proc_create("123", ...)
    /proc/$PID and /proc/misc namespaces are separate things,
    but dumb module might create funky a-la $PID entry.

    * remove post mortem strchr('/') check
    Triggering it implies either strchr() is buggy or memory corruption.
    It should be VFS check anyway.

    In reality, none of these checks will ever trigger,
    it is preparation for the next patch.

    Based on patch from Al Viro.

    Signed-off-by: Alexey Dobriyan
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

08 Apr, 2014

1 commit

  • Currently we don't have a way how to determing from which mount point
    file has been opened. This information is required for proper dumping
    and restoring file descriptos due to presence of mount namespaces. It's
    possible, that two file descriptors are opened using the same paths, but
    one fd references mount point from one namespace while the other fd --
    from other namespace.

    $ ls -l /proc/1/fd/1
    lrwx------ 1 root root 64 Mar 19 23:54 /proc/1/fd/1 -> /dev/null

    $ cat /proc/1/fdinfo/1
    pos: 0
    flags: 0100002
    mnt_id: 16

    $ cat /proc/1/mountinfo | grep ^16
    16 32 0:4 / /dev rw,nosuid shared:2 - devtmpfs devtmpfs rw,size=1013356k,nr_inodes=253339,mode=755

    Signed-off-by: Andrey Vagin
    Acked-by: Pavel Emelyanov
    Acked-by: Cyrill Gorcunov
    Cc: Rob Landley
    Cc: Al Viro
    Cc: Oleg Nesterov
    Cc: "Eric W. Biederman"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrey Vagin
     

12 Sep, 2013

1 commit

  • proc_fd_permission() says "process can still access /proc/self/fd after it
    has executed a setuid()", but the "task_pid() = proc_pid() check only
    helps if the task is group leader, /proc/self points to
    /proc/.

    Change this check to use task_tgid() so that the whole thread group can
    access its /proc/self/fd or /proc//fd.

    Notes:
    - CLONE_THREAD does not require CLONE_FILES so task->files
    can differ, but I don't think this can lead to any security
    problem. And this matches same_thread_group() in
    __ptrace_may_access().

    - /proc/self should probably point to /proc/, but
    it is too late to change the rules. Perhaps it makes sense
    to add /proc/thread though.

    Test-case:

    void *tfunc(void *arg)
    {
    assert(opendir("/proc/self/fd"));
    return NULL;
    }

    int main(void)
    {
    pthread_t t;
    pthread_create(&t, NULL, tfunc, NULL);
    pthread_join(t, NULL);
    return 0;
    }

    fails if, say, this executable is not readable and suid_dumpable = 0.

    Signed-off-by: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     

25 Aug, 2013

1 commit


29 Jun, 2013

2 commits


18 Dec, 2012

1 commit

  • This patch brings ability to print out auxiliary data associated with
    file in procfs interface /proc/pid/fdinfo/fd.

    In particular further patches make eventfd, evenpoll, signalfd and
    fsnotify to print additional information complete enough to restore
    these objects after checkpoint.

    To simplify the code we add show_fdinfo callback inside struct
    file_operations (as Al and Pavel are proposing).

    Signed-off-by: Cyrill Gorcunov
    Acked-by: Pavel Emelyanov
    Cc: Oleg Nesterov
    Cc: Andrey Vagin
    Cc: Al Viro
    Cc: Alexey Dobriyan
    Cc: James Bottomley
    Cc: "Aneesh Kumar K.V"
    Cc: Alexey Dobriyan
    Cc: Matthew Helsley
    Cc: "J. Bruce Fields"
    Cc: "Aneesh Kumar K.V"
    Cc: Tvrtko Ursulin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Cyrill Gorcunov
     

27 Sep, 2012

3 commits