13 Jan, 2019

1 commit

  • commit 574d356b7a02c7e1b01a1d9cba8a26b3c2888f45 upstream.

    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
    Signed-off-by: Greg Kroah-Hartman

    Dominique Martinet
     

21 Nov, 2018

1 commit

  • [ Upstream commit 62e3941776fea8678bb8120607039410b1b61a65 ]

    p9stat_free is more of a cleanup function than a 'free' function as it
    only frees the content of the struct; there are chances of use-after-free
    if it is improperly used (e.g. p9stat_free called twice as it used to be
    possible to)

    Clearing dangling pointers makes the function idempotent and safer to use.

    Link: http://lkml.kernel.org/r/1535410108-20650-2-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet
    Reported-by: syzbot+d4252148d198410b864f@syzkaller.appspotmail.com
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Dominique Martinet
     

15 Sep, 2018

2 commits

  • [ Upstream commit 92aef4675d5b1b55404e1532379e343bed0e5cf2 ]

    Currently when virtio_find_single_vq fails, we go through del_vqs which
    throws a warning (Trying to free already-free IRQ). Skip del_vqs if vq
    allocation failed.

    Link: http://lkml.kernel.org/r/20180524101021.49880-1-jean-philippe.brucker@arm.com
    Signed-off-by: Jean-Philippe Brucker
    Reviewed-by: Greg Kurz
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Signed-off-by: Dominique Martinet
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jean-Philippe Brucker
     
  • [ Upstream commit 9f476d7c540cb57556d3cc7e78704e6cd5100f5f ]

    It may be possible to run p9_fd_cancel() with a deleted req->req_list
    and incur in a double del. To fix hold the client->lock while changing
    the status, so the other threads will be synchronized.

    Link: http://lkml.kernel.org/r/20180723184253.6682-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+735d926e9d1317c3310c@syzkaller.appspotmail.com
    To: Eric Van Hensbergen
    To: Ron Minnich
    To: Latchesar Ionkov
    Cc: Yiwen Jiang
    Cc: David S. Miller
    Signed-off-by: Dominique Martinet
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Tomas Bortoli
     

10 Sep, 2018

5 commits

  • commit 430ac66eb4c5b5c4eb846b78ebf65747510b30f1 upstream.

    The patch adds the flush in p9_mux_poll_stop() as it the function used by
    p9_conn_destroy(), in turn called by p9_fd_close() to stop the async
    polling associated with the data regarding the connection.

    Link: http://lkml.kernel.org/r/20180720092730.27104-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+39749ed7d9ef6dfb23f6@syzkaller.appspotmail.com
    To: Eric Van Hensbergen
    To: Ron Minnich
    To: Latchesar Ionkov
    Cc: Yiwen Jiang
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet
    Signed-off-by: Greg Kroah-Hartman

    Tomas Bortoli
     
  • commit 7913690dcc5e18e235769fd87c34143072f5dbea upstream.

    The p9_client_version() does not initialize the version pointer. If the
    call to p9pdu_readf() returns an error and version has not been allocated
    in p9pdu_readf(), then the program will jump to the "error" label and will
    try to free the version pointer. If version is not initialized, free()
    will be called with uninitialized, garbage data and will provoke a crash.

    Link: http://lkml.kernel.org/r/20180709222943.19503-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+65c6b72f284a39d416b4@syzkaller.appspotmail.com
    Reviewed-by: Jun Piao
    Reviewed-by: Yiwen Jiang
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet
    Signed-off-by: Greg Kroah-Hartman

    Tomas Bortoli
     
  • commit 23cba9cbde0bba05d772b335fe5f66aa82b9ad19 upstream.

    Because the value of limit is VIRTQUEUE_NUM, if index is equal to
    limit, it will cause sg array out of bounds, so correct the judgement
    of BUG_ON.

    Link: http://lkml.kernel.org/r/5B63D5F6.6080109@huawei.com
    Signed-off-by: Yiwen Jiang
    Reported-By: Dan Carpenter
    Acked-by: Jun Piao
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet
    Signed-off-by: Greg Kroah-Hartman

    jiangyiwen
     
  • commit 10aa14527f458e9867cf3d2cc6b8cb0f6704448b upstream.

    Added checks to prevent GPFs from raising.

    Link: http://lkml.kernel.org/r/20180727110558.5479-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+1a262da37d3bead15c39@syzkaller.appspotmail.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet
    Signed-off-by: Greg Kroah-Hartman

    Tomas Bortoli
     
  • commit d28c756caee6e414d9ba367d0b92da24145af2a8 upstream.

    The zero-copy optimization when reading or writing large chunks of data
    is quite useful. However, the 9p messages created through the zero-copy
    write path have an incorrect message size: it should be the size of the
    header + size of the data being written but instead it's just the size
    of the header.

    This only works if the server ignores the size field of the message and
    otherwise breaks the framing of the protocol. Fix this by re-writing the
    message size field with the correct value.

    Tested by running `dd if=/dev/zero of=out bs=4k count=1` inside a
    virtio-9p mount.

    Link: http://lkml.kernel.org/r/20180717003529.114368-1-chirantan@chromium.org
    Signed-off-by: Chirantan Ekbote
    Reviewed-by: Greg Kurz
    Tested-by: Greg Kurz
    Cc: Dylan Reid
    Cc: Guenter Roeck
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet
    Signed-off-by: Greg Kroah-Hartman

    Chirantan Ekbote
     

22 Feb, 2018

1 commit

  • commit 26d99834f89e76514076d9cd06f61e56e6a509b8 upstream.

    When a 9p request is successfully flushed, the server is expected to just
    mark it as used without sending a 9p reply (ie, without writing data into
    the buffer). In this case, virtqueue_get_buf() will return len == 0 and
    we must not report a REQ_STATUS_RCVD status to the client, otherwise the
    client will erroneously assume the request has not been flushed.

    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kurz
    Signed-off-by: Michael S. Tsirkin
    Signed-off-by: Greg Kroah-Hartman

    Greg Kurz
     

30 Nov, 2017

2 commits

  • commit 9523feac272ccad2ad8186ba4fcc89103754de52 upstream.

    Because userspace gets Very Unhappy when calls like stat() and execve()
    return -EINTR on 9p filesystem mounts. For instance, when bash is
    looking in PATH for things to execute and some SIGCHLD interrupts
    stat(), bash can throw a spurious 'command not found' since it doesn't
    retry the stat().

    In practice, hitting the problem is rare and needs a really
    slow/bogged down 9p server.

    Signed-off-by: Tuomas Tynkkynen
    Signed-off-by: Al Viro
    Signed-off-by: Greg Kroah-Hartman

    Tuomas Tynkkynen
     
  • commit 61b272c3aa170b3e461b8df636407b29f35f98eb upstream.

    Since commit c4fac9100456 ("9p: Implement show_options"), the mount
    options of 9p filesystems are printed out with some missing commas
    between the individual options:

    p9-scratch on /mnt/scratch type 9p (rw,dirsync,loose,access=clienttrans=virtio)

    Add them back.

    Fixes: c4fac9100456 ("9p: Implement show_options")
    Signed-off-by: Tuomas Tynkkynen
    Signed-off-by: Al Viro
    Signed-off-by: Greg Kroah-Hartman

    Tuomas Tynkkynen
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

05 Sep, 2017

2 commits


16 Jul, 2017

1 commit

  • Pull ->s_options removal from Al Viro:
    "Preparations for fsmount/fsopen stuff (coming next cycle). Everything
    gets moved to explicit ->show_options(), killing ->s_options off +
    some cosmetic bits around fs/namespace.c and friends. Basically, the
    stuff needed to work with fsmount series with minimum of conflicts
    with other work.

    It's not strictly required for this merge window, but it would reduce
    the PITA during the coming cycle, so it would be nice to have those
    bits and pieces out of the way"

    * 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    isofs: Fix isofs_show_options()
    VFS: Kill off s_options and helpers
    orangefs: Implement show_options
    9p: Implement show_options
    isofs: Implement show_options
    afs: Implement show_options
    affs: Implement show_options
    befs: Implement show_options
    spufs: Implement show_options
    bpf: Implement show_options
    ramfs: Implement show_options
    pstore: Implement show_options
    omfs: Implement show_options
    hugetlbfs: Implement show_options
    VFS: Don't use save/replace_mount_options if not using generic_show_options
    VFS: Provide empty name qstr
    VFS: Make get_filesystem() return the affected filesystem
    VFS: Clean up whitespace in fs/namespace.c and fs/super.c
    Provide a function to create a NUL-terminated string from unterminated data

    Linus Torvalds
     

11 Jul, 2017

1 commit

  • Implement the show_options superblock op for 9p as part of a bid to get
    rid of s_options and generic_show_options() to make it easier to implement
    a context-based mount where the mount options can be passed individually
    over a file descriptor.

    Signed-off-by: David Howells
    cc: Eric Van Hensbergen
    cc: Ron Minnich
    cc: Latchesar Ionkov
    cc: v9fs-developer@lists.sourceforge.net
    Signed-off-by: Al Viro

    David Howells
     

20 Jun, 2017

1 commit

  • Rename:

    wait_queue_t => wait_queue_entry_t

    'wait_queue_t' was always a slight misnomer: its name implies that it's a "queue",
    but in reality it's a queue *entry*. The 'real' queue is the wait queue head,
    which had to carry the name.

    Start sorting this out by renaming it to 'wait_queue_entry_t'.

    This also allows the real structure name 'struct __wait_queue' to
    lose its double underscore and become 'struct wait_queue_entry',
    which is the more canonical nomenclature for such data types.

    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

20 May, 2017

1 commit


19 May, 2017

2 commits


05 May, 2017

1 commit

  • Pull xen updates from Juergen Gross:
    "Xen fixes and featrues for 4.12. The main changes are:

    - enable building the kernel with Xen support but without enabling
    paravirtualized mode (Vitaly Kuznetsov)

    - add a new 9pfs xen frontend driver (Stefano Stabellini)

    - simplify Xen's cpuid handling by making use of cpu capabilities
    (Juergen Gross)

    - add/modify some headers for new Xen paravirtualized devices
    (Oleksandr Andrushchenko)

    - EFI reset_system support under Xen (Julien Grall)

    - and the usual cleanups and corrections"

    * tag 'for-linus-4.12b-rc0b-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: (57 commits)
    xen: Move xen_have_vector_callback definition to enlighten.c
    xen: Implement EFI reset_system callback
    arm/xen: Consolidate calls to shutdown hypercall in a single helper
    xen: Export xen_reboot
    xen/x86: Call xen_smp_intr_init_pv() on BSP
    xen: Revert commits da72ff5bfcb0 and 72a9b186292d
    xen/pvh: Do not fill kernel's e820 map in init_pvh_bootparams()
    xen/scsifront: use offset_in_page() macro
    xen/arm,arm64: rename __generic_dma_ops to xen_get_dma_ops
    xen/arm,arm64: fix xen_dma_ops after 815dd18 "Consolidate get_dma_ops..."
    xen/9pfs: select CONFIG_XEN_XENBUS_FRONTEND
    x86/cpu: remove hypervisor specific set_cpu_features
    vmware: set cpu capabilities during platform initialization
    x86/xen: use capabilities instead of fake cpuid values for xsave
    x86/xen: use capabilities instead of fake cpuid values for x2apic
    x86/xen: use capabilities instead of fake cpuid values for mwait
    x86/xen: use capabilities instead of fake cpuid values for acpi
    x86/xen: use capabilities instead of fake cpuid values for acc
    x86/xen: use capabilities instead of fake cpuid values for mtrr
    x86/xen: use capabilities instead of fake cpuid values for aperf
    ...

    Linus Torvalds
     

02 May, 2017

7 commits

  • All Xen frontends need to select this symbol to avoid a link error:

    net/built-in.o: In function `p9_trans_xen_init':
    :(.text+0x149e9c): undefined reference to `__xenbus_register_frontend'

    Fixes: d4b40a02f837 ("xen/9pfs: build 9pfs Xen transport driver")
    Signed-off-by: Arnd Bergmann
    Reviewed-by: Stefano Stabellini

    Arnd Bergmann
     
  • In order to use "len" to check for xenbus_read errors properly, we need
    to initialize len to 0 before passing it to xenbus_read.

    CC: dan.carpenter@oracle.com
    CC: jgross@suse.com
    CC: boris.ostrovsky@oracle.com
    CC: Eric Van Hensbergen
    CC: Ron Minnich
    CC: Latchesar Ionkov
    CC: v9fs-developer@lists.sourceforge.net
    Signed-off-by: Stefano Stabellini
    Reviewed-by: Juergen Gross
    Signed-off-by: Juergen Gross

    Stefano Stabellini
     
  • This patch adds a Kconfig option and Makefile support for building the
    9pfs Xen driver.

    CC: groug@kaod.org
    CC: boris.ostrovsky@oracle.com
    CC: jgross@suse.com
    CC: Eric Van Hensbergen
    CC: Ron Minnich
    CC: Latchesar Ionkov
    CC: v9fs-developer@lists.sourceforge.net

    Signed-off-by: Stefano Stabellini
    Reviewed-by: Juergen Gross
    Signed-off-by: Juergen Gross

    Stefano Stabellini
     
  • Upon receiving a notification from the backend, schedule the
    p9_xen_response work_struct. p9_xen_response checks if any responses are
    available, if so, it reads them one by one, calling p9_client_cb to send
    them up to the 9p layer (p9_client_cb completes the request). Handle the
    ring following the Xen 9pfs specification.

    CC: groug@kaod.org
    CC: jgross@suse.com
    CC: Eric Van Hensbergen
    CC: Ron Minnich
    CC: Latchesar Ionkov
    CC: v9fs-developer@lists.sourceforge.net

    Signed-off-by: Stefano Stabellini
    Reviewed-by: Boris Ostrovsky
    Reviewed-by: Juergen Gross
    Signed-off-by: Juergen Gross

    Stefano Stabellini
     
  • Implement struct p9_trans_module create and close functions by looking
    at the available Xen 9pfs frontend-backend connections. We don't expect
    many frontend-backend connections, thus walking a list is OK.

    Send requests to the backend by copying each request to one of the
    available rings (each frontend-backend connection comes with multiple
    rings). Handle the ring and notifications following the 9pfs
    specification. If there are not enough free bytes on the ring for the
    request, wait on the wait_queue: the backend will send a notification
    after consuming more requests.

    CC: groug@kaod.org
    CC: jgross@suse.com
    CC: Eric Van Hensbergen
    CC: Ron Minnich
    CC: Latchesar Ionkov
    CC: v9fs-developer@lists.sourceforge.net

    Signed-off-by: Stefano Stabellini
    Reviewed-by: Boris Ostrovsky
    Reviewed-by: Juergen Gross
    Signed-off-by: Juergen Gross

    Stefano Stabellini
     
  • Implement functions to handle the xenbus handshake. Upon connection,
    allocate the rings according to the protocol specification.

    Initialize a work_struct and a wait_queue. The work_struct will be used
    to schedule work upon receiving an event channel notification from the
    backend. The wait_queue will be used to wait when the ring is full and
    we need to send a new request.

    CC: groug@kaod.org
    CC: boris.ostrovsky@oracle.com
    CC: jgross@suse.com
    CC: Eric Van Hensbergen
    CC: Ron Minnich
    CC: Latchesar Ionkov
    CC: v9fs-developer@lists.sourceforge.net

    Signed-off-by: Stefano Stabellini
    Reviewed-by: Juergen Gross
    Signed-off-by: Juergen Gross

    Stefano Stabellini
     
  • Introduce the Xen 9pfs transport driver: add struct xenbus_driver to
    register as a xenbus driver and add struct p9_trans_module to register
    as v9fs driver.

    All functions are empty stubs for now.

    CC: groug@kaod.org
    CC: jgross@suse.com
    CC: Eric Van Hensbergen
    CC: Ron Minnich
    CC: Latchesar Ionkov
    CC: v9fs-developer@lists.sourceforge.net

    Signed-off-by: Stefano Stabellini
    Reviewed-by: Boris Ostrovsky
    Reviewed-by: Juergen Gross
    Signed-off-by: Juergen Gross

    Stefano Stabellini
     

22 Apr, 2017

1 commit


18 Apr, 2017

1 commit


04 Mar, 2017

1 commit


02 Mar, 2017

1 commit


12 Jan, 2017

1 commit


24 Sep, 2016

1 commit

  • Instead of exposing ib_get_dma_mr to ULPs and letting them use it more or
    less unchecked, this moves the capability of creating a global rkey into
    the RDMA core, where it can be easily audited. It also prints a warning
    everytime this feature is used as well.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Sagi Grimberg
    Reviewed-by: Jason Gunthorpe
    Reviewed-by: Steve Wise
    Signed-off-by: Doug Ledford

    Christoph Hellwig
     

09 Aug, 2016

1 commit

  • The memory allocated by iov_iter_get_pages_alloc() can be allocated with
    vmalloc() if kmalloc() failed -- see get_pages_array().

    In that case we need to free it with vfree(), so let's use kvfree().

    The bug manifests like this:

    BUG: unable to handle kernel paging request at ffffeb0400072da0
    IP: [] kfree+0x4b/0x140
    PGD 0
    Oops: 0000 [#1] PREEMPT SMP KASAN
    CPU: 2 PID: 675 Comm: trinity-c2 Not tainted 4.7.0-rc7+ #14
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
    task: ffff8800badef2c0 ti: ffff880069208000 task.ti: ffff880069208000
    RIP: 0010:[] [] kfree+0x4b/0x140
    RSP: 0000:ffff88006920f3f0 EFLAGS: 00010282
    RAX: ffffea0000000000 RBX: ffffc90001cb6000 RCX: 0000000000000000
    RDX: 0000000000000001 RSI: 0000000000000246 RDI: ffffc90001cb6000
    RBP: ffff88006920f410 R08: 0000000000000000 R09: dffffc0000000000
    R10: ffff8800badefa30 R11: 0000056a3d3b0d9f R12: ffff88006920f620
    R13: ffffeb0400072d80 R14: ffff8800baa94078 R15: 0000000000000000
    FS: 00007fbd2b437700(0000) GS:ffff88011af00000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: ffffeb0400072da0 CR3: 000000006926d000 CR4: 00000000000006e0
    Stack:
    0000000000000001 ffff88006920f620 ffffed001755280f ffff8800baa94078
    ffff88006920f6a8 ffffffff8310442b dffffc0000000000 ffff8800badefa30
    ffff8800badefa28 ffff88011af1fba0 1ffff1000d241e98 ffff8800ba892150
    Call Trace:
    [] p9_virtio_zc_request+0x72b/0xdb0
    [] p9_client_zc_rpc.constprop.8+0x246/0xb10
    [] p9_client_read+0x4c9/0x750
    [] v9fs_fid_readpage+0x14c/0x320
    [] v9fs_vfs_readpage+0x36/0x50
    [] filemap_fault+0x9a3/0xe60
    [] __do_fault+0x158/0x300
    [] handle_mm_fault+0x1cf1/0x3c80
    [] __do_page_fault+0x30a/0x8e0
    [] do_page_fault+0x2f/0x80
    [] do_async_page_fault+0x27/0xa0
    [] async_page_fault+0x28/0x30
    Code: 00 80 41 54 53 49 01 fd 48 0f 42 05 b0 39 67 02 48 89 fb 49 01 c5 48 b8 00 00 00 00 00 ea ff ff 49 c1 ed 0c 49 c1 e5 06 49 01 c5 8b 45 20 48 8d 50 ff a8 01 4c 0f 45 ea 49 8b 55 20 48 8d 42
    RIP [] kfree+0x4b/0x140
    RSP
    CR2: ffffeb0400072da0
    ---[ end trace f3d59a04bafec038 ]---

    Cc: Al Viro
    Signed-off-by: Vegard Nossum
    Signed-off-by: Michael S. Tsirkin

    Vegard Nossum
     

28 May, 2016

1 commit

  • Most users of IS_ERR_VALUE() in the kernel are wrong, as they
    pass an 'int' into a function that takes an 'unsigned long'
    argument. This happens to work because the type is sign-extended
    on 64-bit architectures before it gets converted into an
    unsigned type.

    However, anything that passes an 'unsigned short' or 'unsigned int'
    argument into IS_ERR_VALUE() is guaranteed to be broken, as are
    8-bit integers and types that are wider than 'unsigned long'.

    Andrzej Hajda has already fixed a lot of the worst abusers that
    were causing actual bugs, but it would be nice to prevent any
    users that are not passing 'unsigned long' arguments.

    This patch changes all users of IS_ERR_VALUE() that I could find
    on 32-bit ARM randconfig builds and x86 allmodconfig. For the
    moment, this doesn't change the definition of IS_ERR_VALUE()
    because there are probably still architecture specific users
    elsewhere.

    Almost all the warnings I got are for files that are better off
    using 'if (err)' or 'if (err < 0)'.
    The only legitimate user I could find that we get a warning for
    is the (32-bit only) freescale fman driver, so I did not remove
    the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
    For 9pfs, I just worked around one user whose calling conventions
    are so obscure that I did not dare change the behavior.

    I was using this definition for testing:

    #define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
    unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))

    which ends up making all 16-bit or wider types work correctly with
    the most plausible interpretation of what IS_ERR_VALUE() was supposed
    to return according to its users, but also causes a compile-time
    warning for any users that do not pass an 'unsigned long' argument.

    I suggested this approach earlier this year, but back then we ended
    up deciding to just fix the users that are obviously broken. After
    the initial warning that caused me to get involved in the discussion
    (fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
    asked me to send the whole thing again.

    [ Updated the 9p parts as per Al Viro - Linus ]

    Signed-off-by: Arnd Bergmann
    Cc: Andrzej Hajda
    Cc: Andrew Morton
    Link: https://lkml.org/lkml/2016/1/7/363
    Link: https://lkml.org/lkml/2016/5/27/486
    Acked-by: Srinivas Kandagatla # For nvmem part
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     

11 Mar, 2016

1 commit


25 Jan, 2016

1 commit

  • Pull 9p updates from Eric Van Hensbergen:
    "Sorry for the last minute pull request, there's was a change that
    didn't get pulled into for-next until two weeks ago and I wanted to
    give it some bake time.

    Summary:

    Rework and error handling fixes, primarily in the fscatch and fd
    transports"

    * tag 'for-linus-4.5-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs:
    fs/9p: use fscache mutex rather than spinlock
    9p: trans_fd, bail out if recv fcall if missing
    9p: trans_fd, read rework to use p9_parse_header
    net/9p: Add device name details on error

    Linus Torvalds
     

04 Jan, 2016

1 commit