13 Mar, 2014

1 commit

  • 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"
    Cc: linux-fsdevel@vger.kernel.org
    Cc: Christoph Hellwig
    Cc: Artem Bityutskiy
    Cc: Adrian Hunter
    Cc: Evgeniy Dushistov
    Cc: Jan Kara
    Cc: OGAWA Hirofumi
    Cc: Anders Larsen
    Cc: Phillip Lougher
    Cc: Kees Cook
    Cc: Mikulas Patocka
    Cc: Petr Vandrovec
    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

    Theodore Ts'o
     

13 Nov, 2013

1 commit

  • When devpts is unmounted, there may be a no-longer-used IDR tree hanging
    off the superblock we are about to kill. This needs to be cleaned up
    before destroying the SB.

    The leak is usually not a big deal because unmounting devpts is typically
    done when shutting down the whole machine. However, shutting down an LXC
    container instead of a physical machine exposes the problem (the garbage
    is detectable with kmemleak).

    Signed-off-by: Ilija Hadzic
    Cc: Sukadev Bhattiprolu
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ilija Hadzic
     

27 Jan, 2013

1 commit

  • - The context in which devpts is mounted has no effect on the creation
    of ptys as the /dev/ptmx interface has been used by unprivileged
    users for many years.

    - Only support unprivileged mounts in combination with the newinstance
    option to ensure that mounting of /dev/pts in a user namespace will
    not allow the options of an existing mount of devpts to be modified.

    - Create /dev/pts/ptmx as the root user in the user namespace that
    mounts devpts so that it's permissions to be changed.

    Acked-by: Serge Hallyn
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

23 Oct, 2012

4 commits

  • Add kernel-doc texts for some devpts functions, i.e. document them.

    Signed-off-by: Jiri Slaby
    Acked-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     
  • The goal is to stop setting and using tty->driver_data in devpts code.
    It should be used solely by the driver's code, pty in this case.

    Now driver_data are managed only in the pty driver. devpts_pty_new is
    switched to accept what we used to dig out of tty_struct, i.e. device
    node number and index.

    This also removes a note about driver_data being set outside of the
    driver.

    Signed-off-by: Jiri Slaby
    Acked-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     
  • The goal is to stop setting and using tty->driver_data in devpts code.
    It should be used solely by the driver's code, pty in this case.

    For the cleanup of layering, we will need the inode created in
    devpts_pty_new to be stored into slave's driver_data. So we convert
    devpts_pty_new to return the inode or an ERR_PTR-encoded error in case
    of failure.

    The move of 'inode = new_inode(sb);' from declarators to the code is
    only cosmetical, but it makes the code easier to read.

    Signed-off-by: Jiri Slaby
    Acked-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     
  • The goal is to stop setting and using tty->driver_data in devpts code.
    It should be used solely by the driver's code, pty in this case.

    First, here we remove TTY from devpts_get_tty and rename it to
    devpts_get_priv. Note we do not remove type safety, we just shift the
    [implicit] (void *) cast one layer up.

    index was unused in devpts_get_tty, so remove that from the prototype
    too.

    Signed-off-by: Jiri Slaby
    Acked-by: Alan Cox
    Signed-off-by: Greg Kroah-Hartman

    Jiri Slaby
     

14 Jul, 2012

1 commit

  • Pass mount flags to sget() so that it can use them in initialising a new
    superblock before the set function is called. They could also be passed to the
    compare function.

    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    David Howells
     

16 May, 2012

1 commit


22 Mar, 2012

1 commit

  • Pull vfs pile 1 from Al Viro:
    "This is _not_ all; in particular, Miklos' and Jan's stuff is not there
    yet."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (64 commits)
    ext4: initialization of ext4_li_mtx needs to be done earlier
    debugfs-related mode_t whack-a-mole
    hfsplus: add an ioctl to bless files
    hfsplus: change finder_info to u32
    hfsplus: initialise userflags
    qnx4: new helper - try_extent()
    qnx4: get rid of qnx4_bread/qnx4_getblk
    take removal of PF_FORKNOEXEC to flush_old_exec()
    trim includes in inode.c
    um: uml_dup_mmap() relies on ->mmap_sem being held, but activate_mm() doesn't hold it
    um: embed ->stub_pages[] into mmu_context
    gadgetfs: list_for_each_safe() misuse
    ocfs2: fix leaks on failure exits in module_init
    ecryptfs: make register_filesystem() the last potential failure exit
    ntfs: forgets to unregister sysctls on register_filesystem() failure
    logfs: missing cleanup on register_filesystem() failure
    jfs: mising cleanup on register_filesystem() failure
    make configfs_pin_fs() return root dentry on success
    configfs: configfs_create_dir() has parent dentry in dentry->d_parent
    configfs: sanitize configfs_create()
    ...

    Linus Torvalds
     

21 Mar, 2012

1 commit


25 Jan, 2012

2 commits

  • 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: Konstantin Khlebnikov
    Signed-off-by: Greg Kroah-Hartman

    Konstantin Khlebnikov
     
  • Let's move this stuff to the better place, where we can account pty right in
    tty-indexes managing code.

    Signed-off-by: Konstantin Khlebnikov
    Signed-off-by: Greg Kroah-Hartman

    Konstantin Khlebnikov
     

09 Jan, 2012

1 commit

  • devpts_kill_sb() is called even if devpts_fill_super() fails;
    we should not do that kfree() in the latter, especially not
    with ->s_fs_info left pointing to freed object. Double kfree()
    is a Bad Thing(tm)...

    Signed-off-by: Al Viro

    Al Viro
     

07 Jan, 2012

1 commit


02 Nov, 2011

2 commits


23 Mar, 2011

1 commit


21 Mar, 2011

1 commit


29 Oct, 2010

1 commit


22 May, 2010

1 commit


30 Mar, 2010

1 commit

  • …it 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: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

12 Dec, 2009

1 commit

  • 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 527b3e4773628b30d03323a2cb5fb0d84441990f
    Author: Sukadev Bhattiprolu
    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
    #include
    #include
    #include
    #include
    #include
    #include

    #include

    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: Grzegorz Nosek
    Signed-off-by: Sukadev Bhattiprolu
    Tested-by: Serge Hallyn
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Sukadev Bhattiprolu
     

23 Sep, 2009

1 commit

  • Move various magic-number definitions into magic.h.

    Signed-off-by: Nick Black
    Acked-by: Pekka Enberg
    Cc: Al Viro
    Cc: "David S. Miller"
    Cc: Casey Schaufler
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nick Black
     

24 Jun, 2009

1 commit

  • These days, the devpts filesystem is closely integrated with the pty
    memory management, and cannot be built as a module, even less removed
    from the kernel. Accordingly, remove all module-related stuff from
    this filesystem.

    [ v2: only remove code that's actually dead ]

    Signed-off-by: H. Peter Anvin
    Signed-off-by: Al Viro

    H. Peter Anvin
     

11 Jun, 2009

1 commit


15 May, 2009

1 commit

  • devpts_get_sb() calls memset(0) to clear mount options and calls
    parse_mount_options() if user specified any mount options.

    The memset(0) is bogus since the 'mode' and 'ptmxmode' options are
    non-zero by default. parse_mount_options() restores options to default
    anyway and can properly deal with NULL mount options.

    So in devpts_get_sb() remove memset(0) and call parse_mount_options() even
    for NULL mount options.

    Bug reported by Eric Paris: http://lkml.org/lkml/2009/5/7/448.

    Signed-off-by: Sukadev Bhattiprolu
    Tested-by: Marc Dionne
    Reported-by: Eric Paris
    Cc: Christoph Hellwig
    Cc: Alan Cox
    Acked-by: Serge Hallyn
    Cc: Al Viro
    Cc: "Rafael J. Wysocki"
    Reviewed-by: "H. Peter Anvin"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu
     

09 May, 2009

1 commit


28 Mar, 2009

7 commits

  • new_pts_mount() (including the get_sb_nodev()), shares a lot of code
    with init_pts_mount(). The only difference between them is the 'test-super'
    function passed into sget().

    Move all common code into devpts_get_sb() and remove the new_pts_mount() and
    init_pts_mount() functions,

    Changelog[v3]:
    [Serge Hallyn]: Remove unnecessary printk()s
    Changelog[v2]:
    (Christoph Hellwig): Merge code in 'do_pts_mount()' into devpts_get_sb()

    Signed-off-by: Sukadev Bhattiprolu
    Acked-by: Serge Hallyn
    Tested-by: Serge Hallyn
    Signed-off-by: Al Viro

    Sukadev Bhattiprolu
     
  • With mknod_ptmx() moved to devpts_get_sb(), init_pts_mount() becomes
    a wrapper around get_init_pts_sb(). Remove get_init_pts_sb() and
    fold code into init_pts_mount().

    Signed-off-by: Sukadev Bhattiprolu
    Acked-by: Serge Hallyn
    Signed-off-by: Al Viro

    Sukadev Bhattiprolu
     
  • We create 'ptmx' node in both single-instance and multiple-instance
    mounts. So devpts_get_sb() can call mknod_ptmx() once rather than
    have both modes calling mknod_ptmx() separately.

    Signed-off-by: Sukadev Bhattiprolu
    Acked-by: Serge Hallyn
    Signed-off-by: Al Viro

    Sukadev Bhattiprolu
     
  • Since all the mount option parsing is done in devpts, we could do it
    just once and pass it around in devpts functions and eventually store
    it in the super block.

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Al Viro

    Sukadev Bhattiprolu
     
  • On remount, devpts fs only needs to parse the mount options. Users cannot
    directly create/dirty files in /dev/pts so the MS_RDONLY flag and
    shrinking the dcache does not really apply to devpts.

    So effectively on remount, devpts only parses the mount options and updates
    these options in its super block. As such, we could replace do_remount_sb()
    call with a direct parse_mount_options().

    Doing so enables subsequent patches to avoid parsing the mount options twice
    and simplify the code.

    Signed-off-by: Sukadev Bhattiprolu
    Acked-by: Serge Hallyn
    Signed-off-by: Al Viro

    Sukadev Bhattiprolu
     
  • simple_set_mnt() is defined as returning 'int' but always returns 0.
    Callers assume simple_set_mnt() never fails and don't properly cleanup if
    it were to _ever_ fail. For instance, get_sb_single() and get_sb_nodev()
    should:

    up_write(sb->s_unmount);
    deactivate_super(sb);

    if simple_set_mnt() fails.

    Since simple_set_mnt() never fails, would be cleaner if it did not
    return anything.

    [akpm@linux-foundation.org: fix build]
    Signed-off-by: Sukadev Bhattiprolu
    Acked-by: Serge Hallyn
    Cc: Al Viro
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Al Viro

    Sukadev Bhattiprolu
     
  • We should drop the ->s_umount mutex if an error occurs after the
    sget()/grab_super() call. This was introduced when adding support
    for multiple instances of devpts and noticed during a code review/reorg.

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Al Viro

    Sukadev Bhattiprolu
     

11 Mar, 2009

1 commit


06 Jan, 2009

1 commit


03 Jan, 2009

3 commits