24 Sep, 2019

1 commit

  • If cuse_send_init fails, need to fuse_conn_put cc->fc.

    cuse_channel_open->fuse_conn_init->refcount_set(&fc->count, 1)
    ->fuse_dev_alloc->fuse_conn_get
    ->fuse_dev_free->fuse_conn_put

    Fixes: cc080e9e9be1 ("fuse: introduce per-instance fuse_dev structure")
    Reported-by: Hulk Robot
    Signed-off-by: zhengbin
    Signed-off-by: Miklos Szeredi

    zhengbin
     

12 Sep, 2019

2 commits

  • As of now fuse_dev_alloc() both allocates a fuse device and installs it in
    fuse_conn list. fuse_dev_alloc() can fail if fuse_device allocation fails.

    virtio-fs needs to initialize multiple fuse devices (one per virtio queue).
    It initializes one fuse device as part of call to fuse_fill_super_common()
    and rest of the devices are allocated and installed after that.

    But, we can't afford to fail after calling fuse_fill_super_common() as we
    don't have a way to undo all the actions done by fuse_fill_super_common().
    So to avoid failures after the call to fuse_fill_super_common(),
    pre-allocate all fuse devices early and install them into fuse connection
    later.

    This patch provides two separate helpers for fuse device allocation and
    fuse device installation in fuse_conn.

    Signed-off-by: Vivek Goyal
    Signed-off-by: Miklos Szeredi

    Vivek Goyal
     
  • The /dev/fuse device uses fiq->waitq and fasync to signal that requests are
    available. These mechanisms do not apply to virtio-fs. This patch
    introduces callbacks so alternative behavior can be used.

    Note that queue_interrupt() changes along these lines:

    spin_lock(&fiq->waitq.lock);
    wake_up_locked(&fiq->waitq);
    + kill_fasync(&fiq->fasync, SIGIO, POLL_IN);
    spin_unlock(&fiq->waitq.lock);
    - kill_fasync(&fiq->fasync, SIGIO, POLL_IN);

    Since queue_request() and queue_forget() also call kill_fasync() inside
    the spinlock this should be safe.

    Signed-off-by: Stefan Hajnoczi
    Signed-off-by: Miklos Szeredi

    Stefan Hajnoczi
     

10 Sep, 2019

1 commit


02 Sep, 2019

1 commit


05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this file is released under the gplv2

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

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

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

    Thomas Gleixner
     

24 Apr, 2019

1 commit

  • Functions, like pr_err, are a more modern variant of printing compared to
    printk. They could be used to denoise sources by using needed level in
    the print function name, and by automatically inserting per-driver /
    function / ... print prefix as defined by pr_fmt macro. pr_* are also
    said to be used in Documentation/process/coding-style.rst and more
    recent code - for example overlayfs - uses them instead of printk.

    Convert CUSE and FUSE to use the new pr_* functions.

    CUSE output stays completely unchanged, while FUSE output is amended a
    bit for "trying to steal weird page" warning - the second line now comes
    also with "fuse:" prefix. I hope it is ok.

    Suggested-by: Kirill Tkhai
    Signed-off-by: Kirill Smelkov
    Reviewed-by: Kirill Tkhai
    Signed-off-by: Miklos Szeredi

    Kirill Smelkov
     

13 Feb, 2019

2 commits


21 Mar, 2018

2 commits

  • In order to support mounts from namespaces other than init_user_ns, fuse
    must translate uids and gids to/from the userns of the process servicing
    requests on /dev/fuse. This patch does that, with a couple of restrictions
    on the namespace:

    - The userns for the fuse connection is fixed to the namespace
    from which /dev/fuse is opened.

    - The namespace must be the same as s_user_ns.

    These restrictions simplify the implementation by avoiding the need to pass
    around userns references and by allowing fuse to rely on the checks in
    setattr_prepare for ownership changes. Either restriction could be relaxed
    in the future if needed.

    For cuse the userns used is the opener of /dev/cuse. Semantically the cuse
    support does not appear safe for unprivileged users. Practically the
    permissions on /dev/cuse only make it accessible to the global root user.
    If something slips through the cracks in a user namespace the only users
    who will be able to use the cuse device are those users mapped into the
    user namespace.

    Translation in the posix acl is updated to use the uuser namespace of the
    filesystem. Avoiding cases which might bypass this translation is handled
    in a following change.

    This change is stronlgy based on a similar change from Seth Forshee and
    Dongsu Park.

    Cc: Seth Forshee
    Cc: Dongsu Park
    Signed-off-by: Eric W. Biederman
    Signed-off-by: Miklos Szeredi

    Eric W. Biederman
     
  • Currently the userspace has no way of knowing whether the fuse
    connection ended because of umount or abort via sysfs. It makes it hard
    for filesystems to free the mountpoint after abort without worrying
    about removing some new mount.

    The patch fixes it by returning different errors when userspace reads
    from /dev/fuse (-ENODEV for umount and -ECONNABORTED for abort).

    Add a new capability flag FUSE_ABORT_ERROR. If set and the connection is
    gone because of sysfs abort, reading from the device will return
    -ECONNABORTED.

    Signed-off-by: Szymon Lukasz
    Signed-off-by: Miklos Szeredi

    Szymon Lukasz
     

12 Sep, 2017

1 commit

  • If the IOCB_DSYNC flag is set a sync is not being performed by
    fuse_file_write_iter.

    Honor IOCB_DSYNC/IOCB_SYNC by setting O_DYSNC/O_SYNC respectively in the
    flags filed of the write request.

    We don't need to sync data or metadata, since fuse_perform_write() does
    write-through and the filesystem is responsible for updating file times.

    Original patch by Vitaly Zolotusky.

    Reported-by: Nate Clark
    Cc: Vitaly Zolotusky .
    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     

14 Mar, 2016

1 commit

  • The 'reqs' member of fuse_io_priv serves two purposes. First is to track
    the number of oustanding async requests to the server and to signal that
    the io request is completed. The second is to be a reference count on the
    structure to know when it can be freed.

    For sync io requests these purposes can be at odds. fuse_direct_IO() wants
    to block until the request is done, and since the signal is sent when
    'reqs' reaches 0 it cannot keep a reference to the object. Yet it needs to
    use the object after the userspace server has completed processing
    requests. This leads to some handshaking and special casing that it
    needlessly complicated and responsible for at least one race condition.

    It's much cleaner and safer to maintain a separate reference count for the
    object lifecycle and to let 'reqs' just be a count of outstanding requests
    to the userspace server. Then we can know for sure when it is safe to free
    the object without any handshaking or special cases.

    The catch here is that most of the time these objects are stack allocated
    and should not be freed. Initializing these objects with a single reference
    that is never released prevents accidental attempts to free the objects.

    Fixes: 9d5722b7777e ("fuse: handle synchronous iocbs internally")
    Cc: stable@vger.kernel.org # v4.1+
    Signed-off-by: Seth Forshee
    Signed-off-by: Miklos Szeredi

    Seth Forshee
     

10 Nov, 2015

1 commit

  • The problem is that fuse_dev_alloc() acquires an extra reference to cc.fc,
    and the original ref count is never dropped.

    Reported-by: Colin Ian King
    Signed-off-by: Miklos Szeredi
    Fixes: cc080e9e9be1 ("fuse: introduce per-instance fuse_dev structure")
    Cc: # v4.2+

    Miklos Szeredi
     

01 Jul, 2015

2 commits


12 Apr, 2015

2 commits


26 Mar, 2015

1 commit


12 Dec, 2014

1 commit

  • Use fuse_abort_conn() instead of fuse_conn_kill() in fuse_put_super().
    This flushes and aborts requests still on any queues. But since we've
    already reset fc->connected, those requests would not be useful anyway and
    would be flushed when the fuse device is closed.

    Next patches will rely on requests being flushed before the superblock is
    destroyed.

    Use fuse_abort_conn() in cuse_process_init_reply() too, since it makes no
    difference there, and we can get rid of fuse_conn_kill().

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     

07 May, 2014

1 commit


07 Apr, 2014

1 commit

  • Pull module updates from Rusty Russell:
    "Nothing major: the stricter permissions checking for sysfs broke a
    staging driver; fix included. Greg KH said he'd take the patch but
    hadn't as the merge window opened, so it's included here to avoid
    breaking build"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    staging: fix up speakup kobject mode
    Use 'E' instead of 'X' for unsigned module taint flag.
    VERIFY_OCTAL_PERMISSIONS: stricter checking for sysfs perms.
    kallsyms: fix percpu vars on x86-64 with relocation.
    kallsyms: generalize address range checking
    module: LLVMLinux: Remove unused function warning from __param_check macro
    Fix: module signature vs tracepoints: add new TAINT_UNSIGNED_MODULE
    module: remove MODULE_GENERIC_TABLE
    module: allow multiple calls to MODULE_DEVICE_TABLE() per module
    module: use pr_cont

    Linus Torvalds
     

02 Apr, 2014

1 commit

  • The problem is:

    1. write cached data to a file
    2. read directly from the same file (via another fd)

    The 2nd operation may read stale data, i.e. the one that was in a file
    before the 1st op. Problem is in how fuse manages writeback.

    When direct op occurs the core kernel code calls filemap_write_and_wait
    to flush all the cached ops in flight. But fuse acks the writeback right
    after the ->writepages callback exits w/o waiting for the real write to
    happen. Thus the subsequent direct op proceeds while the real writeback
    is still in flight. This is a problem for backends that reorder operation.

    Fix this by making the fuse direct IO callback explicitly wait on the
    in-flight writeback to finish.

    Signed-off-by: Maxim Patlasov
    Signed-off-by: Miklos Szeredi

    Pavel Emelyanov
     

24 Mar, 2014

1 commit

  • Summary of http://lkml.org/lkml/2014/3/14/363 :

    Ted: module_param(queue_depth, int, 444)
    Joe: 0444!
    Rusty: User perms >= group perms >= other perms?
    Joe: CLASS_ATTR, DEVICE_ATTR, SENSOR_ATTR and SENSOR_ATTR_2?

    Side effect of stricter permissions means removing the unnecessary
    S_IFREG from several callers.

    Note that the BUILD_BUG_ON_ZERO((perm) & 2) test was removed: a fair
    number of drivers fail this test, so that will be the debate for a
    future patch.

    Suggested-by: Joe Perches
    Acked-by: Bjorn Helgaas for drivers/pci/slot.c
    Acked-by: Greg Kroah-Hartman
    Cc: Miklos Szeredi
    Cc: Mark Fasheh
    Cc: Joel Becker
    Signed-off-by: Rusty Russell

    Rusty Russell
     

13 Nov, 2013

1 commit

  • Pull vfs updates from Al Viro:
    "All kinds of stuff this time around; some more notable parts:

    - RCU'd vfsmounts handling
    - new primitives for coredump handling
    - files_lock is gone
    - Bruce's delegations handling series
    - exportfs fixes

    plus misc stuff all over the place"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (101 commits)
    ecryptfs: ->f_op is never NULL
    locks: break delegations on any attribute modification
    locks: break delegations on link
    locks: break delegations on rename
    locks: helper functions for delegation breaking
    locks: break delegations on unlink
    namei: minor vfs_unlink cleanup
    locks: implement delegations
    locks: introduce new FL_DELEG lock flag
    vfs: take i_mutex on renamed file
    vfs: rename I_MUTEX_QUOTA now that it's not used for quotas
    vfs: don't use PARENT/CHILD lock classes for non-directories
    vfs: pull ext4's double-i_mutex-locking into common code
    exportfs: fix quadratic behavior in filehandle lookup
    exportfs: better variable name
    exportfs: move most of reconnect_path to helper function
    exportfs: eliminate unused "noprogress" counter
    exportfs: stop retrying once we race with rename/remove
    exportfs: clear DISCONNECTED on all parents sooner
    exportfs: more detailed comment for path_reconnect
    ...

    Linus Torvalds
     

25 Oct, 2013

1 commit


01 Oct, 2013

1 commit

  • This allows udev (or more recently systemd-tmpfiles) to create /dev/cuse on
    boot, in the same way as /dev/fuse is currently created, and the corresponding
    module to be loaded on first access.

    The corresponding functionalty was introduced for fuse in commit 578454f.

    Signed-off-by: Tom Gundersen
    Cc: Kay Sievers
    Signed-off-by: Miklos Szeredi

    Tom Gundersen
     

27 Jul, 2013

1 commit


08 May, 2013

2 commits

  • Merge more incoming from Andrew Morton:

    - Various fixes which were stalled or which I picked up recently

    - A large rotorooting of the AIO code. Allegedly to improve
    performance but I don't really have good performance numbers (I might
    have lost the email) and I can't raise Kent today. I held this out
    of 3.9 and we could give it another cycle if it's all too late/scary.

    I ended up taking only the first two thirds of the AIO rotorooting. I
    left the percpu parts and the batch completion for later. - Linus

    * emailed patches from Andrew Morton : (33 commits)
    aio: don't include aio.h in sched.h
    aio: kill ki_retry
    aio: kill ki_key
    aio: give shared kioctx fields their own cachelines
    aio: kill struct aio_ring_info
    aio: kill batch allocation
    aio: change reqs_active to include unreaped completions
    aio: use cancellation list lazily
    aio: use flush_dcache_page()
    aio: make aio_read_evt() more efficient, convert to hrtimers
    wait: add wait_event_hrtimeout()
    aio: refcounting cleanup
    aio: make aio_put_req() lockless
    aio: do fget() after aio_get_req()
    aio: dprintk() -> pr_debug()
    aio: move private stuff out of aio.h
    aio: add kiocb_cancel()
    aio: kill return value of aio_complete()
    char: add aio_{read,write} to /dev/{null,zero}
    aio: remove retry-based AIO
    ...

    Linus Torvalds
     
  • Faster kernel compiles by way of fewer unnecessary includes.

    [akpm@linux-foundation.org: fix fallout]
    [akpm@linux-foundation.org: fix build]
    Signed-off-by: Kent Overstreet
    Cc: Zach Brown
    Cc: Felipe Balbi
    Cc: Greg Kroah-Hartman
    Cc: Mark Fasheh
    Cc: Joel Becker
    Cc: Rusty Russell
    Cc: Jens Axboe
    Cc: Asai Thambi S P
    Cc: Selvan Mani
    Cc: Sam Bradshaw
    Cc: Jeff Moyer
    Cc: Al Viro
    Cc: Benjamin LaHaise
    Reviewed-by: "Theodore Ts'o"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kent Overstreet
     

18 Apr, 2013

1 commit

  • The patch implements passing "struct fuse_io_priv *io" down the stack up to
    fuse_send_read/write where it is used to submit request asynchronously.
    io->async==0 designates synchronous processing.

    Non-trivial part of the patch is changes in fuse_direct_io(): resources
    like fuse requests and user pages cannot be released immediately in async
    case.

    Signed-off-by: Maxim Patlasov
    Signed-off-by: Miklos Szeredi

    Maxim Patlasov
     

17 Apr, 2013

3 commits

  • A task may have at most one synchronous request allocated. So these
    requests need not be otherwise limited.

    The patch re-works fuse_get_req() to follow this idea.

    Signed-off-by: Maxim Patlasov
    Signed-off-by: Miklos Szeredi

    Maxim Patlasov
     
  • Existing flag fc->blocked is used to suspend request allocation both in case
    of many background request submitted and period of time before init_reply
    arrives from userspace. Next patch will skip blocking allocations of
    synchronous request (disregarding fc->blocked). This is mostly OK, but
    we still need to suspend allocations if init_reply is not arrived yet. The
    patch introduces flag fc->initialized which will serve this purpose.

    Signed-off-by: Maxim Patlasov
    Signed-off-by: Miklos Szeredi

    Maxim Patlasov
     
  • There are two types of processing requests in FUSE: synchronous (via
    fuse_request_send()) and asynchronous (via adding to fc->bg_queue).

    Fortunately, the type of processing is always known in advance, at the time
    of request allocation. This preparatory patch utilizes this fact making
    fuse_get_req() aware about the type. Next patches will use it.

    Signed-off-by: Maxim Patlasov
    Signed-off-by: Miklos Szeredi

    Maxim Patlasov
     

24 Jan, 2013

3 commits

  • Fix the following sparse warnings:

    fs/fuse/file.c:1216:43: warning: cast removes address space of expression
    fs/fuse/file.c:1216:43: warning: incorrect type in initializer (different address spaces)
    fs/fuse/file.c:1216:43: expected void [noderef] *iov_base
    fs/fuse/file.c:1216:43: got void *
    fs/fuse/file.c:1241:43: warning: cast removes address space of expression
    fs/fuse/file.c:1241:43: warning: incorrect type in initializer (different address spaces)
    fs/fuse/file.c:1241:43: expected void [noderef] *iov_base
    fs/fuse/file.c:1241:43: got void *
    fs/fuse/file.c:1267:43: warning: cast removes address space of expression
    fs/fuse/file.c:1267:43: warning: incorrect type in initializer (different address spaces)
    fs/fuse/file.c:1267:43: expected void [noderef] *iov_base
    fs/fuse/file.c:1267:43: got void *

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     
  • Previously, anyone who set flag 'argpages' only filled req->pages[] and set
    per-request page_offset. This patch re-works all cases where argpages=1 to
    fill req->page_descs[] properly.

    Having req->page_descs[] filled properly allows to re-work fuse_copy_pages()
    to copy page fragments described by req->page_descs[]. This will be useful
    for next patches optimizing direct_IO.

    Signed-off-by: Maxim Patlasov
    Signed-off-by: Miklos Szeredi

    Maxim Patlasov
     
  • The patch categorizes all fuse_get_req() invocations into two categories:
    - fuse_get_req_nopages(fc) - when caller doesn't care about req->pages
    - fuse_get_req(fc, n) - when caller need n page pointers (n > 0)

    Adding fuse_get_req_nopages() helps to avoid numerous fuse_get_req(fc, 0)
    scattered over code. Now it's clear from the first glance when a caller need
    fuse_req with page pointers.

    The patch doesn't make any logic changes. In multi-page case, it silly
    allocates array of FUSE_MAX_PAGES_PER_REQ page pointers. This will be amended
    by future patches.

    Signed-off-by: Maxim Patlasov
    Signed-off-by: Miklos Szeredi

    Maxim Patlasov
     

17 Jan, 2013

3 commits

  • Fix the following compiler warnings:

    fs/fuse/cuse.c: In function 'cuse_process_init_reply':
    fs/fuse/cuse.c:288:24: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
    fs/fuse/cuse.c:272:14: note: 'val' was declared here
    fs/fuse/cuse.c:284:10: warning: 'key' may be used uninitialized in this function [-Wmaybe-uninitialized]
    fs/fuse/cuse.c:272:8: note: 'key' was declared here

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     
  • Sysfs doesn't allow two devices with the same name, but we register a
    sysfs entry for each cuse device without checking for name collisions.
    This extends the registration to first check whether the name was already
    registered.

    To avoid race-conditions between the name-check and linking the device, we
    need to protect the whole registration with a mutex.

    Signed-off-by: David Herrmann
    Acked-by: Tejun Heo
    Signed-off-by: Miklos Szeredi

    David Herrmann
     
  • We need to check for name-collisions during cuse-device registration. To
    avoid race-conditions, this needs to be protected during the whole device
    registration. Therefore, replace the spinlocks by mutexes first so we can
    safely extend the locked regions to include more expensive or sleeping
    code paths.

    Signed-off-by: David Herrmann
    Acked-by: Tejun Heo
    Signed-off-by: Miklos Szeredi

    David Herrmann