11 Oct, 2016

1 commit

  • Pull more vfs updates from Al Viro:
    ">rename2() work from Miklos + current_time() from Deepa"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs: Replace current_fs_time() with current_time()
    fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps
    fs: Replace CURRENT_TIME with current_time() for inode timestamps
    fs: proc: Delete inode time initializations in proc_alloc_inode()
    vfs: Add current_time() api
    vfs: add note about i_op->rename changes to porting
    fs: rename "rename2" i_op to "rename"
    vfs: remove unused i_op->rename
    fs: make remaining filesystems use .rename2
    libfs: support RENAME_NOREPLACE in simple_rename()
    fs: support RENAME_NOREPLACE for local filesystems
    ncpfs: fix unused variable warning

    Linus Torvalds
     

28 Sep, 2016

1 commit

  • CURRENT_TIME macro is not appropriate for filesystems as it
    doesn't use the right granularity for filesystem timestamps.
    Use current_time() instead.

    CURRENT_TIME is also not y2038 safe.

    This is also in preparation for the patch that transitions
    vfs timestamps to use 64 bit time and hence make them
    y2038 safe. As part of the effort current_time() will be
    extended to do range checks. Hence, it is necessary for all
    file system timestamps to use current_time(). Also,
    current_time() will be transitioned along with vfs to be
    y2038 safe.

    Note that whenever a single call to current_time() is used
    to change timestamps in different inodes, it is because they
    share the same time granularity.

    Signed-off-by: Deepa Dinamani
    Reviewed-by: Arnd Bergmann
    Acked-by: Felipe Balbi
    Acked-by: Steven Whitehouse
    Acked-by: Ryusuke Konishi
    Acked-by: David Sterba
    Signed-off-by: Al Viro

    Deepa Dinamani
     

23 Sep, 2016

6 commits


04 Sep, 2016

1 commit

  • In commit 8ead9dd54716 ("devpts: more pty driver interface cleanups") I
    made devpts_get_priv() just return the dentry->fs_data directly. And
    because I thought it wouldn't happen, I added a warning if you ever saw
    a pts node that wasn't on devpts.

    And no, that warning never triggered under any actual real use, but you
    can trigger it by creating nonsensical pts nodes by hand.

    So just revert the warning, and make devpts_get_priv() return NULL for
    that case like it used to.

    Reported-by: Dmitry Vyukov
    Cc: stable@vger.kernel.org # 4.6+
    Cc: Eric W Biederman"
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

24 Jun, 2016

1 commit


06 Jun, 2016

1 commit

  • The /dev/ptmx device node is changed to lookup the directory entry "pts"
    in the same directory as the /dev/ptmx device node was opened in. If
    there is a "pts" entry and that entry is a devpts filesystem /dev/ptmx
    uses that filesystem. Otherwise the open of /dev/ptmx fails.

    The DEVPTS_MULTIPLE_INSTANCES configuration option is removed, so that
    userspace can now safely depend on each mount of devpts creating a new
    instance of the filesystem.

    Each mount of devpts is now a separate and equal filesystem.

    Reserved ttys are now available to all instances of devpts where the
    mounter is in the initial mount namespace.

    A new vfs helper path_pts is introduced that finds a directory entry
    named "pts" in the directory of the passed in path, and changes the
    passed in path to point to it. The helper path_pts uses a function
    path_parent_directory that was factored out of follow_dotdot.

    In the implementation of devpts:
    - devpts_mnt is killed as it is no longer meaningful if all mounts of
    devpts are equal.
    - pts_sb_from_inode is replaced by just inode->i_sb as all cached
    inodes in the tty layer are now from the devpts filesystem.
    - devpts_add_ref is rolled into the new function devpts_ptmx. And the
    unnecessary inode hold is removed.
    - devpts_del_ref is renamed devpts_release and reduced to just a
    deacrivate_super.
    - The newinstance mount option continues to be accepted but is now
    ignored.

    In devpts_fs.h definitions for when !CONFIG_UNIX98_PTYS are removed as
    they are never used.

    Documentation/filesystems/devices.txt is updated to describe the current
    situation.

    This has been verified to work properly on openwrt-15.05, centos5,
    centos6, centos7, debian-6.0.2, debian-7.9, debian-8.2, ubuntu-14.04.3,
    ubuntu-15.10, fedora23, magia-5, mint-17.3, opensuse-42.1,
    slackware-14.1, gentoo-20151225 (13.0?), archlinux-2015-12-01. With the
    caveat that on centos6 and on slackware-14.1 that there wind up being
    two instances of the devpts filesystem mounted on /dev/pts, the lower
    copy does not end up getting used.

    Signed-off-by: "Eric W. Biederman"
    Cc: Greg KH
    Cc: Peter Hurley
    Cc: Peter Anvin
    Cc: Andy Lutomirski
    Cc: Al Viro
    Cc: Serge Hallyn
    Cc: Willy Tarreau
    Cc: Aurelien Jarno
    Cc: One Thousand Gnomes
    Cc: Jann Horn
    Cc: Jiri Slaby
    Cc: Florian Weimer
    Cc: Konstantin Khlebnikov
    Signed-off-by: Linus Torvalds

    Eric W. Biederman
     

27 Apr, 2016

1 commit

  • This is more prep-work for the upcoming pty changes. Still just code
    cleanup with no actual semantic changes.

    This removes a bunch pointless complexity by just having the slave pty
    side remember the dentry associated with the devpts slave rather than
    the inode. That allows us to remove all the "look up the dentry" code
    for when we want to remove it again.

    Together with moving the tty pointer from "inode->i_private" to
    "dentry->d_fsdata" and getting rid of pointless inode locking, this
    removes about 30 lines of code. Not only is the end result smaller,
    it's simpler and easier to understand.

    The old code, for example, depended on the d_find_alias() to not just
    find the dentry, but also to check that it is still hashed, which in
    turn validated the tty pointer in the inode.

    That is a _very_ roundabout way to say "invalidate the cached tty
    pointer when the dentry is removed".

    The new code just does

    dentry->d_fsdata = NULL;

    in devpts_pty_kill() instead, invalidating the tty pointer rather more
    directly and obviously. Don't do something complex and subtle when the
    obvious straightforward approach will do.

    The rest of the patch (ie apart from code deletion and the above tty
    pointer clearing) is just switching the calling convention to pass the
    dentry or file pointer around instead of the inode.

    Cc: Eric Biederman
    Cc: Peter Anvin
    Cc: Andy Lutomirski
    Cc: Al Viro
    Cc: Peter Hurley
    Cc: Serge Hallyn
    Cc: Willy Tarreau
    Cc: Aurelien Jarno
    Cc: Alan Cox
    Cc: Jann Horn
    Cc: Greg KH
    Cc: Jiri Slaby
    Cc: Florian Weimer
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

19 Apr, 2016

1 commit

  • This gets rid of the horrible notion of having that

    struct inode *ptmx_inode

    be the linchpin of the interface between the pty code and devpts.

    By de-emphasizing the ptmx inode, a lot of things actually get cleaner,
    and we will have a much saner way forward. In particular, this will
    allow us to associate with any particular devpts instance at open-time,
    and not be artificially tied to one particular ptmx inode.

    The patch itself is actually fairly straightforward, and apart from some
    locking and return path cleanups it's pretty mechanical:

    - the interfaces that devpts exposes all take "struct pts_fs_info *"
    instead of "struct inode *ptmx_inode" now.

    NOTE! The "struct pts_fs_info" thing is a completely opaque structure
    as far as the pty driver is concerned: it's still declared entirely
    internally to devpts. So the pty code can't actually access it in any
    way, just pass it as a "cookie" to the devpts code.

    - the "look up the pts fs info" is now a single clear operation, that
    also does the reference count increment on the pts superblock.

    So "devpts_add/del_ref()" is gone, and replaced by a "lookup and get
    ref" operation (devpts_get_ref(inode)), along with a "put ref" op
    (devpts_put_ref()).

    - the pty master "tty->driver_data" field now contains the pts_fs_info,
    not the ptmx inode.

    - because we don't care about the ptmx inode any more as some kind of
    base index, the ref counting can now drop the inode games - it just
    gets the ref on the superblock.

    - the pts_fs_info now has a back-pointer to the super_block. That's so
    that we can easily look up the information we actually need. Although
    quite often, the pts fs info was actually all we wanted, and not having
    to look it up based on some magical inode makes things more
    straightforward.

    In particular, now that "devpts_get_ref(inode)" operation should really
    be the *only* place we need to look up what devpts instance we're
    associated with, and we do it exactly once, at ptmx_open() time.

    The other side of this is that one ptmx node could now be associated
    with multiple different devpts instances - you could have a single
    /dev/ptmx node, and then have multiple mount namespaces with their own
    instances of devpts mounted on /dev/pts/. And that's all perfectly sane
    in a model where we just look up the pts instance at open time.

    This will eventually allow us to get rid of our odd single-vs-multiple
    pts instance model, but this patch in itself changes no semantics, only
    an internal binding model.

    Cc: Eric Biederman
    Cc: Peter Anvin
    Cc: Andy Lutomirski
    Cc: Al Viro
    Cc: Peter Hurley
    Cc: Serge Hallyn
    Cc: Willy Tarreau
    Cc: Aurelien Jarno
    Cc: Alan Cox
    Cc: Jann Horn
    Cc: Greg KH
    Cc: Jiri Slaby
    Cc: Florian Weimer
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

07 Feb, 2016

1 commit

  • Considering current pty code and multiple devpts instances, it's possible
    to umount a devpts file system while a program still has /dev/tty opened
    pointing to a previosuly closed pty pair in that instance. In the case all
    ptmx and pts/N files are closed, umount can be done. If the program closes
    /dev/tty after umount is done, devpts_kill_index will use now an invalid
    super_block, which was already destroyed in the umount operation after
    running ->kill_sb. This is another "use after free" type of issue, but now
    related to the allocated super_block instance.

    To avoid the problem (warning at ida_remove and potential crashes) for
    this specific case, I added two functions in devpts which grabs additional
    references to the super_block, which pty code now uses so it makes sure
    the super block structure is still valid until pty shutdown is done.
    I also moved the additional inode references to the same functions, which
    also covered similar case with inode being freed before /dev/tty final
    close/shutdown.

    Signed-off-by: Herton R. Krzesinski
    Cc: stable@vger.kernel.org # 2.6.29+
    Reviewed-by: Peter Hurley
    Signed-off-by: Greg Kroah-Hartman

    Herton R. Krzesinski
     

23 Jan, 2016

1 commit

  • parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
    inode_foo(inode) being mutex_foo(&inode->i_mutex).

    Please, use those for access to ->i_mutex; over the coming cycle
    ->i_mutex will become rwsem, with ->lookup() done with it held
    only shared.

    Signed-off-by: Al Viro

    Al Viro
     

01 Jul, 2015

1 commit

  • If devpts failed to initialize, it would store an ERR_PTR in the global
    devpts_mnt. A subsequent open of /dev/ptmx would call devpts_new_index,
    which would dereference devpts_mnt and crash.

    Avoid storing invalid values in devpts_mnt; leave it NULL instead. Make
    both devpts_new_index and devpts_pty_new fail gracefully with ENODEV in
    that case, which then becomes the return value to the userspace open call
    on /dev/ptmx.

    [akpm@linux-foundation.org: remove unneeded static]
    Signed-off-by: Josh Triplett
    Reported-by: Fengguang Wu
    Reviewed-by: Peter Hurley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Josh Triplett
     

16 Apr, 2015

1 commit


07 Jun, 2014

1 commit

  • Also convert spaces to tabs (checkpatch warnings) if (!dentry) KERN_NOTICE
    converted to pr_err (like if (!inode) error process)

    [akpm@linux-foundation.org: use KBUILD_MODNAME, per Joe]
    Signed-off-by: Fabian Frederick
    Cc: Joe Perches
    Cc: "Theodore Ts'o"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Fabian Frederick
     

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