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

10 commits

  • Wrap access to task credentials so that they can be separated more easily from
    the task_struct during the introduction of COW creds.

    Change most current->(|e|s|fs)[ug]id to current_(|e|s|fs)[ug]id().

    Change some task->e?[ug]id to task_e?[ug]id(). In some places it makes more
    sense to use RCU directly rather than a convenient wrapper; these will be
    addressed by later patches.

    Signed-off-by: David Howells
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    David Howells
     
  • fs/devpts/inode.c:324: warning: 'compare_init_pts_sb' defined but not used

    Signed-off-by: Andrew Morton
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • Just nail the oddments now while this code is being touched

    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Alan Cox
     
  • To support containers, allow multiple instances of devpts filesystem, such
    that indices of ptys allocated in one instance are independent of ptys
    allocated in other instances of devpts.

    But to preserve backward compatibility, enable this support for multiple
    instances only if:

    - CONFIG_DEVPTS_MULTIPLE_INSTANCES is set to Y, and
    - '-o newinstance' mount option is specified while mounting devpts

    To use multi-instance mount, a container startup script could:

    $ ns_exec -cm /bin/bash
    $ umount /dev/pts
    $ mount -t devpts -o newinstance lxcpts /dev/pts
    $ mount -o bind /dev/pts/ptmx /dev/ptmx
    $ /usr/sbin/sshd -p 1234

    where 'ns_exec -cm /bin/bash' is calls clone() with CLONE_NEWNS flag and execs
    /bin/bash in the child process. A pty created by the sshd is not visible in
    the original mount of /dev/pts.

    USER-SPACE-IMPACT:
    - See Documentation/fs/devpts.txt (included in next patch) for user-
    space impact in multi-instance and mixed-mode operation.
    TODO:
    - Update mount(8), pts(4) man pages. Highlight impact of not
    redirecting /dev/ptmx to /dev/pts/ptmx after a multi-instance mount.

    Changelog[v6]:
    - [Dave Hansen] Use new get_init_pts_sb() interface
    - [Serge Hallyn] Don't bother displaying 'newinstance' in show_options
    - [Serge Hallyn] Use macros (PARSE_REMOUNT/PARSE_MOUNT) instead of 0/1.
    - [Serge Hallyn] Check error return from get_sb_single() (now
    get_init_pts_sb())
    - devpts_pty_kill(): don't dput error dentries

    Changelog[v5]:
    - Move get_sb_ref() definition to earlier patch
    - Move usage info to Documentation/filesystems/devpts.txt (next patch)
    - Make ptmx node even in init_pts_ns, now that default mode is 0000
    (defined in earlier patch, enabled here).
    - Cache ptmx dentry and use to update mode during remount
    (defined in earlier patch, enabled here).
    - Bugfix: explicitly ignore newinstance on remount (if newinstance was
    specified on remount of initial mount, it would be ignored but
    /proc/mounts would imply that the option was set)

    Changelog[v4]:

    - Update patch description to address H. Peter Anvin's comments
    - Consolidate multi-instance mode code under new config token,
    CONFIG_DEVPTS_MULTIPLE_INSTANCE.
    - Move usage-details from patch description to
    Documentation/fs/devpts.txt

    Changelog[v3]:
    - Rename new mount option to 'newinstance'
    - Create ptmx nodes only in 'newinstance' mounts
    - Bugfix: parse_mount_options() modifies @data but since we need to
    parse the @data twice (once in devpts_get_sb() and once during
    do_remount_sb()), parse a local copy of @data in devpts_get_sb().
    (restructured code in devpts_get_sb() to fix this)

    Changelog[v2]:
    - Support both single-mount and multiple-mount semantics and
    provide '-onewmnt' option to select the semantics.

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu
     
  • See comments in the function header for details. The new interface will
    be used in a follow-on patch.

    Changelog [v2]:
    [Dave Hansen] Replace get_sb_ref() in fs/super.c with get_init_pts_sb()
    and make the new interface private to devpts

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu
     
  • /dev/ptmx is closely tied to the devpts filesystem. An open of /dev/ptmx,
    allocates the next pty index and the associated device shows up in the
    devpts fs as /dev/pts/n.

    Wih multiple instancs of devpts filesystem, during an open of /dev/ptmx
    we would be unable to determine which instance of the devpts is being
    accessed.

    So we move the 'ptmx' node into /dev/pts and use the inode of the 'ptmx'
    node to identify the superblock and hence the devpts instance. This patch
    adds ability for the kernel to internally create the [ptmx, c, 5:2] device
    when mounting devpts filesystem. Since the ptmx node in devpts is new and
    may surprise some userspace scripts, the default permissions for the new
    node is 0000. These permissions can be changed either using chmod or by
    remounting with the new '-o ptmxmode=0666' mount option.

    Changelog[v5]:
    - [Serge Hallyn bugfix]: Letting new_inode() assign inode number to
    ptmx can collide with hand-assigning inode numbers to ptys. So,
    hand-assign specific inode number to ptmx node also.
    - [Serge Hallyn]: Maybe safer to grab root dentry mutex while creating
    ptmx node
    - [Bugfix with Serge Hallyn] Replace lookup_one_len() in mknod_ptmx()
    wih d_alloc_name() (lookup during ->get_sb() locks up system). To
    simplify patchset, fold the ptmx_dentry patch into this.

    Changelog[v4]:
    - Change default permissions of pts/ptmx node to 0000.
    - Move code for ptmxmode under #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES.

    Changelog[v3]:
    - Rename ptmx_mode to ptmxmode (for consistency with 'newinstance')

    Changelog[v2]:
    - [H. Peter Anvin] Remove mknod() system call support and create the
    ptmx node internally.

    Changelog[v1]:
    - Earlier version of this patch enabled creating /dev/pts/tty as
    well. As pointed out by Al Viro and H. Peter Anvin, that is not
    really necessary.

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu
     
  • Move code to parse mount options into a separate function so it can
    (later) be shared between mount and remount operations.

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu
     
  • With support for multiple mounts of devpts, the 'config' structure really
    represents per-mount options rather than config parameters. Rename 'config'
    structure to 'pts_mount_opts' and store it in the super-block.

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu
     
  • To enable multiple mounts of devpts, 'allocated_ptys' must be a per-mount
    variable rather than a global variable. Move 'allocated_ptys' into the
    super_block's s_fs_info.

    Changelog[v2]:
    Define and use DEVPTS_SB() wrapper.

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu
     
  • Remove the 'devpts_root' global variable and find the root dentry using
    the super_block. The super-block can be found from the device inode, using
    the new wrapper, pts_sb_from_inode().

    Changelog: This patch is based on an earlier patchset from Serge Hallyn
    and Matt Helsley.

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Alan Cox
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu