1. 15 Apr, 2015 1 commit
  2. 06 Jun, 2014 1 commit
  3. 13 Mar, 2014 1 commit
    • Theodore Ts'o's avatar
      fs: push sync_filesystem() down to the file system's remount_fs() · 02b9984d
      Theodore Ts'o authored
      Previously, the no-op "mount -o mount /dev/xxx" operation when the
      file system is already mounted read-write causes an implied,
      unconditional syncfs().  This seems pretty stupid, and it's certainly
      documented or guaraunteed to do this, nor is it particularly useful,
      except in the case where the file system was mounted rw and is getting
      remounted read-only.
      
      However, it's possible that there might be some file systems that are
      actually depending on this behavior.  In most file systems, it's
      probably fine to only call sync_filesystem() when transitioning from
      read-write to read-only, and there are some file systems where this is
      not needed at all (for example, for a pseudo-filesystem or something
      like romfs).
      Signed-off-by: Theodore Ts'o's avatar"Theodore Ts'o" <tytso@mit.edu>
      Cc: linux-fsdevel@vger.kernel.org
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Artem Bityutskiy <dedekind1@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Evgeniy Dushistov <dushistov@mail.ru>
      Cc: Jan Kara <jack@suse.cz>
      Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Cc: Anders Larsen <al@alarsen.net>
      Cc: Phillip Lougher <phillip@squashfs.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
      Cc: Petr Vandrovec <petr@vandrovec.name>
      Cc: xfs@oss.sgi.com
      Cc: linux-btrfs@vger.kernel.org
      Cc: linux-cifs@vger.kernel.org
      Cc: samba-technical@lists.samba.org
      Cc: codalist@coda.cs.cmu.edu
      Cc: linux-ext4@vger.kernel.org
      Cc: linux-f2fs-devel@lists.sourceforge.net
      Cc: fuse-devel@lists.sourceforge.net
      Cc: cluster-devel@redhat.com
      Cc: linux-mtd@lists.infradead.org
      Cc: jfs-discussion@lists.sourceforge.net
      Cc: linux-nfs@vger.kernel.org
      Cc: linux-nilfs@vger.kernel.org
      Cc: linux-ntfs-dev@lists.sourceforge.net
      Cc: ocfs2-devel@oss.oracle.com
      Cc: reiserfs-devel@vger.kernel.org
      02b9984d
  4. 13 Nov, 2013 1 commit
  5. 07 Mar, 2013 1 commit
  6. 04 Mar, 2013 1 commit
    • Eric W. Biederman's avatar
      fs: Limit sys_mount to only request filesystem modules. · 7f78e035
      Eric W. Biederman authored
      Modify the request_module to prefix the file system type with "fs-"
      and add aliases to all of the filesystems that can be built as modules
      to match.
      
      A common practice is to build all of the kernel code and leave code
      that is not commonly needed as modules, with the result that many
      users are exposed to any bug anywhere in the kernel.
      
      Looking for filesystems with a fs- prefix limits the pool of possible
      modules that can be loaded by mount to just filesystems trivially
      making things safer with no real cost.
      
      Using aliases means user space can control the policy of which
      filesystem modules are auto-loaded by editing /etc/modprobe.d/*.conf
      with blacklist and alias directives.  Allowing simple, safe,
      well understood work-arounds to known problematic software.
      
      This also addresses a rare but unfortunate problem where the filesystem
      name is not the same as it's module name and module auto-loading
      would not work.  While writing this patch I saw a handful of such
      cases.  The most significant being autofs that lives in the module
      autofs4.
      
      This is relevant to user namespaces because we can reach the request
      module in get_fs_type() without having any special permissions, and
      people get uncomfortable when a user specified string (in this case
      the filesystem type) goes all of the way to request_module.
      
      After having looked at this issue I don't think there is any
      particular reason to perform any filtering or permission checks beyond
      making it clear in the module request that we want a filesystem
      module.  The common pattern in the kernel is to call request_module()
      without regards to the users permissions.  In general all a filesystem
      module does once loaded is call register_filesystem() and go to sleep.
      Which means there is not much attack surface exposed by loading a
      filesytem module unless the filesystem is mounted.  In a user
      namespace filesystems are not mounted unless .fs_flags = FS_USERNS_MOUNT,
      which most filesystems do not set today.
      Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Reported-by: default avatarKees Cook <keescook@google.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      7f78e035
  7. 27 Jan, 2013 1 commit
  8. 22 Oct, 2012 4 commits
  9. 14 Jul, 2012 1 commit
  10. 15 May, 2012 1 commit
  11. 21 Mar, 2012 1 commit
  12. 24 Jan, 2012 2 commits
    • Konstantin Khlebnikov's avatar
      tty: rework pty count limiting · e9aba515
      Konstantin Khlebnikov authored
      After adding devpts multiple-insrances sysctl kernel.pty.max limit pty count for
      each devpts instance independently, while kernel.pty.nr shows total pty count.
      
      This patch restores sysctl kernel.pty.max as global limit (4096 by default),
      adds pty reseve for main devpts (mounted without "newinstance" argument),
      and new sysctl to tune it: kernel.pty.reserve (1024 by default)
      
      Also it adds devpts mount option "max=%d" to limit pty count for each devpts
      instance independently. (by default NR_UNIX98_PTY_MAX == 2^20)
      
      Thus devpts instances in containers cannot eat up all available pty even if we didn't
      set any limits, while with "max" argument we can adjust limits more precisely.
      
      Plus, now open("/dev/ptmx") return -ENOSPC in case lack of pty indexes,
      this is more informative than -EIO.
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@openvz.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      e9aba515
    • Konstantin Khlebnikov's avatar
      tty: move pty count limiting into devpts · a4834c10
      Konstantin Khlebnikov authored
      Let's move this stuff to the better place, where we can account pty right in
      tty-indexes managing code.
      Signed-off-by: default avatarKonstantin Khlebnikov <khlebnikov@openvz.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      a4834c10
  13. 09 Jan, 2012 1 commit
  14. 07 Jan, 2012 1 commit
  15. 02 Nov, 2011 2 commits
  16. 23 Mar, 2011 1 commit
  17. 21 Mar, 2011 1 commit
  18. 29 Oct, 2010 1 commit
  19. 21 May, 2010 1 commit
  20. 30 Mar, 2010 1 commit
    • Tejun Heo's avatar
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo authored
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Guess-its-ok-by: default avatarChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  21. 11 Dec, 2009 1 commit
    • Sukadev Bhattiprolu's avatar
      devpts_get_tty() should validate inode · edfacdd6
      Sukadev Bhattiprolu authored
      devpts_get_tty() assumes that the inode passed in is associated with a valid
      pty.  But if the only reference to the pty is via a bind-mount, the inode
      passed to devpts_get_tty() while valid, would refer to a pty that no longer
      exists.
      
      With a lot of debug effort, Grzegorz Nosek developed a small program (see
      below) to reproduce a crash on recent kernels. This crash is a regression
      introduced by the commit:
      
      	commit 527b3e47
      	Author: Sukadev Bhattiprolu <sukadev@us.ibm.com>
      	Date:   Mon Oct 13 10:43:08 2008 +0100
      
      To fix, ensure that the dentry associated with the inode has not yet been
      deleted/unhashed by devpts_pty_kill().
      
      See also:
      https://lists.linux-foundation.org/pipermail/containers/2009-July/019273.html 
      
      tty-bug.c:
      
      #define _GNU_SOURCE
      #include <fcntl.h>
      #include <sched.h>
      #include <stdlib.h>
      #include <sys/mount.h>
      #include <sys/signal.h>
      #include <unistd.h>
      #include <stdio.h>
      
      #include <linux/fs.h>
      
      void dummy(int sig)
      {
      }
      
      static int child(void *unused)
      {
      	int fd;
      
      	signal(SIGINT, dummy); signal(SIGHUP, dummy);
      	pause(); /* cheesy synchronisation to wait for /dev/pts/0 to appear */
      
      	mount("/dev/pts/0", "/dev/console", NULL, MS_BIND, NULL);
      	sleep(2);
      
      	fd = open("/dev/console", O_RDWR);
      	dup(0); dup(0);
      	write(1, "Hello world!\n", sizeof("Hello world!\n")-1);
      	return 0;
      }
      
      int main(void)
      {
      	pid_t pid;
      	char *stack;
      
      	stack = malloc(16384);
      	pid = clone(child, stack+16384, CLONE_NEWNS|SIGCHLD, NULL);
      
      	open("/dev/ptmx", O_RDWR|O_NOCTTY|O_NONBLOCK);
      
      	unlockpt(fd); grantpt(fd);
      
      	sleep(2);
      	kill(pid, SIGHUP);
      	sleep(1);
      	return 0; /* exit before child opens /dev/console */
      }
      Reported-by: default avatarGrzegorz Nosek <root@localdomain.pl>
      Signed-off-by: default avatarSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Tested-by: default avatarSerge Hallyn <serue@us.ibm.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      edfacdd6
  22. 23 Sep, 2009 1 commit
  23. 24 Jun, 2009 1 commit
  24. 11 Jun, 2009 1 commit
  25. 15 May, 2009 1 commit
  26. 09 May, 2009 1 commit
  27. 27 Mar, 2009 7 commits
  28. 10 Mar, 2009 1 commit
  29. 05 Jan, 2009 1 commit