12 Oct, 2016

14 commits

  • cmd part of this struct is the same as an index of itself within
    _ioctls[]. In fact this cmd is unused, so we can drop this part.

    Link: http://lkml.kernel.org/r/20160831033414.9910.66697.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     
  • Having this in autofs_i.h gives illusion that uncommenting this enables
    pr_debug(), but it doesn't enable all the pr_debug() in autofs because
    inclusion order matters.

    XFS has the same DEBUG macro in its core header fs/xfs/xfs.h, however XFS
    seems to have a rule to include this prior to other XFS headers as well as
    kernel headers. This is not the case with autofs, and DEBUG could be
    enabled via Makefile, so autofs should just get rid of this comment to
    make the code less confusing. It's a comment, so there is literally no
    functional difference.

    Link: http://lkml.kernel.org/r/20160831033409.9910.77067.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     
  • All other warnings use "cmd(0x%08x)" and this is the only one with
    "cmd(%d)". (below comes from my userspace debug program, but not
    automount daemon)

    [ 1139.905676] autofs4:pid:1640:check_dev_ioctl_version: ioctl control interface version mismatch: kernel(1.0), user(0.0), cmd(-1072131215)

    Link: http://lkml.kernel.org/r/20160812024851.12352.75458.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     
  • No functional changes, based on the following justification.

    1. Make the code more consistent using the ioctl vector _ioctls[],
    rather than assigning NULL only for this ioctl command.
    2. Remove goto done; for better maintainability in the long run.
    3. The existing code is based on the fact that validate_dev_ioctl()
    sets ioctl version for any command, but AUTOFS_DEV_IOCTL_VERSION_CMD
    should explicitly set it regardless of the default behavior.

    Link: http://lkml.kernel.org/r/20160812024846.12352.9885.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • The count of miscellaneous device ioctls in fs/autofs4/autofs_i.h is wrong.

    The number of ioctls is the difference between AUTOFS_DEV_IOCTL_VERSION_CMD
    and AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD (14) not the difference between
    AUTOFS_IOC_COUNT and 11 (21).

    [kusumi.tomohiro@gmail.com: fix typo that made the count macro negative]
    Link: http://lkml.kernel.org/r/20160831033420.9910.16809.stgit@pluto.themaw.net
    Link: http://lkml.kernel.org/r/20160812024841.12352.11975.stgit@pluto.themaw.net
    Signed-off-by: Ian Kent
    Cc: Tomohiro Kusumi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • This isn't a return value, so change the message to indicate the status is
    the result of may_umount().

    (or locate pr_debug() after put_user() with the same message)

    Link: http://lkml.kernel.org/r/20160812024836.12352.74628.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     
  • Returning -ENOTTY here fails to free dynamically allocated param.

    Link: http://lkml.kernel.org/r/20160812024815.12352.69153.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     
  • These two were left from commit aa55ddf340c9 ("autofs4: remove unused
    ioctls") which removed unused ioctls.

    Link: http://lkml.kernel.org/r/20160812024810.12352.96377.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     
  • kfree dentry data allocated by autofs4_new_ino() with autofs4_free_ino()
    instead of raw kfree. (since we have the interface to free autofs_info*)

    This patch was modified to remove the need to set the dentry info field to
    NULL dew to a change in the previous patch.

    Link: http://lkml.kernel.org/r/20160812024805.12352.43650.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     
  • The inode allocation failure case in autofs4_dir_symlink() frees the
    autofs dentry info of the dentry without setting ->d_fsdata to NULL.

    That could lead to a double free so just get rid of the free and leave it
    to ->d_release().

    Link: http://lkml.kernel.org/r/20160812024759.12352.10653.stgit@pluto.themaw.net
    Signed-off-by: Ian Kent
    Cc: Tomohiro Kusumi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • It's invalid if the given mode is neither dir nor link, so warn on else
    case.

    Link: http://lkml.kernel.org/r/20160812024754.12352.8536.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     
  • Somewhere along the line the error handling gotos have become incorrect.

    Link: http://lkml.kernel.org/r/20160812024749.12352.15100.stgit@pluto.themaw.net
    Signed-off-by: Ian Kent
    Cc: Tomohiro Kusumi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • This patch does what the below comment says. It could be and it's
    considered better to do this first before various functions get called
    during initialization.

    /* Couldn't this be tested earlier? */

    Link: http://lkml.kernel.org/r/20160812024744.12352.43075.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     
  • autofs4_kill_sb() doesn't need to be declared as extern, and no other
    functions in .h are explicitly declared as extern.

    Link: http://lkml.kernel.org/r/20160812024739.12352.99354.stgit@pluto.themaw.net
    Signed-off-by: Tomohiro Kusumi
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomohiro Kusumi
     

11 Oct, 2016

2 commits

  • 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
     
  • Al Viro
     

07 Oct, 2016

1 commit

  • Pull namespace updates from Eric Biederman:
    "This set of changes is a number of smaller things that have been
    overlooked in other development cycles focused on more fundamental
    change. The devpts changes are small things that were a distraction
    until we managed to kill off DEVPTS_MULTPLE_INSTANCES. There is an
    trivial regression fix to autofs for the unprivileged mount changes
    that went in last cycle. A pair of ioctls has been added by Andrey
    Vagin making it is possible to discover the relationships between
    namespaces when referring to them through file descriptors.

    The big user visible change is starting to add simple resource limits
    to catch programs that misbehave. With namespaces in general and user
    namespaces in particular allowing users to use more kinds of
    resources, it has become important to have something to limit errant
    programs. Because the purpose of these limits is to catch errant
    programs the code needs to be inexpensive to use as it always on, and
    the default limits need to be high enough that well behaved programs
    on well behaved systems don't encounter them.

    To this end, after some review I have implemented per user per user
    namespace limits, and use them to limit the number of namespaces. The
    limits being per user mean that one user can not exhause the limits of
    another user. The limits being per user namespace allow contexts where
    the limit is 0 and security conscious folks can remove from their
    threat anlysis the code used to manage namespaces (as they have
    historically done as it root only). At the same time the limits being
    per user namespace allow other parts of the system to use namespaces.

    Namespaces are increasingly being used in application sand boxing
    scenarios so an all or nothing disable for the entire system for the
    security conscious folks makes increasing use of these sandboxes
    impossible.

    There is also added a limit on the maximum number of mounts present in
    a single mount namespace. It is nontrivial to guess what a reasonable
    system wide limit on the number of mount structure in the kernel would
    be, especially as it various based on how a system is using
    containers. A limit on the number of mounts in a mount namespace
    however is much easier to understand and set. In most cases in
    practice only about 1000 mounts are used. Given that some autofs
    scenarious have the potential to be 30,000 to 50,000 mounts I have set
    the default limit for the number of mounts at 100,000 which is well
    above every known set of users but low enough that the mount hash
    tables don't degrade unreaonsably.

    These limits are a start. I expect this estabilishes a pattern that
    other limits for resources that namespaces use will follow. There has
    been interest in making inotify event limits per user per user
    namespace as well as interest expressed in making details about what
    is going on in the kernel more visible"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (28 commits)
    autofs: Fix automounts by using current_real_cred()->uid
    mnt: Add a per mount namespace limit on the number of mounts
    netns: move {inc,dec}_net_namespaces into #ifdef
    nsfs: Simplify __ns_get_path
    tools/testing: add a test to check nsfs ioctl-s
    nsfs: add ioctl to get a parent namespace
    nsfs: add ioctl to get an owning user namespace for ns file descriptor
    kernel: add a helper to get an owning user namespace for a namespace
    devpts: Change the owner of /dev/pts/ptmx to the mounter of /dev/pts
    devpts: Remove sync_filesystems
    devpts: Make devpts_kill_sb safe if fsi is NULL
    devpts: Simplify devpts_mount by using mount_nodev
    devpts: Move the creation of /dev/pts/ptmx into fill_super
    devpts: Move parse_mount_options into fill_super
    userns: When the per user per user namespace limit is reached return ENOSPC
    userns; Document per user per user namespace limits.
    mntns: Add a limit on the number of mount namespaces.
    netns: Add a limit on the number of net namespaces
    cgroupns: Add a limit on the number of cgroup namespaces
    ipcns: Add a limit on the number of ipc namespaces
    ...

    Linus Torvalds
     

01 Oct, 2016

1 commit

  • Seth Forshee reports that in 4.8-rcN some automounts are failing
    because the requesting the automount changed.

    The relevant call path is:
    follow_automount()
    ->d_automount
    autofs4_d_automount
    autofs4_mount_wait
    autofs4_wait

    In autofs4_wait wq_uid and wq_gid are set to current_uid() and
    current_gid respectively. With follow_automount now overriding creds
    uid that we export to userspace changes and that breaks existing
    setups.

    To remove the regression set wq_uid and wq_gid from
    current_real_cred()->uid and current_real_cred()->gid respectively.
    This restores the current behavior as current->real_cred is identical
    to current->cred except when override creds are used.

    Cc: stable@vger.kernel.org
    Fixes: aeaa4a79ff6a ("fs: Call d_automount with the filesystems creds")
    Reported-by: Seth Forshee
    Tested-by: Seth Forshee
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

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
     

20 Sep, 2016

1 commit

  • Somewhere along the way the autofs expire operation has changed to hold
    a spin lock over expired dentry selection. The autofs indirect mount
    expired dentry selection is complicated and quite lengthy so it isn't
    appropriate to hold a spin lock over the operation.

    Commit 47be61845c77 ("fs/dcache.c: avoid soft-lockup in dput()") added a
    might_sleep() to dput() causing a WARN_ONCE() about this usage to be
    issued.

    But the spin lock doesn't need to be held over this check, the autofs
    dentry info. flags are enough to block walks into dentrys during the
    expire.

    I've left the direct mount expire as it is (for now) because it is much
    simpler and quicker than the indirect mount expire and adding spin lock
    release and re-aquires would do nothing more than add overhead.

    Fixes: 47be61845c77 ("fs/dcache.c: avoid soft-lockup in dput()")
    Link: http://lkml.kernel.org/r/20160912014017.1773.73060.stgit@pluto.themaw.net
    Signed-off-by: Ian Kent
    Reported-by: Takashi Iwai
    Tested-by: Takashi Iwai
    Cc: Takashi Iwai
    Cc: NeilBrown
    Cc: Al Viro
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     

06 Aug, 2016

1 commit

  • Pull qstr constification updates from Al Viro:
    "Fairly self-contained bunch - surprising lot of places passes struct
    qstr * as an argument when const struct qstr * would suffice; it
    complicates analysis for no good reason.

    I'd prefer to feed that separately from the assorted fixes (those are
    in #for-linus and with somewhat trickier topology)"

    * 'work.const-qstr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    qstr: constify instances in adfs
    qstr: constify instances in lustre
    qstr: constify instances in f2fs
    qstr: constify instances in ext2
    qstr: constify instances in vfat
    qstr: constify instances in procfs
    qstr: constify instances in fuse
    qstr constify instances in fs/dcache.c
    qstr: constify instances in nfs
    qstr: constify instances in ocfs2
    qstr: constify instances in autofs4
    qstr: constify instances in hfs
    qstr: constify instances in hfsplus
    qstr: constify instances in logfs
    qstr: constify dentry_init_security

    Linus Torvalds
     

29 Jul, 2016

1 commit

  • This changes the vfs dentry hashing to mix in the parent pointer at the
    _beginning_ of the hash, rather than at the end.

    That actually improves both the hash and the code generation, because we
    can move more of the computation to the "static" part of the dcache
    setup, and do less at lookup runtime.

    It turns out that a lot of other hash users also really wanted to mix in
    a base pointer as a 'salt' for the hash, and so the slightly extended
    interface ends up working well for other cases too.

    Users that want a string hash that is purely about the string pass in a
    'salt' pointer of NULL.

    * merge branch 'salted-string-hash':
    fs/dcache.c: Save one 32-bit multiply in dcache lookup
    vfs: make the string hashes salt the hash

    Linus Torvalds
     

21 Jul, 2016

1 commit


25 Jun, 2016

1 commit


12 Jun, 2016

1 commit

  • * make autofs4_expire_indirect() skip the dentries being in process of
    expiry
    * do *not* mess with list_move(); making sure that dentry with
    AUTOFS_INF_EXPIRING are not picked for expiry is enough.
    * do not remove NO_RCU when we set EXPIRING, don't bother with smp_mb()
    there. Clear it at the same time we clear EXPIRING. Makes a bunch of
    tests simpler.
    * rename NO_RCU to WANT_EXPIRE, which is what it really is.

    Signed-off-by: Al Viro

    Al Viro
     

11 Jun, 2016

1 commit

  • We always mixed in the parent pointer into the dentry name hash, but we
    did it late at lookup time. It turns out that we can simplify that
    lookup-time action by salting the hash with the parent pointer early
    instead of late.

    A few other users of our string hashes also wanted to mix in their own
    pointers into the hash, and those are updated to use the same mechanism.

    Hash users that don't have any particular initial salt can just use the
    NULL pointer as a no-salt.

    Cc: Vegard Nossum
    Cc: George Spelvin
    Cc: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

03 May, 2016

1 commit


20 Mar, 2016

1 commit

  • Pull vfs updates from Al Viro:

    - Preparations of parallel lookups (the remaining main obstacle is the
    need to move security_d_instantiate(); once that becomes safe, the
    rest will be a matter of rather short series local to fs/*.c

    - preadv2/pwritev2 series from Christoph

    - assorted fixes

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (32 commits)
    splice: handle zero nr_pages in splice_to_pipe()
    vfs: show_vfsstat: do not ignore errors from show_devname method
    dcache.c: new helper: __d_add()
    don't bother with __d_instantiate(dentry, NULL)
    untangle fsnotify_d_instantiate() a bit
    uninline d_add()
    replace d_add_unique() with saner primitive
    quota: use lookup_one_len_unlocked()
    cifs_get_root(): use lookup_one_len_unlocked()
    nfs_lookup: don't bother with d_instantiate(dentry, NULL)
    kill dentry_unhash()
    ceph_fill_trace(): don't bother with d_instantiate(dn, NULL)
    autofs4: don't bother with d_instantiate(dentry, NULL) in ->lookup()
    configfs: move d_rehash() into configfs_create() for regular files
    ceph: don't bother with d_rehash() in splice_dentry()
    namei: teach lookup_slow() to skip revalidate
    namei: massage lookup_slow() to be usable by lookup_one_len_unlocked()
    lookup_one_len_unlocked(): use lookup_dcache()
    namei: simplify invalidation logics in lookup_dcache()
    namei: change calling conventions for lookup_{fast,slow} and follow_managed()
    ...

    Linus Torvalds
     

16 Mar, 2016

9 commits

  • Use the standard pr_xxx() log macros directly for log prints instead of
    the AUTOFS_XXX() macros.

    Signed-off-by: Ian Kent
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Common kernel coding practice is to include the newline of log prints
    within the log text rather than hidden away in a macro.

    To avoid introducing inconsistencies as changes are made change the log
    macros to not include the newline.

    Signed-off-by: Ian Kent
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Use the pr_*() print in AUTOFS_*() macros instead of printks and include
    the module name in log message macros. Also use the AUTOFS_*() macros
    everywhere instead of raw printks.

    Signed-off-by: Ian Kent
    Cc: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Fix some white space format errors.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • The return from an ioctl if an invalid ioctl is passed in should be
    EINVAL not ENOSYS.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • The need for this is questionable but checkpatch.pl complains about the
    line length and it's a straightfoward change.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Refactor autofs4_get_set_timeout() to eliminate coding style error.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Try and make the coding style completely consistent throughtout the
    autofs module and inline with kernel coding style recommendations.

    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • This is required for CRIU (Checkpoint Restart In Userspace) to migrate a
    mount point when write end in user space is closed.

    Below is a brief description of the problem.

    To migrate a non-catatonic autofs mount point, one has to restore the
    control pipe between kernel and autofs master process.

    One of the autofs masters is systemd, which closes pipe write end after
    passing it to the kernel with mount call.

    To be able to restore the systemd control pipe one has to know which
    read pipe end in systemd corresponds to the write pipe end in the
    kernel. The pipe "fd" in mount options is not enough because it was
    closed and probably replaced by some other descriptor.

    Thus, some other attribute is required to be able to find the read pipe
    end. The best attribute to use to find the correct pipe end is inode
    number becuase it's unique for the whole system and can't be reused
    while the autofs mount exists.

    This attribute can also be used to recognize a situation where an autofs
    mount has no master (no process with specified "pgrp" or no file
    descriptor with "pipe_ino", specified in autofs mount options).

    Signed-off-by: Stanislav Kinsburskiy
    Signed-off-by: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Stanislav Kinsburskiy
     

14 Mar, 2016

1 commit


31 Dec, 2015

1 commit


09 Dec, 2015

1 commit

  • new method: ->get_link(); replacement of ->follow_link(). The differences
    are:
    * inode and dentry are passed separately
    * might be called both in RCU and non-RCU mode;
    the former is indicated by passing it a NULL dentry.
    * when called that way it isn't allowed to block
    and should return ERR_PTR(-ECHILD) if it needs to be called
    in non-RCU mode.

    It's a flagday change - the old method is gone, all in-tree instances
    converted. Conversion isn't hard; said that, so far very few instances
    do not immediately bail out when called in RCU mode. That'll change
    in the next commits.

    Signed-off-by: Al Viro

    Al Viro