12 Oct, 2020

1 commit

  • In p9_fd_create_unix, checking is performed to see if the addr (passed
    as an argument) is NULL or not.
    However, no check is performed to see if addr is a valid address, i.e.,
    it doesn't entirely consist of only 0's.
    The initialization of sun_server.sun_path to be equal to this faulty
    addr value leads to an uninitialized variable, as detected by KMSAN.
    Checking for this (faulty addr) and returning a negative error number
    appropriately, resolves this issue.

    Link: http://lkml.kernel.org/r/20201012042404.2508-1-anant.thazhemadam@gmail.com
    Reported-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com
    Tested-by: syzbot+75d51fe5bf4ebe988518@syzkaller.appspotmail.com
    Signed-off-by: Anant Thazhemadam
    Signed-off-by: Dominique Martinet

    Anant Thazhemadam
     

09 Oct, 2020

1 commit

  • Fix follow warnings:
    [net/9p/trans_xen.c:454]: (warning) %u in format string (no. 1) requires
    'unsigned int' but the argument type is 'int'.
    [net/9p/trans_xen.c:460]: (warning) %u in format string (no. 1) requires
    'unsigned int' but the argument type is 'int'.

    Link: http://lkml.kernel.org/r/20201009080552.89918-1-yebin10@huawei.com
    Reported-by: Hulk Robot
    Signed-off-by: Ye Bin
    Signed-off-by: Dominique Martinet

    Ye Bin
     

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
     

15 Aug, 2020

1 commit

  • Pull 9p updates from Dominique Martinet:

    - some code cleanup

    - a couple of static analysis fixes

    - setattr: try to pick a fid associated with the file rather than the
    dentry, which might sometimes matter

    * tag '9p-for-5.9-rc1' of git://github.com/martinetd/linux:
    9p: Remove unneeded cast from memory allocation
    9p: remove unused code in 9p
    net/9p: Fix sparse endian warning in trans_fd.c
    9p: Fix memory leak in v9fs_mount
    9p: retrieve fid from file when file instance exist.

    Linus Torvalds
     

02 Aug, 2020

1 commit


19 Jul, 2020

3 commits

  • p9_read_work and p9_fd_cancelled may be called concurrently.
    In some cases, req->req_list may be deleted by both p9_read_work
    and p9_fd_cancelled.

    We can fix it by ignoring replies associated with a cancelled
    request and ignoring cancelled request if message has been received
    before lock.

    Link: http://lkml.kernel.org/r/20200612090833.36149-1-wanghai38@huawei.com
    Fixes: 60ff779c4abb ("9p: client: remove unused code and any reference to "cancelled" function")
    Cc: # v3.12+
    Reported-by: syzbot+77a25acfa0382e06ab23@syzkaller.appspotmail.com
    Signed-off-by: Wang Hai
    Signed-off-by: Dominique Martinet

    Wang Hai
     
  • Address sparse endian warning:
    net/9p/trans_fd.c:932:28: warning: incorrect type in assignment (different base types)
    net/9p/trans_fd.c:932:28: expected restricted __be32 [addressable] [assigned] [usertype] s_addr
    net/9p/trans_fd.c:932:28: got unsigned long

    Link: http://lkml.kernel.org/r/20200618183417.5423-1-alexander.kapshuk@gmail.com
    Signed-off-by: Alexander Kapshuk
    Signed-off-by: Dominique Martinet

    Alexander Kapshuk
     
  • p9_fd_open just fgets file descriptors passed in from userspace, but
    doesn't verify that they are valid for read or writing. This gets
    cought down in the VFS when actually attempting a read or write, but
    a new warning added in linux-next upsets syzcaller.

    Fix this by just verifying the fds early on.

    Link: http://lkml.kernel.org/r/20200710085722.435850-1-hch@lst.de
    Reported-by: syzbot+e6f77e16ff68b2434a2c@syzkaller.appspotmail.com
    Signed-off-by: Christoph Hellwig
    [Dominique: amend goto as per Doug Nazar's review]
    Signed-off-by: Dominique Martinet

    Christoph Hellwig
     

14 Jul, 2020

1 commit

  • Simple fixes which require no deep knowledge of the code.

    Cc: Eric Van Hensbergen
    Cc: Latchesar Ionkov
    Cc: Dominique Martinet
    Signed-off-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Andrew Lunn
     

21 Jun, 2020

1 commit

  • The user tool modinfo is used to get information on kernel modules, including a
    description where it is available.

    This patch adds a brief MODULE_DESCRIPTION to the following modules:

    9p
    drop_monitor
    esp4_offload
    esp6_offload
    fou
    fou6
    ila
    sch_fq
    sch_fq_codel
    sch_hhf

    Signed-off-by: Rob Gill
    Signed-off-by: David S. Miller

    Rob Gill
     

02 Jun, 2020

1 commit

  • Increase XEN_9PFS_RING_ORDER to 9 for performance reason. Order 9 is the
    max allowed by the protocol.

    We can't assume that all backends will support order 9. The xenstore
    property max-ring-page-order specifies the max order supported by the
    backend. We'll use max-ring-page-order for the size of the ring.

    This means that the size of the ring is not static
    (XEN_FLEX_RING_SIZE(9)) anymore. Change XEN_9PFS_RING_SIZE to take an
    argument and base the calculation on the order chosen at setup time.

    Finally, modify p9_xen_trans.maxsize to be divided by 4 compared to the
    original value. We need to divide it by 2 because we have two rings
    coming off the same order allocation: the in and out rings. This was a
    mistake in the original code. Also divide it further by 2 because we
    don't want a single request/reply to fill up the entire ring. There can
    be multiple requests/replies outstanding at any given time and if we use
    the full ring with one, we risk forcing the backend to wait for the
    client to read back more replies before continuing, which is not
    performant.

    Link: http://lkml.kernel.org/r/20200521193242.15953-1-sstabellini@kernel.org
    Signed-off-by: Stefano Stabellini
    Signed-off-by: Dominique Martinet

    Stefano Stabellini
     

27 Mar, 2020

1 commit

  • A user doesn't necessarily want to wait for all the requested data to
    be available, since the waiting time for each request is unbounded.

    The new method permits sending one read request at a time and getting
    the response ASAP, allowing to use 9pnet with synthetic file systems
    representing arbitrary data streams.

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

    Sergey Alirzaev
     

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

1 commit

  • The p9_tag_alloc() does not initialize the transport error t_err field.
    The struct p9_req_t *req is allocated and stored in a struct p9_client
    variable. The field t_err is never initialized before p9_conn_cancel()
    checks its value.

    KUMSAN(KernelUninitializedMemorySantizer, a new error detection tool)
    reports this bug.

    ==================================================================
    BUG: KUMSAN: use of uninitialized memory in p9_conn_cancel+0x2d9/0x3b0
    Read of size 4 at addr ffff88805f9b600c by task kworker/1:2/1216

    CPU: 1 PID: 1216 Comm: kworker/1:2 Not tainted 5.2.0-rc4+ #28
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
    Workqueue: events p9_write_work
    Call Trace:
    dump_stack+0x75/0xae
    __kumsan_report+0x17c/0x3e6
    kumsan_report+0xe/0x20
    p9_conn_cancel+0x2d9/0x3b0
    p9_write_work+0x183/0x4a0
    process_one_work+0x4d1/0x8c0
    worker_thread+0x6e/0x780
    kthread+0x1ca/0x1f0
    ret_from_fork+0x35/0x40

    Allocated by task 1979:
    save_stack+0x19/0x80
    __kumsan_kmalloc.constprop.3+0xbc/0x120
    kmem_cache_alloc+0xa7/0x170
    p9_client_prepare_req.part.9+0x3b/0x380
    p9_client_rpc+0x15e/0x880
    p9_client_create+0x3d0/0xac0
    v9fs_session_init+0x192/0xc80
    v9fs_mount+0x67/0x470
    legacy_get_tree+0x70/0xd0
    vfs_get_tree+0x4a/0x1c0
    do_mount+0xba9/0xf90
    ksys_mount+0xa8/0x120
    __x64_sys_mount+0x62/0x70
    do_syscall_64+0x6d/0x1e0
    entry_SYSCALL_64_after_hwframe+0x44/0xa9

    Freed by task 0:
    (stack is not available)

    The buggy address belongs to the object at ffff88805f9b6008
    which belongs to the cache p9_req_t of size 144
    The buggy address is located 4 bytes inside of
    144-byte region [ffff88805f9b6008, ffff88805f9b6098)
    The buggy address belongs to the page:
    page:ffffea00017e6d80 refcount:1 mapcount:0 mapping:ffff888068b63740 index:0xffff88805f9b7d90 compound_mapcount: 0
    flags: 0x100000000010200(slab|head)
    raw: 0100000000010200 ffff888068b66450 ffff888068b66450 ffff888068b63740
    raw: ffff88805f9b7d90 0000000000100001 00000001ffffffff 0000000000000000
    page dumped because: kumsan: bad access detected
    ==================================================================

    Link: http://lkml.kernel.org/r/20190613070854.10434-1-shuaibinglu@126.com
    Signed-off-by: Lu Shuaibing
    [dominique.martinet@cea.fr: grouped the added init with the others]
    Signed-off-by: Dominique Martinet

    Lu Shuaibing
     

05 Aug, 2019

1 commit

  • Send and Receive completion is handled on a single CPU selected at
    the time each Completion Queue is allocated. Typically this is when
    an initiator instantiates an RDMA transport, or when a target
    accepts an RDMA connection.

    Some ULPs cannot open a connection per CPU to spread completion
    workload across available CPUs and MSI vectors. For such ULPs,
    provide an API that allows the RDMA core to select a completion
    vector based on the device's complement of available comp_vecs.

    ULPs that invoke ib_alloc_cq() with only comp_vector 0 are converted
    to use the new API so that their completion workloads interfere less
    with each other.

    Suggested-by: Håkon Bugge
    Signed-off-by: Chuck Lever
    Reviewed-by: Leon Romanovsky
    Cc:
    Cc:
    Link: https://lore.kernel.org/r/20190729171923.13428.52555.stgit@manet.1015granger.net
    Signed-off-by: Doug Ledford

    Chuck Lever
     

13 Jul, 2019

1 commit

  • Pull 9p updates from Dominique Martinet:
    "Two small fixes to properly cleanup the 9p transports list if
    virtio/xen module initialization fail.

    9p might otherwise try to access memory from a module that failed to
    register got freed"

    * tag '9p-for-5.3' of git://github.com/martinetd/linux:
    9p/xen: Add cleanup path in p9_trans_xen_init
    9p/virtio: Add cleanup path in p9_virtio_init

    Linus Torvalds
     

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


15 May, 2019

2 commits

  • If xenbus_register_frontend() fails in p9_trans_xen_init,
    we should call v9fs_unregister_trans() to do cleanup.

    Link: http://lkml.kernel.org/r/20190430143933.19368-1-yuehaibing@huawei.com
    Cc: stable@vger.kernel.org
    Fixes: 868eb122739a ("xen/9pfs: introduce Xen 9pfs transport driver")
    Signed-off-by: YueHaibing
    Signed-off-by: Dominique Martinet

    YueHaibing
     
  • KASAN report this:

    BUG: unable to handle kernel paging request at ffffffffa0097000
    PGD 3870067 P4D 3870067 PUD 3871063 PMD 2326e2067 PTE 0
    Oops: 0000 [#1
    CPU: 0 PID: 5340 Comm: modprobe Not tainted 5.1.0-rc7+ #25
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
    RIP: 0010:__list_add_valid+0x10/0x70
    Code: c3 48 8b 06 55 48 89 e5 5d 48 39 07 0f 94 c0 0f b6 c0 c3 90 90 90 90 90 90 90 55 48 89 d0 48 8b 52 08 48 89 e5 48 39 f2 75 19 8b 32 48 39 f0 75 3a

    RSP: 0018:ffffc90000e23c68 EFLAGS: 00010246
    RAX: ffffffffa00ad000 RBX: ffffffffa009d000 RCX: 0000000000000000
    RDX: ffffffffa0097000 RSI: ffffffffa0097000 RDI: ffffffffa009d000
    RBP: ffffc90000e23c68 R08: 0000000000000001 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa0097000
    R13: ffff888231797180 R14: 0000000000000000 R15: ffffc90000e23e78
    FS: 00007fb215285540(0000) GS:ffff888237a00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: ffffffffa0097000 CR3: 000000022f144000 CR4: 00000000000006f0
    Call Trace:
    v9fs_register_trans+0x2f/0x60 [9pnet
    ? 0xffffffffa0087000
    p9_virtio_init+0x25/0x1000 [9pnet_virtio
    do_one_initcall+0x6c/0x3cc
    ? kmem_cache_alloc_trace+0x248/0x3b0
    do_init_module+0x5b/0x1f1
    load_module+0x1db1/0x2690
    ? m_show+0x1d0/0x1d0
    __do_sys_finit_module+0xc5/0xd0
    __x64_sys_finit_module+0x15/0x20
    do_syscall_64+0x6b/0x1d0
    entry_SYSCALL_64_after_hwframe+0x49/0xbe
    RIP: 0033:0x7fb214d8e839
    Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 3d 01 f0 ff ff 73 01

    RSP: 002b:00007ffc96554278 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
    RAX: ffffffffffffffda RBX: 000055e67eed2aa0 RCX: 00007fb214d8e839
    RDX: 0000000000000000 RSI: 000055e67ce95c2e RDI: 0000000000000003
    RBP: 000055e67ce95c2e R08: 0000000000000000 R09: 000055e67eed2aa0
    R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000
    R13: 000055e67eeda500 R14: 0000000000040000 R15: 000055e67eed2aa0
    Modules linked in: 9pnet_virtio(+) 9pnet gre rfkill vmw_vsock_virtio_transport_common vsock [last unloaded: 9pnet_virtio
    CR2: ffffffffa0097000
    ---[ end trace 4a52bb13ff07b761

    If register_virtio_driver() fails in p9_virtio_init,
    we should call v9fs_unregister_trans() to do cleanup.

    Link: http://lkml.kernel.org/r/20190430115942.41840-1-yuehaibing@huawei.com
    Cc: stable@vger.kernel.org
    Reported-by: Hulk Robot
    Fixes: b530cc794024 ("9p: add virtio transport")
    Signed-off-by: YueHaibing
    Signed-off-by: Dominique Martinet

    YueHaibing
     

13 Mar, 2019

1 commit

  • If msize is less than 4096, we should close and put trans, destroy
    tagpool, not just free client. This patch fixes that.

    Link: http://lkml.kernel.org/m/1552464097-142659-1-git-send-email-zhengbin13@huawei.com
    Cc: stable@vger.kernel.org
    Fixes: 574d356b7a02 ("9p/net: put a lower bound on msize")
    Reported-by: Hulk Robot
    Signed-off-by: zhengbin
    Signed-off-by: Dominique Martinet

    zhengbin
     

23 Jan, 2019

1 commit

  • In preparation to enabling -Wimplicit-fallthrough, mark switch cases
    where we are expecting to fall through.

    This patch fixes the following warning:

    net/9p/trans_xen.c:514:6: warning: this statement may fall through [-Wimplicit-fallthrough=]

    Warning level 3 was used: -Wimplicit-fallthrough=3

    This patch is part of the ongoing efforts to enabling
    -Wimplicit-fallthrough

    Link: http://lkml.kernel.org/r/20190123071632.GA8039@embeddedor
    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Dominique Martinet

    Gustavo A. R. Silva
     

25 Dec, 2018

1 commit

  • If the requested msize is too small (either from command line argument
    or from the server version reply), we won't get any work done.
    If it's *really* too small, nothing will work, and this got caught by
    syzbot recently (on a new kmem_cache_create_usercopy() call)

    Just set a minimum msize to 4k in both code paths, until someone
    complains they have a use-case for a smaller msize.

    We need to check in both mount option and server reply individually
    because the msize for the first version request would be unchecked
    with just a global check on clnt->msize.

    Link: http://lkml.kernel.org/r/1541407968-31350-1-git-send-email-asmadeus@codewreck.org
    Reported-by: syzbot+0c1d61e4db7db94102ca@syzkaller.appspotmail.com
    Signed-off-by: Dominique Martinet
    Cc: Eric Van Hensbergen
    Cc: Latchesar Ionkov
    Cc: stable@vger.kernel.org

    Dominique Martinet
     

20 Nov, 2018

1 commit


04 Nov, 2018

1 commit


03 Nov, 2018

1 commit

  • When switching to the new iovec accessors, a negation got subtly
    dropped, leading to 9p being remarkably broken (here with kvmtool):

    [ 7.430941] VFS: Mounted root (9p filesystem) on device 0:15.
    [ 7.432080] devtmpfs: mounted
    [ 7.432717] Freeing unused kernel memory: 1344K
    [ 7.433658] Run /virt/init as init process
    Warning: unable to translate guest address 0x7e00902ff000 to host
    Warning: unable to translate guest address 0x7e00902fefc0 to host
    Warning: unable to translate guest address 0x7e00902ff000 to host
    Warning: unable to translate guest address 0x7e008febef80 to host
    Warning: unable to translate guest address 0x7e008febf000 to host
    Warning: unable to translate guest address 0x7e008febef00 to host
    Warning: unable to translate guest address 0x7e008febf000 to host
    [ 7.436376] Kernel panic - not syncing: Requested init /virt/init failed (error -8).
    [ 7.437554] CPU: 29 PID: 1 Comm: swapper/0 Not tainted 4.19.0-rc8-02267-g00e23707442a #291
    [ 7.439006] Hardware name: linux,dummy-virt (DT)
    [ 7.439902] Call trace:
    [ 7.440387] dump_backtrace+0x0/0x148
    [ 7.441104] show_stack+0x14/0x20
    [ 7.441768] dump_stack+0x90/0xb4
    [ 7.442425] panic+0x120/0x27c
    [ 7.443036] kernel_init+0xa4/0x100
    [ 7.443725] ret_from_fork+0x10/0x18
    [ 7.444444] SMP: stopping secondary CPUs
    [ 7.445391] Kernel Offset: disabled
    [ 7.446169] CPU features: 0x0,23000438
    [ 7.446974] Memory Limit: none
    [ 7.447645] ---[ end Kernel panic - not syncing: Requested init /virt/init failed (error -8). ]---

    Restoring the missing "!" brings the guest back to life.

    Fixes: 00e23707442a ("iov_iter: Use accessor function")
    Reported-by: Will Deacon
    Signed-off-by: Marc Zyngier
    Signed-off-by: Al Viro

    Marc Zyngier
     

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

2 commits

  • 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
     
  • Use accessor functions to access an iterator's type and direction. This
    allows for the possibility of using some other method of determining the
    type of iterator than if-chains with bitwise-AND conditions.

    Signed-off-by: David Howells

    David Howells
     

10 Oct, 2018

3 commits

  • p9_read_work/p9_write_work might still hold references to a req after
    having been cancelled; make sure we put any of these to avoid potential
    request leak on disconnect.

    Fixes: 728356dedeff8 ("9p: Add refcount to p9_req_t")
    Link: http://lkml.kernel.org/r/1539057956-23741-2-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet
    Cc: Eric Van Hensbergen
    Cc: Latchesar Ionkov
    Reviewed-by: Tomas Bortoli

    Dominique Martinet
     
  • p9_read_work would try to handle an errored req even if it got put to
    error state by another thread between the lookup (that worked) and the
    time it had been fully read.
    The request itself is safe to use because we hold a ref to it from the
    lookup (for m->rreq, so it was safe to read into the request data buffer
    until this point), but the req_list has been deleted at the same time
    status changed, and client_cb already has been called as well, so we
    should not do either.

    Link: http://lkml.kernel.org/r/1539057956-23741-1-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet
    Reported-by: syzbot+2222c34dc40b515f30dc@syzkaller.appspotmail.com
    Cc: Eric Van Hensbergen
    Cc: Latchesar Ionkov

    Dominique Martinet
     
  • p9_tag_alloc() is supposed to return error pointers, but we accidentally
    return a NULL here. It would cause a NULL dereference in the caller.

    Link: http://lkml.kernel.org/m/20180926103934.GA14535@mwanda
    Fixes: 996d5b4db4b1 ("9p: Use a slab for allocating requests")
    Signed-off-by: Dan Carpenter
    Signed-off-by: Dominique Martinet

    Dan Carpenter
     

08 Sep, 2018

8 commits

  • strcpy to dirent->d_name could overflow the buffer, use strscpy to check
    the provided string length and error out if the size was too big.

    While we are here, make the function return an error when the pdu
    parsing failed, instead of returning the pdu offset as if it had been a
    success...

    Link: http://lkml.kernel.org/r/1536339057-21974-4-git-send-email-asmadeus@codewreck.org
    Addresses-Coverity-ID: 139133 ("Copy into fixed size buffer")
    Signed-off-by: Dominique Martinet

    Dominique Martinet
     
  • the client c is always dereferenced to get the rdma struct, so c has to
    be a valid pointer at this point.
    Gcc would optimize that away but let's make coverity happy...

    Link: http://lkml.kernel.org/r/1536339057-21974-3-git-send-email-asmadeus@codewreck.org
    Addresses-Coverity-ID: 102778 ("Dereference before null check")
    Signed-off-by: Dominique Martinet

    Dominique Martinet
     
  • v9fs_dir_readdir() could deadloop if a struct was sent with a size set
    to -2

    Link: http://lkml.kernel.org/r/1536134432-11997-1-git-send-email-asmadeus@codewreck.org
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88021
    Signed-off-by: Gertjan Halkes
    Signed-off-by: Dominique Martinet

    Gertjan Halkes
     
  • In struct p9_conn, rename req to rreq as it is used by the read routine.

    Link: http://lkml.kernel.org/r/20180903160321.2181-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Suggested-by: Jun Piao
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • 9p/rdma would sometimes drop the connection and display errors in
    recv_done when the user does ^C.
    The errors were caused by recv buffers that were posted at the time
    of disconnect, and we just do not want to disconnect when
    down_interruptible is... interrupted.

    Link: http://lkml.kernel.org/r/1535625307-18019-1-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet

    Dominique Martinet
     
  • To avoid use-after-free(s), use a refcount to keep track of the
    usable references to any instantiated struct p9_req_t.

    This commit adds p9_req_put(), p9_req_get() and p9_req_try_get() as
    wrappers to kref_put(), kref_get() and kref_get_unless_zero().
    These are used by the client and the transports to keep track of
    valid requests' references.

    p9_free_req() is added back and used as callback by kref_put().

    Add SLAB_TYPESAFE_BY_RCU as it ensures that the memory freed by
    kmem_cache_free() will not be reused for another type until the rcu
    synchronisation period is over, so an address gotten under rcu read
    lock is safe to inc_ref() without corrupting random memory while
    the lock is held.

    Link: http://lkml.kernel.org/r/1535626341-20693-1-git-send-email-asmadeus@codewreck.org
    Co-developed-by: Dominique Martinet
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+467050c1ce275af2a5b8@syzkaller.appspotmail.com
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • In sight of the next patch to add a refcount in p9_req_t, rename
    the p9_free_req() function in p9_release_req().

    In the next patch the actual kfree will be moved to another function.

    Link: http://lkml.kernel.org/r/20180811144254.23665-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Acked-by: Jun Piao
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • Having a specific cache for the fcall allocations helps speed up
    end-to-end latency.

    The caches will automatically be merged if there are multiple caches
    of items with the same size so we do not need to try to share a cache
    between different clients of the same size.

    Since the msize is negotiated with the server, only allocate the cache
    after that negotiation has happened - previous allocations or
    allocations of different sizes (e.g. zero-copy fcall) are made with
    kmalloc directly.

    Some figures on two beefy VMs with Connect-IB (sriov) / trans=rdma,
    with ior running 32 processes in parallel doing small 32 bytes IOs:
    - no alloc (4.18-rc7 request cache): 65.4k req/s
    - non-power of two alloc, no patch: 61.6k req/s
    - power of two alloc, no patch: 62.2k req/s
    - non-power of two alloc, with patch: 64.7k req/s
    - power of two alloc, with patch: 65.1k req/s

    Link: http://lkml.kernel.org/r/1532943263-24378-2-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet
    Acked-by: Jun Piao
    Cc: Matthew Wilcox
    Cc: Greg Kurz

    Dominique Martinet