17 Oct, 2020

1 commit

  • The table of ioctl functions should be marked const in order to put them
    in read-only memory, and we should use array_index_nospec() to avoid
    speculation disclosing the contents of kernel memory to userspace.

    Signed-off-by: Matthew Wilcox (Oracle)
    Signed-off-by: Andrew Morton
    Acked-by: Ian Kent
    Link: https://lkml.kernel.org/r/20200818122203.GO17456@casper.infradead.org
    Signed-off-by: Linus Torvalds

    Matthew Wilcox
     

30 Sep, 2020

1 commit

  • autofs got broken in some configurations by commit 13c164b1a186
    ("autofs: switch to kernel_write") because there is now an extra LSM
    permission check done by security_file_permission() in rw_verify_area().

    autofs is one if the few places that really does want the much more
    limited __kernel_write(), because the write is an internal kernel one
    that shouldn't do any user permission checks (it also doesn't need the
    file_start_write/file_end_write logic, since it's just a pipe).

    There are a couple of other cases like that - accounting, core dumping,
    and splice - but autofs stands out because it can be built as a module.

    As a result, we need to export this internal __kernel_write() function
    again.

    We really don't want any other module to use this, but we don't have a
    "EXPORT_SYMBOL_FOR_AUTOFS_ONLY()". But we can mark it GPL-only to at
    least approximate that "internal use only" for licensing.

    While in this area, make autofs pass in NULL for the file position
    pointer, since it's always a pipe, and we now use a NULL file pointer
    for streaming file descriptors (see file_ppos() and commit 438ab720c675:
    "vfs: pass ppos=NULL to .read()/.write() of FMODE_STREAM files")

    This effectively reverts commits 9db977522449 ("fs: unexport
    __kernel_write") and 13c164b1a186 ("autofs: switch to kernel_write").

    Fixes: 13c164b1a186 ("autofs: switch to kernel_write")
    Reported-by: Ondrej Mosnacek
    Acked-by: Christoph Hellwig
    Acked-by: Acked-by: Ian Kent
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

15 Aug, 2020

1 commit


08 Jul, 2020

1 commit


14 Mar, 2020

1 commit


06 Dec, 2019

1 commit

  • Pull autofs updates from Al Viro:
    "autofs misuses checks for ->d_subdirs emptiness; the cursors are in
    the same lists, resulting in false negatives. It's not needed anyway,
    since autofs maintains counter in struct autofs_info, containing 0 for
    removed ones, 1 for live symlinks and 1 + number of children for live
    directories, which is precisely what we need for those checks.

    This series switches to use of that counter and untangles the crap
    around its uses (it needs not be atomic and there's a bunch of
    completely pointless "defensive" checks).

    This fell out of dcache_readdir work; the main point is to get rid of
    ->d_subdirs abuses in there. I've more followup cleanups, but I hadn't
    run those by Ian yet, so they can go next cycle"

    * 'next.autofs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    autofs: don't bother with atomics for ino->count
    autofs_dir_rmdir(): check ino->count for deciding whether it's empty...
    autofs: get rid of pointless checks around ->count handling
    autofs_clear_leaf_automount_flags(): use ino->count instead of ->d_subdirs

    Linus Torvalds
     

25 Oct, 2019

1 commit


18 Sep, 2019

4 commits


27 Jul, 2019

2 commits


25 Jul, 2019

1 commit

  • * new helper: positive_after(parent, child); parent->d_lock is
    held by caller, grabs and returns the first thing after child
    in the list of children that has simple_positive() true. NULL
    if nothing's found; NULL child == search the entire list.

    * get_next_positive_subdir() loses the redundant check for
    d_count and switches to use of that helper. BTW, dput(NULL) is
    a no-op for a good reason...

    * get_next_positive_dentry() switched to the same helper. Logics:
    look for positive child in prev; if not found, look for the
    positive child of prev's parent following prev, etc. That way
    we are guaranteed that we are only moving rootwards through the
    ancestors of prev, which is pinned and thus not going anywhere.
    Since ->d_parent on autofs never changes, the same goes for
    the entire chain of ancestors and we don't need overlapping
    ->d_lock on them. Which avoids the trylock loops, in addition
    to simplifying the logics in there...

    Signed-off-by: Al Viro

    Al Viro
     

24 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this file is part of the linux kernel and is made available under
    the terms of the gnu general public license version 2 or at your
    option any later version incorporated herein by reference

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 18 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Richard Fontana
    Reviewed-by: Allison Randal
    Reviewed-by: Armijn Hemel
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190520075211.321157221@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


10 Apr, 2019

1 commit


08 Mar, 2019

3 commits

  • autofs does not expect the pipe it is given to have O_NONBLOCK set -
    specifically if __kernel_write() in autofs_write() returns -EAGAIN, this
    is treated as a fatal error and the pipe is closed.

    For safety autofs should, therefore, clear the O_NONBLOCK flag.

    Releases of systemd prior to 8th February 2019 used
    pipe2(p, O_NONBLOCK|O_CLOEXEC)
    and thus (inadvertently) set this flag.

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

    NeilBrown
     
  • Fix checkpatch.sh WARNING about the use of seq_printf() to print simple
    strings in autofs_show_options(), use seq_puts() in this case.

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

    Ian Kent
     
  • Add an autofs file system mount option that can be used to provide a
    generic indicator to applications that the mount entry should be ignored
    when displaying mount information.

    In other OSes that provide autofs and that provide a mount list to user
    space based on the kernel mount list a no-op mount option ("ignore" is
    the one use on the most common OS) is allowed so that autofs file system
    users can optionally use it.

    The idea is that it be used by user space programs to exclude autofs
    mounts from consideration when reading the mounts list.

    Prior to the change to link /etc/mtab to /proc/self/mounts all I needed
    to do to achieve this was to use mount(2) and not update the mtab but
    now that no longer works.

    I know the symlinking happened a long time ago and I considered doing
    this then but, at the time I couldn't remember the commonly used option
    name and thought persuading the various utility maintainers would be too
    hard.

    But now I have a RHEL request to do this for compatibility for a widely
    used product so I want to go ahead with it and try and enlist the help
    of some utility package maintainers.

    Clearly, without the option nothing can be done so it's at least a
    start.

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

    Ian Kent
     

02 Feb, 2019

2 commits

  • In autofs_fill_super() on error of get inode/make root dentry the return
    should be ENOMEM as this is the only failure case of the called
    functions.

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

    Ian Kent
     
  • autofs_expire_run() calls dput(dentry) to drop the reference count of
    dentry. However, dentry is read via autofs_dentry_ino(dentry) after
    that. This may result in a use-free-bug. The patch drops the reference
    count of dentry only when it is never used.

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

    Pan Bian
     

05 Jan, 2019

4 commits

  • Commit 092a53452bb7 ("autofs: take more care to not update last_used on
    path walk") helped to (partially) resolve a problem where automounts
    were not expiring due to aggressive accesses from user space.

    This patch was later reverted because, for very large environments, it
    meant more mount requests from clients and when there are a lot of
    clients this caused a fairly significant increase in server load.

    But there is a need for both types of expire check, depending on use
    case, so add a mount option to allow for strict update of last use of
    autofs dentrys (which just means not updating the last use on path walk
    access).

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

    Ian Kent
     
  • Change the superblock info. catatonic setting to be part of a flags bit
    field.

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

    Ian Kent
     
  • The parse_options() function uses a long list of parameters, most of
    which are present in the super block info structure already.

    The mount parameters set in parse_options() options don't require
    cleanup so using the super block info struct directly is simpler.

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

    Ian Kent
     
  • Al Viro made some suggestions to improve the implementation of commit
    0633da48f0 ("fix autofs_sbi() does not check super block type").

    The check is unnecessary in all cases except for ioctl usage so placing
    the check in the super block accessor function adds a small overhead to
    the common case where it isn't needed.

    So it's sufficient to do this in the ioctl code only.

    Also the check in the ioctl code is needlessly complex.

    [akpm@linux-foundation.org: declare autofs_fs_type in .h, not .c]
    Link: http://lkml.kernel.org/r/154296970987.9889.1597442413573683096.stgit@pluto-themaw-net
    Signed-off-by: Ian Kent
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     

23 Aug, 2018

9 commits

  • Merge more updates from Andrew Morton:

    - the rest of MM

    - procfs updates

    - various misc things

    - more y2038 fixes

    - get_maintainer updates

    - lib/ updates

    - checkpatch updates

    - various epoll updates

    - autofs updates

    - hfsplus

    - some reiserfs work

    - fatfs updates

    - signal.c cleanups

    - ipc/ updates

    * emailed patches from Andrew Morton : (166 commits)
    ipc/util.c: update return value of ipc_getref from int to bool
    ipc/util.c: further variable name cleanups
    ipc: simplify ipc initialization
    ipc: get rid of ids->tables_initialized hack
    lib/rhashtable: guarantee initial hashtable allocation
    lib/rhashtable: simplify bucket_table_alloc()
    ipc: drop ipc_lock()
    ipc/util.c: correct comment in ipc_obtain_object_check
    ipc: rename ipcctl_pre_down_nolock()
    ipc/util.c: use ipc_rcu_putref() for failues in ipc_addid()
    ipc: reorganize initialization of kern_ipc_perm.seq
    ipc: compute kern_ipc_perm.id under the ipc lock
    init/Kconfig: remove EXPERT from CHECKPOINT_RESTORE
    fs/sysv/inode.c: use ktime_get_real_seconds() for superblock stamp
    adfs: use timespec64 for time conversion
    kernel/sysctl.c: fix typos in comments
    drivers/rapidio/devices/rio_mport_cdev.c: remove redundant pointer md
    fork: don't copy inconsistent signal handler state to child
    signal: make get_signal() return bool
    signal: make sigkill_pending() return bool
    ...

    Linus Torvalds
     
  • The userspace automount(8) daemon is meant to perform a forced expire when
    sent a SIGUSR2.

    But since the expiration is routed through the kernel and the kernel
    doesn't send an expire request if the mount is busy this hasn't worked at
    least since autofs version 5.

    Add an AUTOFS_EXP_FORCED flag to allow implemention of the feature and
    bump the protocol version so user space can check if it's implemented if
    needed.

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

    Ian Kent
     
  • Make the usage of the expire flags consistent by naming the expire flags
    the same as it is named in the version 5 miscelaneous ioctl parameters and
    only check the bit flags when needed.

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

    Ian Kent
     
  • autofs_expire_indirect() isn't used outside of fs/autofs/expire.c so make
    it static.

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

    Ian Kent
     
  • autofs_expire_direct() isn't used outside of fs/autofs/expire.c so make it
    static.

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

    Ian Kent
     
  • The expire flag AUTOFS_EXP_LEAVES is cleared before the second call to
    should_expire() in autofs_expire_indirect() but the parameter passed in
    the second call is incorrect.

    Fortunately AUTOFS_EXP_LEAVES expire flag has not been used for a long
    time but might be needed in the future so fix it rather than remove the
    expire leaves functionality.

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

    Ian Kent
     
  • The global variable "now" in fs/autofs/expire.c is used in an inconsistent
    way, sometimes using jiffies directly, and sometimes using the "now"
    variable, and setting it isn't done consistently either.

    But the autofs dentry info last_used field is only updated during path
    walks or during expire so jiffies can be used directly and the global
    variable "now" removed.

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

    Ian Kent
     
  • Depending on how it is configured the autofs user space daemon can leave
    in use mounts mounted at exit and re-connect to them at start up. But for
    this to work best the state of the autofs file system needs to be left
    intact over the restart.

    Also, at system shutdown, mounts in an autofs file system might be
    umounted exposing a mount point trigger for which subsequent access can
    lead to a hang. So recent versions of automount(8) now does its best to
    set autofs file system mounts catatonic at shutdown.

    When autofs file system mounts are catatonic it's currently possible to
    create and remove directories and symlinks which can be a problem at
    restart, as described above.

    So return EACCES in the directory, symlink and unlink methods if the
    autofs file system is catatonic.

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

    Ian Kent
     
  • autofs_sbi() does not check the superblock magic number to verify it has
    been given an autofs super block.

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

    Ian Kent
     

22 Aug, 2018

1 commit

  • …iederm/user-namespace

    Pull core signal handling updates from Eric Biederman:
    "It was observed that a periodic timer in combination with a
    sufficiently expensive fork could prevent fork from every completing.
    This contains the changes to remove the need for that restart.

    This set of changes is split into several parts:

    - The first part makes PIDTYPE_TGID a proper pid type instead
    something only for very special cases. The part starts using
    PIDTYPE_TGID enough so that in __send_signal where signals are
    actually delivered we know if the signal is being sent to a a group
    of processes or just a single process.

    - With that prep work out of the way the logic in fork is modified so
    that fork logically makes signals received while it is running
    appear to be received after the fork completes"

    * 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (22 commits)
    signal: Don't send signals to tasks that don't exist
    signal: Don't restart fork when signals come in.
    fork: Have new threads join on-going signal group stops
    fork: Skip setting TIF_SIGPENDING in ptrace_init_task
    signal: Add calculate_sigpending()
    fork: Unconditionally exit if a fatal signal is pending
    fork: Move and describe why the code examines PIDNS_ADDING
    signal: Push pid type down into complete_signal.
    signal: Push pid type down into __send_signal
    signal: Push pid type down into send_signal
    signal: Pass pid type into do_send_sig_info
    signal: Pass pid type into send_sigio_to_task & send_sigurg_to_task
    signal: Pass pid type into group_send_sig_info
    signal: Pass pid and pid type into send_sigqueue
    posix-timers: Noralize good_sigevent
    signal: Use PIDTYPE_TGID to clearly store where file signals will be sent
    pid: Implement PIDTYPE_TGID
    pids: Move the pgrp and session pid pointers from task_struct to signal_struct
    kvm: Don't open code task_pid in kvm_vcpu_ioctl
    pids: Compute task_tgid using signal->leader_pid
    ...

    Linus Torvalds
     

21 Jul, 2018

1 commit

  • To access these fields the code always has to go to group leader so
    going to signal struct is no loss and is actually a fundamental simplification.

    This saves a little bit of memory by only allocating the pid pointer array
    once instead of once for every thread, and even better this removes a
    few potential races caused by the fact that group_leader can be changed
    by de_thread, while signal_struct can not.

    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

15 Jul, 2018

1 commit

  • The autofs subsystem does not check that the "path" parameter is present
    for all cases where it is required when it is passed in via the "param"
    struct.

    In particular it isn't checked for the AUTOFS_DEV_IOCTL_OPENMOUNT_CMD
    ioctl command.

    To solve it, modify validate_dev_ioctl(function to check that a path has
    been provided for ioctl commands that require it.

    Link: http://lkml.kernel.org/r/153060031527.26631.18306637892746301555.stgit@pluto.themaw.net
    Signed-off-by: Tomas Bortoli
    Signed-off-by: Ian Kent
    Reported-by: syzbot+60c837b428dc84e83a93@syzkaller.appspotmail.com
    Cc: Dmitry Vyukov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tomas Bortoli
     

06 Jul, 2018

1 commit

  • It turns out that systemd has a bug: it wants to load the autofs module
    early because of some initialization ordering with udev, and it doesn't
    do that correctly. Everywhere else it does the proper "look up module
    name" that does the proper alias resolution, but in that early code, it
    just uses a hardcoded "autofs4" for the module name.

    The result of that is that as of commit a2225d931f75 ("autofs: remove
    left-over autofs4 stubs"), you get

    systemd[1]: Failed to insert module 'autofs4': No such file or directory

    in the system logs, and a lack of module loading. All this despite the
    fact that we had very clearly marked 'autofs4' as an alias for this
    module.

    What's so ridiculous about this is that literally everything else does
    the module alias handling correctly, including really old versions of
    systemd (that just used 'modprobe' to do this), and even all the other
    systemd module loading code.

    Only that special systemd early module load code is broken, hardcoding
    the module names for not just 'autofs4', but also "ipv6", "unix",
    "ip_tables" and "virtio_rng". Very annoying.

    Instead of creating an _additional_ separate compatibility 'autofs4'
    module, just rely on the fact that everybody else gets this right, and
    just call the module 'autofs4' for compatibility reasons, with 'autofs'
    as the alias name.

    That will allow the systemd people to fix their bugs, adding the proper
    alias handling, and maybe even fix the name of the module to be just
    "autofs" (so that they can _test_ the alias handling). And eventually,
    we can revert this silly compatibility hack.

    See also

    https://github.com/systemd/systemd/issues/9501
    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=902946

    for the systemd bug reports upstream and in the Debian bug tracker
    respectively.

    Fixes: a2225d931f75 ("autofs: remove left-over autofs4 stubs")
    Reported-by: Ben Hutchings
    Reported-by: Michael Biebl
    Cc: Ian Kent
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

13 Jun, 2018

1 commit