09 Dec, 2020

1 commit


02 Dec, 2020

2 commits

  • The default splice operations got removed recently, add it back to 9p
    with iter_file_splice_write like many other filesystems do.

    Link: http://lkml.kernel.org/r/1606837496-21717-1-git-send-email-asmadeus@codewreck.org
    Fixes: 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops")
    Signed-off-by: Dominique Martinet
    Acked-by: Toke Høiland-Jørgensen
    Reviewed-by: Christoph Hellwig

    Dominique Martinet
     
  • The v9fs file operations were missing the splice_read operations, which
    breaks sendfile() of files on such a filesystem. I discovered this while
    trying to load an eBPF program using iproute2 inside a 'virtme' environment
    which uses 9pfs for the virtual file system. iproute2 relies on sendfile()
    with an AF_ALG socket to hash files, which was erroring out in the virtual
    environment.

    Since generic_file_splice_read() seems to just implement splice_read in
    terms of the read_iter operation, I simply added the generic implementation
    to the file operations, which fixed the error I was seeing. A quick grep
    indicates that this is what most other file systems do as well.

    Link: http://lkml.kernel.org/r/20201201135409.55510-1-toke@redhat.com
    Fixes: 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops")
    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Dominique Martinet

    Toke Høiland-Jørgensen
     

29 Oct, 2020

1 commit


26 Oct, 2020

1 commit


25 Oct, 2020

1 commit

  • Pull misc vfs updates from Al Viro:
    "Assorted stuff all over the place (the largest group here is
    Christoph's stat cleanups)"

    * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs: remove KSTAT_QUERY_FLAGS
    fs: remove vfs_stat_set_lookup_flags
    fs: move vfs_fstatat out of line
    fs: implement vfs_stat and vfs_lstat in terms of vfs_fstatat
    fs: remove vfs_statx_fd
    fs: omfs: use kmemdup() rather than kmalloc+memcpy
    [PATCH] reduce boilerplate in fsid handling
    fs: Remove duplicated flag O_NDELAY occurring twice in VALID_OPEN_FLAGS
    selftests: mount: add nosymfollow tests
    Add a "nosymfollow" mount option.

    Linus Torvalds
     

24 Oct, 2020

1 commit


23 Oct, 2020

1 commit

  • Pull 9p updates from Dominique Martinet:
    "A couple of small fixes (loff_t overflow on 32bit, syzbot
    uninitialized variable warning) and code cleanup (xen)"

    * tag '9p-for-5.10-rc1' of git://github.com/martinetd/linux:
    net: 9p: initialize sun_server.sun_path to have addr's value only when addr is valid
    9p/xen: Fix format argument warning
    9P: Cast to loff_t before multiplying

    Linus Torvalds
     

08 Oct, 2020

1 commit

  • On 32-bit systems, this multiplication will overflow for files larger
    than 4GB.

    Link: http://lkml.kernel.org/r/20201004180428.14494-2-willy@infradead.org
    Cc: stable@vger.kernel.org
    Fixes: fb89b45cdfdc ("9P: introduction of a new cache=mmap model.")
    Signed-off-by: Matthew Wilcox (Oracle)
    Signed-off-by: Dominique Martinet

    Matthew Wilcox (Oracle)
     

25 Sep, 2020

2 commits

  • Replace the two negative flags that are always used together with a
    single positive flag that indicates the writeback capability instead
    of two related non-capabilities. Also remove the pointless wrappers
    to just check the flag.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Jan Kara
    Reviewed-by: Johannes Thumshirn
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     
  • Set up a readahead size by default, as very few users have a good
    reason to change it. This means code, ecryptfs, and orangefs now
    set up the values while they were previously missing it, while ubifs,
    mtd and vboxsf manually set it to 0 to avoid readahead.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Jan Kara
    Acked-by: David Sterba [btrfs]
    Acked-by: Richard Weinberger [ubifs, mtd]
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

19 Sep, 2020

1 commit


01 Sep, 2020

1 commit


24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

17 Aug, 2020

1 commit


31 Jul, 2020

1 commit

  • Remove kmem_cache_alloc return value cast.

    Coccinelle emits the following warning:

    ./fs/9p/vfs_inode.c:226:12-29: WARNING: casting value returned by memory allocation function to (struct v9fs_inode *) is useless.

    Link: http://lkml.kernel.org/r/1596013140-49744-1-git-send-email-liheng40@huawei.com
    Signed-off-by: Li Heng
    [Dominique: commit message wording]
    Signed-off-by: Dominique Martinet

    Li Heng
     

19 Jul, 2020

3 commits

  • These codes have been commented out since 2007 and lay in kernel
    since then. So, it's better to remove them.

    Link: http://lkml.kernel.org/r/20200628074337.45895-1-jianyong.wu@arm.com
    Signed-off-by: Jianyong Wu
    Signed-off-by: Dominique Martinet

    Jianyong Wu
     
  • v9fs_mount
    v9fs_session_init
    v9fs_cache_session_get_cookie
    v9fs_random_cachetag -->alloc cachetag
    v9ses->fscache = fscache_acquire_cookie -->maybe NULL
    sb = sget -->fail, goto clunk
    clunk_fid:
    v9fs_session_close
    if (v9ses->fscache) -->NULL
    kfree(v9ses->cachetag)

    Thus memleak happens.

    Link: http://lkml.kernel.org/r/20200615012153.89538-1-zhengbin13@huawei.com
    Fixes: 60e78d2c993e ("9p: Add fscache support to 9p")
    Cc: # v2.6.32+
    Signed-off-by: Zheng Bin
    Signed-off-by: Dominique Martinet

    Zheng Bin
     
  • In the current setattr implementation in 9p, fid is always retrieved
    from dentry no matter file instance exists or not. If so, there may be
    some info related to opened file instance dropped. So it's better
    to retrieve fid from file instance when it is passed to setattr.

    for example:
    fd=open("tmp", O_RDWR);
    ftruncate(fd, 10);

    The file context related with the fd will be lost as fid is always
    retrieved from dentry, then the backend can't get the info of
    file context. It is against the original intention of user and
    may lead to bug.

    Link: http://lkml.kernel.org/r/20200710101548.10108-1-jianyong.wu@arm.com
    Signed-off-by: Jianyong Wu
    Signed-off-by: Dominique Martinet

    Jianyong Wu
     

09 Apr, 2020

1 commit


27 Mar, 2020

3 commits

  • A proper way to handle O_NONBLOCK would be making the requests and
    responses happen asynchronously, but this would require serious code
    refactoring.

    Link: http://lkml.kernel.org/r/20200205003457.24340-2-l29ah@cock.li
    Signed-off-by: Sergey Alirzaev
    Signed-off-by: Dominique Martinet

    Sergey Alirzaev
     
  • Fixes coccicheck warning:

    fs/9p/vfs_inode.c:146:3-4: Unneeded semicolon

    Link: http://lkml.kernel.org/r/1576752517-58292-1-git-send-email-zhengbin13@huawei.com
    Reported-by: Hulk Robot
    Signed-off-by: zhengbin
    Signed-off-by: Dominique Martinet

    zhengbin
     
  • Adjust indentation from spaces to tab (+optional two spaces) as in
    coding style with command like:
    $ sed -e 's/^ /\t/' -i */Kconfig

    Link: http://lkml.kernel.org/r/20191120134340.16770-1-krzk@kernel.org
    Signed-off-by: Krzysztof Kozlowski
    Signed-off-by: Dominique Martinet

    Krzysztof Kozlowski
     

06 Nov, 2019

1 commit

  • Add a flag option to get xattr method that could have a bit flag of
    XATTR_NOSECURITY passed to it. XATTR_NOSECURITY is generally then
    set in the __vfs_getxattr path when called by security
    infrastructure.

    This handles the case of a union filesystem driver that is being
    requested by the security layer to report back the xattr data.

    For the use case where access is to be blocked by the security layer.

    The path then could be security(dentry) ->
    __vfs_getxattr(dentry...XATTR_NOSECURITY) ->
    handler->get(dentry...XATTR_NOSECURITY) ->
    __vfs_getxattr(lower_dentry...XATTR_NOSECURITY) ->
    lower_handler->get(lower_dentry...XATTR_NOSECURITY)
    which would report back through the chain data and success as
    expected, the logging security layer at the top would have the
    data to determine the access permissions and report back the target
    context that was blocked.

    Without the get handler flag, the path on a union filesystem would be
    the errant security(dentry) -> __vfs_getxattr(dentry) ->
    handler->get(dentry) -> vfs_getxattr(lower_dentry) -> nested ->
    security(lower_dentry, log off) -> lower_handler->get(lower_dentry)
    which would report back through the chain no data, and -EACCES.

    For selinux for both cases, this would translate to a correctly
    determined blocked access. In the first case with this change a correct avc
    log would be reported, in the second legacy case an incorrect avc log
    would be reported against an uninitialized u:object_r:unlabeled:s0
    context making the logs cosmetically useless for audit2allow.

    This patch series is inert and is the wide-spread addition of the
    flags option for xattr functions, and a replacement of __vfs_getxattr
    with __vfs_getxattr(...XATTR_NOSECURITY).

    Signed-off-by: Mark Salyzyn
    Reviewed-by: Jan Kara
    Acked-by: Jan Kara
    Acked-by: Jeff Layton
    Acked-by: David Sterba
    Acked-by: Darrick J. Wong
    Acked-by: Mike Marshall
    Cc: Stephen Smalley
    Cc: linux-kernel@vger.kernel.org
    Cc: kernel-team@android.com
    Cc: linux-security-module@vger.kernel.org

    (cherry picked from (rejected from archive because of too many recipients))
    Signed-off-by: Mark Salyzyn
    Bug: 133515582
    Bug: 136124883
    Bug: 129319403
    Change-Id: Iabbb8771939d5f66667a26bb23ddf4c562c349a1

    Mark Salyzyn
     

28 Sep, 2019

1 commit

  • Pull 9p updates from Dominique Martinet:
    "Some of the usual small fixes and cleanup.

    Small fixes all around:
    - avoid overlayfs copy-up for PRIVATE mmaps
    - KUMSAN uninitialized warning for transport error
    - one syzbot memory leak fix in 9p cache
    - internal API cleanup for v9fs_fill_super"

    * tag '9p-for-5.4' of git://github.com/martinetd/linux:
    9p/vfs_super.c: Remove unused parameter data in v9fs_fill_super
    9p/cache.c: Fix memory leak in v9fs_cache_session_get_cookie
    9p: Transport error uninitialized
    9p: avoid attaching writeback_fid on mmap with type PRIVATE

    Linus Torvalds
     

03 Sep, 2019

3 commits

  • v9fs_fill_super has a param 'void *data' which is unused in the
    function.

    This patch removes the 'void *data' param in v9fs_fill_super and changes
    the parameters in all function calls of v9fs_fill_super.

    Link: http://lkml.kernel.org/r/20190523165619.GA4209@bharath12345-Inspiron-5559
    Signed-off-by: Bharath Vedartham
    Signed-off-by: Dominique Martinet

    Bharath Vedartham
     
  • v9fs_cache_session_get_cookie assigns a random cachetag to v9ses->cachetag,
    if the cachetag is not assigned previously.

    v9fs_random_cachetag allocates memory to v9ses->cachetag with kmalloc and uses
    scnprintf to fill it up with a cachetag.

    But if scnprintf fails, v9ses->cachetag is not freed in the current
    code causing a memory leak.

    Fix this by freeing v9ses->cachetag it v9fs_random_cachetag fails.

    This was reported by syzbot, the link to the report is below:
    https://syzkaller.appspot.com/bug?id=f012bdf297a7a4c860c38a88b44fbee43fd9bbf3

    Link: http://lkml.kernel.org/r/20190522194519.GA5313@bharath12345-Inspiron-5559
    Reported-by: syzbot+3a030a73b6c1e9833815@syzkaller.appspotmail.com
    Signed-off-by: Bharath Vedartham
    Signed-off-by: Dominique Martinet

    Bharath Vedartham
     
  • Currently on mmap cache policy, we always attach writeback_fid
    whether mmap type is SHARED or PRIVATE. However, in the use case
    of kata-container which combines 9p(Guest OS) with overlayfs(Host OS),
    this behavior will trigger overlayfs' copy-up when excute command
    inside container.

    Link: http://lkml.kernel.org/r/20190820100325.10313-1-cgxu519@zoho.com.cn
    Signed-off-by: Chengguang Xu
    Signed-off-by: Dominique Martinet

    Chengguang Xu
     

30 Aug, 2019

1 commit

  • struct p9_wstat and struct p9_stat_dotl indicate that the
    wire transport uses u32 and u64 fields for timestamps.
    Fill in the appropriate limits to avoid inconsistencies in
    the vfs cached inode times when timestamps are outside the
    permitted range.

    Note that the upper bound for V9FS_PROTO_2000L is retained as S64_MAX.
    This is because that is the upper bound supported by vfs.

    Signed-off-by: Deepa Dinamani
    Acked-by: Jeff Layton
    Cc: ericvh@gmail.com
    Cc: lucho@ionkov.net
    Cc: asmadeus@codewreck.org
    Cc: v9fs-developer@lists.sourceforge.net

    Deepa Dinamani
     

13 Jul, 2019

1 commit

  • Fix the callback 9p passes to read_cache_page to actually have the
    proper type expected. Casting around function pointers can easily
    hide typing bugs, and defeats control flow protection.

    Link: http://lkml.kernel.org/r/20190520055731.24538-5-hch@lst.de
    Signed-off-by: Christoph Hellwig
    Reviewed-by: Kees Cook
    Cc: Sami Tolvanen
    Cc: Nick Desaulniers
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Hellwig
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not write to free software
    foundation 51 franklin street fifth floor boston ma 02111 1301 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

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

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Richard Fontana
    Reviewed-by: Alexios Zavras
    Reviewed-by: Steve Winslow
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190528170026.981318839@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


02 May, 2019

1 commit


18 Mar, 2019

1 commit

  • Pull 9p updates from Dominique Martinet:
    "Here is a 9p update for 5.1; there honestly hasn't been much.

    Two fixes (leak on invalid mount argument and possible deadlock on
    i_size update on 32bit smp) and a fall-through warning cleanup"

    * tag '9p-for-5.1' of git://github.com/martinetd/linux:
    9p/net: fix memory leak in p9_client_create
    9p: use inode->i_lock to protect i_size_write() under 32-bit
    9p: mark expected switch fall-through

    Linus Torvalds
     

13 Mar, 2019

1 commit

  • All users of VM_MAX_READAHEAD actually convert it to kbytes and then to
    pages. Define the macro explicitly as (SZ_128K / PAGE_SIZE). This
    simplifies the expression in every filesystem. Also rename the macro to
    VM_READAHEAD_PAGES to properly convey its meaning. Finally remove unused
    VM_MIN_READAHEAD

    [akpm@linux-foundation.org: fix fs/io_uring.c, per Stephen]
    Link: http://lkml.kernel.org/r/20181221144053.24318-1-nborisov@suse.com
    Signed-off-by: Nikolay Borisov
    Reviewed-by: Matthew Wilcox
    Reviewed-by: David Hildenbrand
    Cc: Jens Axboe
    Cc: Eric Van Hensbergen
    Cc: Latchesar Ionkov
    Cc: Dominique Martinet
    Cc: David Howells
    Cc: Chris Mason
    Cc: Josef Bacik
    Cc: David Sterba
    Cc: Miklos Szeredi
    Cc: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nikolay Borisov
     

03 Mar, 2019

1 commit

  • Use inode->i_lock to protect i_size_write(), else i_size_read() in
    generic_fillattr() may loop infinitely in read_seqcount_begin() when
    multiple processes invoke v9fs_vfs_getattr() or v9fs_vfs_getattr_dotl()
    simultaneously under 32-bit SMP environment, and a soft lockup will be
    triggered as show below:

    watchdog: BUG: soft lockup - CPU#5 stuck for 22s! [stat:2217]
    Modules linked in:
    CPU: 5 PID: 2217 Comm: stat Not tainted 5.0.0-rc1-00005-g7f702faf5a9e #4
    Hardware name: Generic DT based system
    PC is at generic_fillattr+0x104/0x108
    LR is at 0xec497f00
    pc : [] lr : [] psr: 200c0013
    sp : ec497e20 ip : ed608030 fp : ec497e3c
    r10: 00000000 r9 : ec497f00 r8 : ed608030
    r7 : ec497ebc r6 : ec497f00 r5 : ee5c1550 r4 : ee005780
    r3 : 0000052d r2 : 00000000 r1 : ec497f00 r0 : ed608030
    Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
    Control: 10c5387d Table: ac48006a DAC: 00000051
    CPU: 5 PID: 2217 Comm: stat Not tainted 5.0.0-rc1-00005-g7f702faf5a9e #4
    Hardware name: Generic DT based system
    Backtrace:
    [] (dump_backtrace) from [] (show_stack+0x20/0x24)
    [] (show_stack) from [] (dump_stack+0xb0/0xdc)
    [] (dump_stack) from [] (show_regs+0x1c/0x20)
    [] (show_regs) from [] (watchdog_timer_fn+0x280/0x2f8)
    [] (watchdog_timer_fn) from [] (__hrtimer_run_queues+0x18c/0x380)
    [] (__hrtimer_run_queues) from [] (hrtimer_run_queues+0xb8/0xf0)
    [] (hrtimer_run_queues) from [] (run_local_timers+0x28/0x64)
    [] (run_local_timers) from [] (update_process_times+0x3c/0x6c)
    [] (update_process_times) from [] (tick_nohz_handler+0xe0/0x1bc)
    [] (tick_nohz_handler) from [] (arch_timer_handler_virt+0x38/0x48)
    [] (arch_timer_handler_virt) from [] (handle_percpu_devid_irq+0x8c/0x240)
    [] (handle_percpu_devid_irq) from [] (generic_handle_irq+0x34/0x44)
    [] (generic_handle_irq) from [] (__handle_domain_irq+0x6c/0xc4)
    [] (__handle_domain_irq) from [] (gic_handle_irq+0x4c/0x88)
    [] (gic_handle_irq) from [] (__irq_svc+0x70/0x98)
    [] (generic_fillattr) from [] (v9fs_vfs_getattr_dotl+0x74/0xa4)
    [] (v9fs_vfs_getattr_dotl) from [] (vfs_getattr_nosec+0x68/0x7c)
    [] (vfs_getattr_nosec) from [] (vfs_getattr+0x44/0x48)
    [] (vfs_getattr) from [] (vfs_statx+0x9c/0xec)
    [] (vfs_statx) from [] (sys_lstat64+0x48/0x78)
    [] (sys_lstat64) from [] (ret_fast_syscall+0x0/0x28)

    [dominique.martinet@cea.fr: updated comment to not refer to a function
    in another subsystem]
    Link: http://lkml.kernel.org/r/20190124063514.8571-2-houtao1@huawei.com
    Cc: stable@vger.kernel.org
    Fixes: 7549ae3e81cc ("9p: Use the i_size_[read, write]() macros instead of using inode->i_size directly.")
    Reported-by: Xing Gaopeng
    Signed-off-by: Hou Tao
    Signed-off-by: Dominique Martinet

    Hou Tao
     

02 Nov, 2018

1 commit

  • Pull AFS updates from Al Viro:
    "AFS series, with some iov_iter bits included"

    * 'work.afs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (26 commits)
    missing bits of "iov_iter: Separate type from direction and use accessor functions"
    afs: Probe multiple fileservers simultaneously
    afs: Fix callback handling
    afs: Eliminate the address pointer from the address list cursor
    afs: Allow dumping of server cursor on operation failure
    afs: Implement YFS support in the fs client
    afs: Expand data structure fields to support YFS
    afs: Get the target vnode in afs_rmdir() and get a callback on it
    afs: Calc callback expiry in op reply delivery
    afs: Fix FS.FetchStatus delivery from updating wrong vnode
    afs: Implement the YFS cache manager service
    afs: Remove callback details from afs_callback_break struct
    afs: Commit the status on a new file/dir/symlink
    afs: Increase to 64-bit volume ID and 96-bit vnode ID for YFS
    afs: Don't invoke the server to read data beyond EOF
    afs: Add a couple of tracepoints to log I/O errors
    afs: Handle EIO from delivery function
    afs: Fix TTL on VL server and address lists
    afs: Implement VL server rotation
    afs: Improve FS server rotation error handling
    ...

    Linus Torvalds
     

24 Oct, 2018

1 commit

  • In the iov_iter struct, separate the iterator type from the iterator
    direction and use accessor functions to access them in most places.

    Convert a bunch of places to use switch-statements to access them rather
    then chains of bitwise-AND statements. This makes it easier to add further
    iterator types. Also, this can be more efficient as to implement a switch
    of small contiguous integers, the compiler can use ~50% fewer compare
    instructions than it has to use bitwise-and instructions.

    Further, cease passing the iterator type into the iterator setup function.
    The iterator function can set that itself. Only the direction is required.

    Signed-off-by: David Howells

    David Howells
     

08 Sep, 2018

2 commits

  • the 9p client code overwrites our glock.client_id pointing to a static
    buffer by an allocated string holding the network provided value which
    we do not care about; free and reset the value as appropriate.

    This is almost identical to the leak in v9fs_file_getlock() fixed by
    Al Viro in commit ce85dd58ad5a6 ("9p: we are leaking glock.client_id
    in v9fs_file_getlock()"), which was returned as an error by a coverity
    false positive -- while we are here attempt to make the code slightly
    more robust to future change of the net/9p/client code and hopefully
    more clear to coverity that there is no problem.

    Link: http://lkml.kernel.org/r/1536339057-21974-5-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet

    Dominique Martinet
     
  • iattr is passed to v9fs_vfs_setattr_dotl which does send various
    values from iattr over the wire, even if it tells the server to
    only look at iattr.ia_valid fields this could leak some stack data.

    Link: http://lkml.kernel.org/r/1536339057-21974-2-git-send-email-asmadeus@codewreck.org
    Addresses-Coverity-ID: 1195601 ("Uninitalized scalar variable")
    Signed-off-by: Dominique Martinet

    Dominique Martinet