11 Aug, 2010

1 commit


09 Aug, 2010

1 commit

  • Handling of autofs ioctl numbers does not need to be generic
    and can easily be done directly in autofs itself.

    This also pushes the BKL into autofs and autofs4 ioctl
    methods.

    Signed-off-by: Arnd Bergmann
    Acked-by: H. Peter Anvin
    Cc: Al Viro
    Cc: Ian Kent
    Cc: Autofs
    Cc: John Kacur
    Signed-off-by: Frederic Weisbecker

    Arnd Bergmann
     

28 May, 2010

1 commit

  • Use memdup_user when user data is immediately copied into the allocated
    region. Elimination of the variable ads, which is no longer useful.

    The semantic patch that makes this change is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @@
    expression from,to,size,flag;
    position p;
    identifier l1,l2;
    @@

    - to = \(kmalloc@p\|kzalloc@p\)(size,flag);
    + to = memdup_user(from,size);
    if (
    - to==NULL
    + IS_ERR(to)
    || ...) {

    }
    - if (copy_from_user(to, from, size) != 0) {
    -
    - }
    //

    Signed-off-by: Julia Lawall
    Cc: Ian Kent
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Julia Lawall
     

26 May, 2010

1 commit

  • This adds:
    alias: devname:
    to some common kernel modules, which will allow the on-demand loading
    of the kernel module when the device node is accessed.

    Ideally all these modules would be compiled-in, but distros seems too
    much in love with their modularization that we need to cover the common
    cases with this new facility. It will allow us to remove a bunch of pretty
    useless init scripts and modprobes from init scripts.

    The static device node aliases will be carried in the module itself. The
    program depmod will extract this information to a file in the module directory:
    $ cat /lib/modules/2.6.34-00650-g537b60d-dirty/modules.devname
    # Device nodes to trigger on-demand module loading.
    microcode cpu/microcode c10:184
    fuse fuse c10:229
    ppp_generic ppp c108:0
    tun net/tun c10:200
    dm_mod mapper/control c10:235

    Udev will pick up the depmod created file on startup and create all the
    static device nodes which the kernel modules specify, so that these modules
    get automatically loaded when the device node is accessed:
    $ /sbin/udevd --debug
    ...
    static_dev_create_from_modules: mknod '/dev/cpu/microcode' c10:184
    static_dev_create_from_modules: mknod '/dev/fuse' c10:229
    static_dev_create_from_modules: mknod '/dev/ppp' c108:0
    static_dev_create_from_modules: mknod '/dev/net/tun' c10:200
    static_dev_create_from_modules: mknod '/dev/mapper/control' c10:235
    udev_rules_apply_static_dev_perms: chmod '/dev/net/tun' 0666
    udev_rules_apply_static_dev_perms: chmod '/dev/fuse' 0666

    A few device nodes are switched to statically allocated numbers, to allow
    the static nodes to work. This might also useful for systems which still run
    a plain static /dev, which is completely unsafe to use with any dynamic minor
    numbers.

    Note:
    The devname aliases must be limited to the *common* and *single*instance*
    device nodes, like the misc devices, and never be used for conceptually limited
    systems like the loop devices, which should rather get fixed properly and get a
    control node for losetup to talk to, instead of creating a random number of
    device nodes in advance, regardless if they are ever used.

    This facility is to hide the mess distros are creating with too modualized
    kernels, and just to hide that these modules are not compiled-in, and not to
    paper-over broken concepts. Thanks! :)

    Cc: Greg Kroah-Hartman
    Cc: David S. Miller
    Cc: Miklos Szeredi
    Cc: Chris Mason
    Cc: Alasdair G Kergon
    Cc: Tigran Aivazian
    Cc: Ian Kent
    Signed-Off-By: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     

22 May, 2010

1 commit


11 May, 2010

1 commit

  • After commit 1f36f774b2 ("Switch !O_CREAT case to use of do_last()") in
    2.6.34-rc1 autofs direct mounts stopped working. This is caused by
    current->link_count being 0 when ->follow_link() is called from
    do_filp_open().

    I can't work out why this hasn't been seen before Als patch series.

    This patch removes the autofs dependence on current->link_count.

    Signed-off-by: Ian Kent
    Cc: Al Viro
    Signed-off-by: Linus Torvalds

    Ian Kent
     

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
     

04 Mar, 2010

3 commits


16 Dec, 2009

10 commits

  • We need to be able to cope with the directory mutex being held during
    ->d_revalidate() in some cases, but not all cases, and not necessarily by
    us. Because we need to release the mutex when we call back to the daemon
    to do perform a mount we must be sure that it is us who holds the mutex so
    we must redirect mount requests to ->lookup() if the mutex is held.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • In autofs4_lookup_expiring() a declaration within the list traversal loop
    uses a declaration that has the same name as the function parameter.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • In autofs4_lookup_active() a declaration within the list traversal loop
    uses a declaration that has the same name as the function parameter.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • We unhash the dentry (in a subsequent patch) in ->d_revalidate() in order
    to send mount requests to ->lookup(). But then we can not rely on
    d_unhased() to give reliable results because it may be called at any time
    by any code path. The d_unhashed() function is used by __simple_empty()
    in the path walking callbacks but autofs mount point dentrys should have
    no directories at all so a list_empty() on d_subdirs should be (and is)
    sufficient.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • The lookup functions for active and expiring dentrys use parameters that
    can be easily obtained on entry so we change the call to to take just the
    dentry. This makes the subsequent change, to send all lookups to
    ->lookup(), a bit cleaner.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Rename the variable unhashed to active in autofs4_lookup() to better
    reflect its usage.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Eliminate the use of the d_lock spin lock by using the autofs super block
    info spin lock. This reduces the number of spin locks we use by one and
    makes the code for the following patch (to redirect ->d_revalidate() to
    ->lookup()) a little simpler.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Define simple helper function for checking if we need to trigger a mount.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Define some simple helper functions for adding and deleting entries on the
    expiring dentry list.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • Define some simple helper functions for adding and deleting entries on the
    active (and unhashed) dentry list.

    Signed-off-by: Ian Kent
    Cc: Sage Weil
    Cc: Al Viro
    Cc: Andreas Dilger
    Cc: Christoph Hellwig
    Cc: Yehuda Saheh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     

01 Sep, 2009

1 commit


13 Jul, 2009

1 commit

  • * Remove smp_lock.h from files which don't need it (including some headers!)
    * Add smp_lock.h to files which do need it
    * Make smp_lock.h include conditional in hardirq.h
    It's needed only for one kernel_locked() usage which is under CONFIG_PREEMPT

    This will make hardirq.h inclusion cheaper for every PREEMPT=n config
    (which includes allmodconfig/allyesconfig, BTW)

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

12 Jun, 2009

3 commits


10 Jun, 2009

1 commit

  • The recent ->lookup() deadlock correction required the directory inode
    mutex to be dropped while waiting for expire completion. We were
    concerned about side effects from this change and one has been identified.

    I saw several error messages.

    They cause autofs to become quite confused and don't really point to the
    actual problem.

    Things like:

    handle_packet_missing_direct:1376: can't find map entry for (43,1827932)

    which is usually totally fatal (although in this case it wouldn't be
    except that I treat is as such because it normally is).

    do_mount_direct: direct trigger not valid or already mounted
    /test/nested/g3c/s1/ss1

    which is recoverable, however if this problem is at play it can cause
    autofs to become quite confused as to the dependencies in the mount tree
    because mount triggers end up mounted multiple times. It's hard to
    accurately check for this over mounting case and automount shouldn't need
    to if the kernel module is doing its job.

    There was one other message, similar in consequence of this last one but I
    can't locate a log example just now.

    When checking if a mount has already completed prior to adding a new mount
    request to the wait queue we check if the dentry is hashed and, if so, if
    it is a mount point. But, if a mount successfully completed while we
    slept on the wait queue mutex the dentry must exist for the mount to have
    completed so the test is not really needed.

    Mounts can also be done on top of a global root dentry, so for the above
    case, where a mount request completes and the wait queue entry has already
    been removed, the hashed test returning false can cause an incorrect
    callback to the daemon. Also, d_mountpoint() is not sufficient to check
    if a mount has completed for the multi-mount case when we don't have a
    real mount at the base of the tree.

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

    Ian Kent
     

03 May, 2009

1 commit


21 Apr, 2009

2 commits


01 Apr, 2009

2 commits

  • A deadlock can occur when user space uses a signal (autofs version 4 uses
    SIGCHLD for this) to effect expire completion.

    The order of events is:

    Expire process completes, but before being able to send SIGCHLD to it's parent
    ...

    Another process walks onto a different mount point and drops the directory
    inode semaphore prior to sending the request to the daemon as it must ...

    A third process does an lstat on on the expired mount point causing it to wait
    on expire completion (unfortunately) holding the directory semaphore.

    The mount request then arrives at the daemon which does an lstat and,
    deadlock.

    For some time I was concerned about releasing the directory semaphore around
    the expire wait in autofs4_lookup as well as for the mount call back. I
    finally realized that the last round of changes in this function made the
    expiring dentry and the lookup dentry separate and distinct so the check and
    possible wait can be done anywhere prior to the mount call back. This patch
    moves the check to just before the mount call back and inside the directory
    inode mutex release.

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

    Ian Kent
     
  • A significant portion of the autofs_dev_ioctl_expire() and
    autofs4_expire_multi() functions is duplicated code. This patch cleans that
    up.

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

    Ian Kent
     

28 Mar, 2009

1 commit


22 Jan, 2009

1 commit


07 Jan, 2009

4 commits

  • In function validate_dev_ioctl() we check that the string we've been sent
    is a valid path. The function that does this check assumes the string is
    NULL terminated but our NULL termination check isn't done until after this
    call. This patch changes the order of the check.

    Signed-off-by: Ian Kent
    Acked-by: Jeff Moyer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ian Kent
     
  • - the type assigned at mount when no type is given is changed
    from 0 to AUTOFS_TYPE_INDIRECT. This was done because 0 and
    AUTOFS_TYPE_INDIRECT were being treated implicitly as the same
    type.

    - previously, an offset mount had it's type set to
    AUTOFS_TYPE_DIRECT|AUTOFS_TYPE_OFFSET but the mount control
    re-implementation needs to be able distinguish all three types.
    So this was changed to make the type setting explicit.

    - a type AUTOFS_TYPE_ANY was added for use by the re-implementation
    when checking if a given path is a mountpoint. It's not really a
    type as we use this to ask if a given path is a mountpoint in the
    autofs_dev_ioctl_ismountpoint() function.

    - functions to set and test the autofs mount types have been added to
    improve readability and make the type usage explicit.

    - the mount type is used from user space for the mount control
    re-implementtion so, for consistency, all the definitions have
    been moved to the user space include file include/linux/auto_fs4.h.

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

    Ian Kent
     
  • A local definition of devid in autofs_dev_ioctl_ismountpoint() shadows
    the fuction wide definition.

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

    Ian Kent
     
  • The parameter usage in the device node ioctl code uses arg1 and arg2 as
    parameter names. This patch redefines the parameter names to reflect what
    they actually are in an effort to make the code more readable.

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

    Ian Kent
     

06 Jan, 2009

1 commit


14 Nov, 2008

2 commits

  • Conflicts:
    security/keys/internal.h
    security/keys/process_keys.c
    security/keys/request_key.c

    Fixed conflicts above by using the non 'tsk' versions.

    Signed-off-by: James Morris

    James Morris
     
  • Pass credentials through dentry_open() so that the COW creds patch can have
    SELinux's flush_unauthorized_files() pass the appropriate creds back to itself
    when it opens its null chardev.

    The security_dentry_open() call also now takes a creds pointer, as does the
    dentry_open hook in struct security_operations.

    Signed-off-by: David Howells
    Acked-by: James Morris
    Signed-off-by: James Morris

    David Howells