05 Dec, 2016

1 commit


12 Oct, 2016

4 commits

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

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
     

16 Mar, 2016

6 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
     
  • 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
     

16 Apr, 2015

1 commit


04 Jul, 2014

1 commit

  • On strict build environments we can see:

    fs/autofs4/inode.c: In function 'autofs4_fill_super':
    fs/autofs4/inode.c:312: error: 'pgrp' may be used uninitialized in this function
    make[2]: *** [fs/autofs4/inode.o] Error 1
    make[1]: *** [fs/autofs4] Error 2
    make: *** [fs] Error 2
    make: *** Waiting for unfinished jobs....

    This is due to the use of pgrp_set being used to indicate pgrp has has
    been set rather than initializing pgrp itself.

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

    Ian Kent
     

24 Jan, 2014

2 commits

  • While kzallocing sbi/ino fails, it should return -ENOMEM.

    And it should return the err value from autofs_prepare_pipe.

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

    Rui Xiang
     
  • Enable autofs4 to work in a "container". oz_pgrp is converted from
    pid_t to struct pid and this is stored at mount time based on the
    "pgrp=" option or if the option is missing then the current pgrp.

    The "pgrp=" option is interpreted in the PID namespace of the current
    process. This option is flawed in that it doesn't carry the namespace
    information, so it should be deprecated. AFAICS the autofs daemon
    always sends the current pgrp, which is the default anyway.

    The oz_pgrp is also set from the AUTOFS_DEV_IOCTL_SETPIPEFD_CMD ioctl.
    This ioctl sets oz_pgrp to the current pgrp. It is not allowed to
    change the pid namespace.

    oz_pgrp is used mainly to determine whether the process traversing the
    autofs mount tree is the autofs daemon itself or not. This function now
    compares the pid pointers instead of the pid_t values.

    One other use of oz_pgrp is in autofs4_show_options. There is shows the
    virtual pid number (i.e. the one that is valid inside the PID namespace
    of the calling process)

    For debugging printk convert oz_pgrp to the value in the initial pid
    namespace.

    Signed-off-by: Sukadev Bhattiprolu
    Signed-off-by: Miklos Szeredi
    Acked-by: Serge Hallyn
    Cc: Eric Biederman
    Acked-by: Ian Kent
    Cc: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sukadev Bhattiprolu
     

25 Oct, 2013

1 commit


15 Nov, 2012

1 commit

  • Use kuid_t and kgid_t in struct autofs_info and struct autofs_wait_queue.

    When creating directories and symlinks default the uid and gid of
    the mount requester to the global root uid and gid. autofs4_wait
    will update these fields when a mount is requested.

    When generating autofsv5 packets report the uid and gid of the mount
    requestor in user namespace of the process that opened the pipe,
    reporting unmapped uids and gids as overflowuid and overflowgid.

    In autofs_dev_ioctl_requester return the uid and gid of the last mount
    requester converted into the calling processes user namespace. When the
    uid or gid don't map return overflowuid and overflowgid as appropriate,
    allowing failure to find a mount requester to be distinguished from
    failure to map a mount requester.

    The uid and gid mount options specifying the user and group of the
    root autofs inode are converted into kuid and kgid as they are parsed
    defaulting to the current uid and current gid of the process that
    mounts autofs.

    Mounting of autofs for the present remains confined to processes in
    the initial user namespace.

    Cc: Ian Kent
    Acked-by: Serge Hallyn
    Signed-off-by: Eric W. Biederman

    Eric W. Biederman
     

29 May, 2012

1 commit

  • Pull writeback tree from Wu Fengguang:
    "Mainly from Jan Kara to avoid iput() in the flusher threads."

    * tag 'writeback' of git://git.kernel.org/pub/scm/linux/kernel/git/wfg/linux:
    writeback: Avoid iput() from flusher thread
    vfs: Rename end_writeback() to clear_inode()
    vfs: Move waiting for inode writeback from end_writeback() to evict_inode()
    writeback: Refactor writeback_single_inode()
    writeback: Remove wb->list_lock from writeback_single_inode()
    writeback: Separate inode requeueing after writeback
    writeback: Move I_DIRTY_PAGES handling
    writeback: Move requeueing when I_SYNC set to writeback_sb_inodes()
    writeback: Move clearing of I_SYNC into inode_sync_complete()
    writeback: initialize global_dirty_limit
    fs: remove 8 bytes of padding from struct writeback_control on 64 bit builds
    mm: page-writeback.c: local functions should not be exposed globally

    Linus Torvalds
     

06 May, 2012

1 commit

  • After we moved inode_sync_wait() from end_writeback() it doesn't make sense
    to call the function end_writeback() anymore. Rename it to clear_inode()
    which well says what the function really does - set I_CLEAR flag.

    Signed-off-by: Jan Kara
    Signed-off-by: Fengguang Wu

    Jan Kara
     

30 Apr, 2012

1 commit

  • The autofs packet size has had a very unfortunate size problem on x86:
    because the alignment of 'u64' differs in 32-bit and 64-bit modes, and
    because the packet data was not 8-byte aligned, the size of the autofsv5
    packet structure differed between 32-bit and 64-bit modes despite
    looking otherwise identical (300 vs 304 bytes respectively).

    We first fixed that up by making the 64-bit compat mode know about this
    problem in commit a32744d4abae ("autofs: work around unhappy compat
    problem on x86-64"), and that made a 32-bit 'systemd' work happily on a
    64-bit kernel because everything then worked the same way as on a 32-bit
    kernel.

    But it turned out that 'automount' had actually known and worked around
    this problem in user space, so fixing the kernel to do the proper 32-bit
    compatibility handling actually *broke* 32-bit automount on a 64-bit
    kernel, because it knew that the packet sizes were wrong and expected
    those incorrect sizes.

    As a result, we ended up reverting that compatibility mode fix, and
    thus breaking systemd again, in commit fcbf94b9dedd.

    With both automount and systemd doing a single read() system call, and
    verifying that they get *exactly* the size they expect but using
    different sizes, it seemed that fixing one of them inevitably seemed to
    break the other. At one point, a patch I seriously considered applying
    from Michael Tokarev did a "strcmp()" to see if it was automount that
    was doing the operation. Ugly, ugly.

    However, a prettier solution exists now thanks to the packetized pipe
    mode. By marking the communication pipe as being packetized (by simply
    setting the O_DIRECT flag), we can always just write the bigger packet
    size, and if user-space does a smaller read, it will just get that
    partial end result and the extra alignment padding will simply be thrown
    away.

    This makes both automount and systemd happy, since they now get the size
    they asked for, and the kernel side of autofs simply no longer needs to
    care - it could pad out the packet arbitrarily.

    Of course, if there is some *other* user of autofs (please, please,
    please tell me it ain't so - and we haven't heard of any) that tries to
    read the packets with multiple writes, that other user will now be
    broken - the whole point of the packetized mode is that one system call
    gets exactly one packet, and you cannot read a packet in pieces.

    Tested-by: Michael Tokarev
    Cc: Alan Cox
    Cc: David Miller
    Cc: Ian Kent
    Cc: Thomas Meyer
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

28 Apr, 2012

1 commit

  • This reverts commit a32744d4abae24572eff7269bc17895c41bd0085.

    While that commit was technically the right thing to do, and made the
    x86-64 compat mode work identically to native 32-bit mode (and thus
    fixing the problem with a 32-bit systemd install on a 64-bit kernel), it
    turns out that the automount binaries had workarounds for this compat
    problem.

    Now, the workarounds are disgusting: doing an "uname()" to find out the
    architecture of the kernel, and then comparing it for the 64-bit cases
    and fixing up the size of the read() in automount for those. And they
    were confused: it's not actually a generic 64-bit issue at all, it's
    very much tied to just x86-64, which has different alignment for an
    'u64' in 64-bit mode than in 32-bit mode.

    But the end result is that fixing the compat layer actually breaks the
    case of a 32-bit automount on a x86-64 kernel.

    There are various approaches to fix this (including just doing a
    "strcmp()" on current->comm and comparing it to "automount"), but I
    think that I will do the one that teaches pipes about a special "packet
    mode", which will allow user space to not have to care too deeply about
    the padding at the end of the autofs packet.

    That change will make the compat workaround unnecessary, so let's revert
    it first, and get automount working again in compat mode. The
    packetized pipes will then fix autofs for systemd.

    Reported-and-requested-by: Michael Tokarev
    Cc: Ian Kent
    Cc: stable@kernel.org # for 3.3
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

21 Mar, 2012

1 commit


26 Feb, 2012

1 commit

  • When the autofs protocol version 5 packet type was added in commit
    5c0a32fc2cd0 ("autofs4: add new packet type for v5 communications"), it
    obvously tried quite hard to be word-size agnostic, and uses explicitly
    sized fields that are all correctly aligned.

    However, with the final "char name[NAME_MAX+1]" array at the end, the
    actual size of the structure ends up being not very well defined:
    because the struct isn't marked 'packed', doing a "sizeof()" on it will
    align the size of the struct up to the biggest alignment of the members
    it has.

    And despite all the members being the same, the alignment of them is
    different: a "__u64" has 4-byte alignment on x86-32, but native 8-byte
    alignment on x86-64. And while 'NAME_MAX+1' ends up being a nice round
    number (256), the name[] array starts out a 4-byte aligned.

    End result: the "packed" size of the structure is 300 bytes: 4-byte, but
    not 8-byte aligned.

    As a result, despite all the fields being in the same place on all
    architectures, sizeof() will round up that size to 304 bytes on
    architectures that have 8-byte alignment for u64.

    Note that this is *not* a problem for 32-bit compat mode on POWER, since
    there __u64 is 8-byte aligned even in 32-bit mode. But on x86, 32-bit
    and 64-bit alignment is different for 64-bit entities, and as a result
    the structure that has exactly the same layout has different sizes.

    So on x86-64, but no other architecture, we will just subtract 4 from
    the size of the structure when running in a compat task. That way we
    will write the properly sized packet that user mode expects.

    Not pretty. Sadly, this very subtle, and unnecessary, size difference
    has been encoded in user space that wants to read packets of *exactly*
    the right size, and will refuse to touch anything else.

    Reported-and-tested-by: Thomas Meyer
    Signed-off-by: Ian Kent
    Signed-off-by: Linus Torvalds

    Ian Kent
     

11 Jan, 2012

1 commit

  • Just serialize the actual writing of packets into pipe on
    a new mutex, independent from everything else in the locking
    hierarchy. As soon as something has started feeding a piece
    of packet into the pipe to daemon, we *want* everything else
    about to try the same to wait until we are done.

    Acked-by: Ian Kent
    Signed-off-by: Al Viro

    Al Viro
     

07 Jan, 2012

1 commit


04 Jan, 2012

1 commit


02 Nov, 2011

1 commit


18 Jan, 2011

7 commits


16 Jan, 2011

5 commits

  • Merge the remaining autofs4 dentry ops tables. It doesn't matter if
    d_automount and d_manage are present on something that's not mountable or
    holdable as these ops are only used if the appropriate flags are set in
    dentry->d_flags.

    [AV] switch to ->s_d_op, since now _everything_ on autofs4 is using the
    same dentry_operations.

    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    David Howells
     
  • When this function is called the local reference count does't need to
    be updated since the dentry is going away and dput definitely must
    not be called here.

    Also the autofs info struct field inode isn't used so remove it.

    Signed-off-by: Ian Kent
    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    Ian Kent
     
  • There are now two distinct dentry operations uses. One for dentrys
    that trigger mounts and one for dentrys that do not.

    Rationalize the use of these dentry operations and rename them to
    reflect their function.

    Signed-off-by: Ian Kent
    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    Ian Kent
     
  • Since the use of ->follow_link() has been eliminated there is no
    need to separate the indirect and direct inode operations.

    Signed-off-by: Ian Kent
    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    Ian Kent
     
  • This patch required a previous patch to add the ->d_automount()
    dentry operation.

    Add a function to use the newly defined ->d_manage() dentry operation
    for blocking during mount and expire.

    Whether the VFS calls the dentry operations d_automount() and d_manage()
    is controled by the DMANAGED_AUTOMOUNT and DMANAGED_TRANSIT flags. autofs
    uses the d_automount() operation to callback to user space to request
    mount operations and the d_manage() operation to block walks into mounts
    that are under construction or destruction.

    In order to prevent these functions from being called unnecessarily the
    DMANAGED_* flags are cleared for cases which would cause this. In the
    common case the DMANAGED_AUTOMOUNT and DMANAGED_TRANSIT flags are both
    set for dentrys waiting to be mounted. The DMANAGED_TRANSIT flag is
    cleared upon successful mount request completion and set during expire
    runs, both during the dentry expire check, and if selected for expire,
    is left set until a subsequent successful mount request completes.

    The exception to this is the so-called rootless multi-mount which has
    no actual mount at its base. In this case the DMANAGED_AUTOMOUNT flag
    is cleared upon successful mount request completion as well and set
    again after a successful expire.

    Signed-off-by: Ian Kent
    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    Ian Kent