27 Nov, 2018

1 commit

  • commit 432798195bbce1f8cd33d1c0284d0538835e25fb upstream.

    I was trying to solve a double free but I introduced a more serious
    NULL dereference bug. The problem is that if there is an IRQ which
    triggers immediately, then we need "info->uio_dev" but it's not set yet.

    This patch puts the original initialization back to how it was and just
    sets info->uio_dev to NULL on the error path so it should solve both
    the Oops and the double free.

    Fixes: f019f07ecf6a ("uio: potential double frees if __uio_register_device() fails")
    Reported-by: Mathias Thore
    Signed-off-by: Dan Carpenter
    Cc: stable
    Tested-by: Mathias Thore
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     

14 Nov, 2018

1 commit

  • [ Upstream commit ae61cf5b9913027c6953a79ed3894da4f47061bd ]

    When both uio and the uio drivers are built in the kernel, it is possible
    for a driver to register devices before the uio class is registered.

    This may result in a NULL pointer dereference later on in
    get_device_parent() when accessing the class glue_dirs spinlock.

    The trace looks like that:

    Unable to handle kernel NULL pointer dereference at virtual address 00000140
    [...]
    [] _raw_spin_lock+0x14/0x48
    [] device_add+0x154/0x6a0
    [] device_create_groups_vargs+0x120/0x128
    [] device_create+0x54/0x60
    [] __uio_register_device+0x120/0x4a8
    [] jaguar2_pci_probe+0x2d4/0x558
    [] local_pci_probe+0x3c/0xb8
    [] pci_device_probe+0x11c/0x180
    [] driver_probe_device+0x22c/0x2d8
    [] __driver_attach+0xbc/0xc0
    [] bus_for_each_dev+0x4c/0x98
    [] driver_attach+0x20/0x28
    [] bus_add_driver+0x1b8/0x228
    [] driver_register+0x60/0xf8
    [] __pci_register_driver+0x40/0x48

    Return EPROBE_DEFER in that case so the driver can register the device
    later.

    Signed-off-by: Alexandre Belloni
    Signed-off-by: Greg Kroah-Hartman
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Alexandre Belloni
     

20 Aug, 2018

1 commit

  • Pull UIO fix from Greg KH:
    "Here is a single UIO fix that I forgot to send before 4.18-final came
    out. It reverts a UIO patch that went in the 4.18 development window
    that was causing problems.

    This patch has been in linux-next for a while with no problems, I just
    forgot to send it earlier, or as part of the larger char/misc patch
    series from yesterday, my fault"

    * tag 'char-misc-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
    Revert "uio: use request_threaded_irq instead"

    Linus Torvalds
     

12 Aug, 2018

1 commit

  • Since mutex lock in irq hanler is useless currently, here will
    remove it together with it.

    This reverts commit 9421e45f5ff3d558cf8b75a8cc0824530caf3453.

    Reported-by: james.r.harris@intel.com
    CC: Ahsan Atta
    Signed-off-by: Xiubo Li
    Signed-off-by: Greg Kroah-Hartman

    Xiubo Li
     

02 Aug, 2018

3 commits

  • The uio_unregister_device() function assumes that if "info->uio_dev" is
    non-NULL that means "info" is fully allocated. Setting info->uio_de
    has to be the last thing in the function.

    In the current code, if request_threaded_irq() fails then we return with
    info->uio_dev set to non-NULL but info is not fully allocated and it can
    lead to double frees.

    Fixes: beafc54c4e2f ("UIO: Add the User IO core code")
    Signed-off-by: Dan Carpenter
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • The call trace:
    XXX/1910 is trying to acquire lock:
    (&mm->mmap_sem){++++++}, at: [] might_fault+0x57/0xb0

    but task is already holding lock:
    (&idev->info_lock){+.+...}, at: [] uio_write+0x46/0x130 [uio]

    which lock already depends on the new lock.

    the existing dependency chain (in reverse order) is:

    -> #1 (&idev->info_lock){+.+...}:
    [] lock_acquire+0x99/0x1e0
    [] mutex_lock_nested+0x93/0x410
    [] uio_mmap+0x2d/0x170 [uio]
    [] mmap_region+0x428/0x650
    [] do_mmap+0x3b8/0x4e0
    [] vm_mmap_pgoff+0xd3/0x120
    [] SyS_mmap_pgoff+0x1f1/0x270
    [] SyS_mmap+0x22/0x30
    [] system_call_fastpath+0x1c/0x21

    -> #0 (&mm->mmap_sem){++++++}:
    [] __lock_acquire+0xdac/0x15f0
    [] lock_acquire+0x99/0x1e0
    [] might_fault+0x84/0xb0
    [] uio_write+0xb4/0x130 [uio]
    [] vfs_write+0xc3/0x1f0
    [] SyS_write+0x8a/0x100
    [] system_call_fastpath+0x1c/0x21

    other info that might help us debug this:
    Possible unsafe locking scenario:
    CPU0 CPU1
    ---- ----
    lock(&idev->info_lock);
    lock(&mm->mmap_sem);
    lock(&idev->info_lock);
    lock(&mm->mmap_sem);

    *** DEADLOCK ***
    1 lock held by XXX/1910:
    #0: (&idev->info_lock){+.+...}, at: [] uio_write+0x46/0x130 [uio]

    stack backtrace:
    CPU: 0 PID: 1910 Comm: XXX Kdump: loaded Not tainted #1
    Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
    Call Trace:
    [] dump_stack+0x19/0x1b
    [] print_circular_bug+0x1f9/0x207
    [] check_prevs_add+0x957/0x960
    [] __lock_acquire+0xdac/0x15f0
    [] ? mark_held_locks+0xb9/0x140
    [] lock_acquire+0x99/0x1e0
    [] ? might_fault+0x57/0xb0
    [] might_fault+0x84/0xb0
    [] ? might_fault+0x57/0xb0
    [] uio_write+0xb4/0x130 [uio]
    [] vfs_write+0xc3/0x1f0
    [] ? fget_light+0xfc/0x510
    [] SyS_write+0x8a/0x100
    [] system_call_fastpath+0x1c/0x21

    Signed-off-by: Xiubo Li
    Signed-off-by: Greg Kroah-Hartman

    Xiubo Li
     
  • There are two bugs here. First the error codes weren't set on several
    paths. And second, if the call to request_threaded_irq() inside
    uio_register_device() fails then it would lead to a double free when
    we call uio_unregister_device() inside pruss_cleanup().

    Signed-off-by: Dan Carpenter
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     

21 Jul, 2018

3 commits

  • For those without any license text present or short reference
    to GPL, add SPDX tag.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     
  • uio_mmap has multiple fail paths to set return value to nonzero then
    goto out. However, it always returns *0* from the *out* at end, and
    this will mislead callers who check the return value of this function.

    Fixes: 57c5f4df0a5a0ee ("uio: fix crash after the device is unregistered")
    CC: Xiubo Li
    Signed-off-by: Hailong Liu
    Cc: stable
    Signed-off-by: Jiang Biao
    Signed-off-by: Greg Kroah-Hartman

    Hailong Liu
     
  • Replace short statement in comment with proper SPDX
    license tag.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     

07 Jul, 2018

3 commits

  • For the target_core_user use case, after the device is unregistered
    it maybe still opened in user space, then the kernel will crash, like:

    [ 251.163692] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
    [ 251.163820] IP: [] show_name+0x23/0x40 [uio]
    [ 251.163965] PGD 8000000062694067 PUD 62696067 PMD 0
    [ 251.164097] Oops: 0000 [#1] SMP
    ...
    [ 251.165605] e1000 mptscsih mptbase drm_panel_orientation_quirks dm_mirror dm_region_hash dm_log dm_mod
    [ 251.166014] CPU: 0 PID: 13380 Comm: tcmu-runner Kdump: loaded Not tainted 3.10.0-916.el7.test.x86_64 #1
    [ 251.166381] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/19/2017
    [ 251.166747] task: ffff971eb91db0c0 ti: ffff971e9e384000 task.ti: ffff971e9e384000
    [ 251.167137] RIP: 0010:[] [] show_name+0x23/0x40 [uio]
    [ 251.167563] RSP: 0018:ffff971e9e387dc8 EFLAGS: 00010282
    [ 251.167978] RAX: 0000000000000000 RBX: ffff971e9e3f8000 RCX: ffff971eb8368d98
    [ 251.168408] RDX: ffff971e9e3f8000 RSI: ffffffffc0738084 RDI: ffff971e9e3f8000
    [ 251.168856] RBP: ffff971e9e387dd0 R08: ffff971eb8bc0018 R09: 0000000000000000
    [ 251.169296] R10: 0000000000001000 R11: ffffffffa09d444d R12: ffffffffa1076e80
    [ 251.169750] R13: ffff971e9e387f18 R14: 0000000000000001 R15: ffff971e9cfb1c80
    [ 251.170213] FS: 00007ff37d175880(0000) GS:ffff971ebb600000(0000) knlGS:0000000000000000
    [ 251.170693] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    [ 251.171248] CR2: 0000000000000008 CR3: 00000000001f6000 CR4: 00000000003607f0
    [ 251.172071] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    [ 251.172640] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    [ 251.173236] Call Trace:
    [ 251.173789] [] dev_attr_show+0x23/0x60
    [ 251.174356] [] ? mutex_lock+0x12/0x2f
    [ 251.174892] [] sysfs_kf_seq_show+0xcf/0x1f0
    [ 251.175433] [] kernfs_seq_show+0x26/0x30
    [ 251.175981] [] seq_read+0x110/0x3f0
    [ 251.176609] [] kernfs_fop_read+0xf5/0x160
    [ 251.177158] [] vfs_read+0x9f/0x170
    [ 251.177707] [] SyS_read+0x7f/0xf0
    [ 251.178268] [] system_call_fastpath+0x1c/0x21
    [ 251.178823] Code: 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 53 48 89 d3 e8 7e 96 56 e0 48 8b 80 d8 02 00 00 48 89 df 48 c7 c6 84 80 73 c0 8b 50 08 31 c0 e8 e2 67 44 e0 5b 48 98 5d c3 0f 1f 00 66 2e
    [ 251.180115] RIP [] show_name+0x23/0x40 [uio]
    [ 251.180820] RSP
    [ 251.181473] CR2: 0000000000000008

    CC: Hamish Martin
    CC: Mike Christie
    Reviewed-by: Hamish Martin
    Signed-off-by: Xiubo Li
    Signed-off-by: Greg Kroah-Hartman

    Xiubo Li
     
  • We are hitting a regression with the following commit:

    commit a93e7b331568227500186a465fee3c2cb5dffd1f
    Author: Hamish Martin
    Date: Mon May 14 13:32:23 2018 +1200

    uio: Prevent device destruction while fds are open

    The problem is the addition of spin_lock_irqsave in uio_write. This
    leads to hitting uio_write -> copy_from_user -> _copy_from_user ->
    might_fault and the logs filling up with sleeping warnings.

    I also noticed some uio drivers allocate memory, sleep, grab mutexes
    from callouts like open() and release and uio is now doing
    spin_lock_irqsave while calling them.

    Reported-by: Mike Christie
    CC: Hamish Martin
    Reviewed-by: Hamish Martin
    Signed-off-by: Xiubo Li
    Signed-off-by: Greg Kroah-Hartman

    Xiubo Li
     
  • Prepraing for changing to use mutex lock.

    Signed-off-by: Xiubo Li
    Signed-off-by: Greg Kroah-Hartman

    Xiubo Li
     

13 Jun, 2018

1 commit

  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

14 May, 2018

2 commits

  • Prevent destruction of a uio_device while user space apps hold open
    file descriptors to that device. Further, access to the 'info' member
    of the struct uio_device is protected by spinlock. This is to ensure
    stale pointers to data not under control of the UIO subsystem are not
    dereferenced.

    Signed-off-by: Hamish Martin
    Reviewed-by: Chris Packham
    Signed-off-by: Greg Kroah-Hartman

    Hamish Martin
     
  • Drive all return paths for uio_write() through a single block at the
    end of the function.

    Signed-off-by: Hamish Martin
    Reviewed-by: Chris Packham
    Signed-off-by: Greg Kroah-Hartman

    Hamish Martin
     

30 Apr, 2018

1 commit


23 Apr, 2018

6 commits

  • Structure platform_driver does not need to set the owner field, as this
    will be populated by the driver core.

    Generated by scripts/coccinelle/api/platform_no_drv_owner.cocci.

    Signed-off-by: Fabio Estevam
    Signed-off-by: Greg Kroah-Hartman

    Fabio Estevam
     
  • Use new return type vm_fault_t for fault handler
    in struct vm_operations_struct. For now, this is
    just documenting that the function returns a VM_
    FAULT value rather than an errno. Once all inst
    ances are converted, vm_fault_t will become a di
    stinct type.

    Reference - 1c8f422059ae ("mm: change return type
    to vm_fault_t")

    Signed-off-by: Souptick Joarder
    Reviewed-by: Matthew Wilcox
    Signed-off-by: Greg Kroah-Hartman

    Souptick Joarder
     
  • The fault method of handling subchannel ring, did not work correctly
    (it only worked for the first page).

    Since ring buffer is physically contiguous, using the vm helper
    function is simpler and handles more cases.

    Fixes: 37b96a4931db ("uio_hv_generic: support sub-channels")
    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     
  • Need to mask the correct sub-channel in the callback from VMBUS
    isr. Otherwise, can get in to infinite interrupt storm.

    Fixes: 37b96a4931db ("uio_hv_generic: support sub-channels")
    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     
  • The primary channel also needs a ring buffer attribute. This allows
    application to check if kernel supports uio sub channels, and also
    makes all channels use consistent API.

    Fixes: 37b96a4931db ("uio_hv_generic: support sub-channels")
    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     
  • The original code had ring size as a module parameter, but
    then it was made a fixed value. The code to set the size of
    the ring buffer binary file was lost in the transistion.
    The size is needed by user mode driver to know the size of
    the ring buffer.

    Fixes: 37b96a4931db ("uio_hv_generic: support sub-channels")
    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     

07 Mar, 2018

1 commit

  • Use sysfs to allow supporting sub-channels. The userspace application
    makes request to host to create sub-channels and the UIO kernel
    driver populates the sysfs per-channel directory with a binary
    attribute file that can be used to read/write ring.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     

12 Feb, 2018

1 commit

  • This is the mindless scripted replacement of kernel use of POLL*
    variables as described by Al, done by this script:

    for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
    L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
    for f in $L; do sed -i "-es/^\([^\"]*\)\(\\)/\\1E\\2/" $f; done
    done

    with de-mangling cleanups yet to come.

    NOTE! On almost all architectures, the EPOLL* constants have the same
    values as the POLL* constants do. But they keyword here is "almost".
    For various bad reasons they aren't the same, and epoll() doesn't
    actually work quite correctly in some cases due to this on Sparc et al.

    The next patch from Al will sort out the final differences, and we
    should be all done.

    Scripted-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

02 Feb, 2018

1 commit

  • Pull char/misc driver updates from Greg KH:
    "Here is the big pull request for char/misc drivers for 4.16-rc1.

    There's a lot of stuff in here. Three new driver subsystems were added
    for various types of hardware busses:

    - siox
    - slimbus
    - soundwire

    as well as a new vboxguest subsystem for the VirtualBox hypervisor
    drivers.

    There's also big updates from the FPGA subsystem, lots of Android
    binder fixes, the usual handful of hyper-v updates, and lots of other
    smaller driver updates.

    All of these have been in linux-next for a long time, with no reported
    issues"

    * tag 'char-misc-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (155 commits)
    char: lp: use true or false for boolean values
    android: binder: use VM_ALLOC to get vm area
    android: binder: Use true and false for boolean values
    lkdtm: fix handle_irq_event symbol for INT_HW_IRQ_EN
    EISA: Delete error message for a failed memory allocation in eisa_probe()
    EISA: Whitespace cleanup
    misc: remove AVR32 dependencies
    virt: vbox: Add error mapping for VERR_INVALID_NAME and VERR_NO_MORE_FILES
    soundwire: Fix a signedness bug
    uio_hv_generic: fix new type mismatch warnings
    uio_hv_generic: fix type mismatch warnings
    auxdisplay: img-ascii-lcd: add missing MODULE_DESCRIPTION/AUTHOR/LICENSE
    uio_hv_generic: add rescind support
    uio_hv_generic: check that host supports monitor page
    uio_hv_generic: create send and receive buffers
    uio: document uio_hv_generic regions
    doc: fix documentation about uio_hv_generic
    vmbus: add monitor_id and subchannel_id to sysfs per channel
    vmbus: fix ABI documentation
    uio_hv_generic: use ISR callback method
    ...

    Linus Torvalds
     

13 Jan, 2018

1 commit

  • In commit 72d146578950 ("uio_hv_generic: fix type mismatch warnings"),
    I addressed some warnings that show up with CONFIG_X86_PAE, now a new
    change has added more of the same:

    drivers/uio/uio_hv_generic.c: In function 'hv_uio_probe':
    drivers/uio/uio_hv_generic.c:205:5: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
    drivers/uio/uio_hv_generic.c:225:5: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

    The fix is the same as before, casting to uintptr_t as an intermediate.

    Fixes: e7d214642a19 ("uio_hv_generic: create send and receive buffers")
    Signed-off-by: Arnd Bergmann
    Cc: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     

11 Jan, 2018

4 commits

  • I moved the virt_to_phys() conversion into hv_uio_probe() as part of
    a warning fix. Stephen's cleanup to remove the private mmap() function
    seems reasonable, but part of it reverted the change that I did to
    hide the warnings, so they are back now:

    drivers/uio/uio_hv_generic.c: In function 'hv_uio_probe':
    drivers/uio/uio_hv_generic.c:123:5: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
    drivers/uio/uio_hv_generic.c:130:5: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
    drivers/uio/uio_hv_generic.c:136:5: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]

    The type mismatch is now the result of the uio_mmap() definition, and
    the best way I see from here is to shut them up with a uintptr_t cast.

    Fixes: 9c40546c012c ("uio_hv_generic: use standard mmap for resources")
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     
  • When host rescinds the device, the UIO driver will clear the interrupt
    state and notify application. The read (or write) on the interrupt FD
    will then fail with -EIO. This is simpler than adding lots extra uevent
    stuff inside UIO.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     
  • In order for userspace application to signal host, it needs the
    host to support the monitor page property. Check for the flag
    and fail if this is not supported.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     
  • Map in receive and send buffers for networking in UIO device.
    These buffers are special and need to be setup by kernel
    API's; userspace can not do it.

    Signed-off-by: Stephen Hemminger
    Signed-off-by: Greg Kroah-Hartman

    Stephen Hemminger
     

10 Jan, 2018

3 commits


29 Nov, 2017

1 commit


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
     

22 May, 2017

1 commit


18 May, 2017

1 commit

  • Some userspace drivers and frameworks only poll and do not
    require interrupts to be available and enabled on the
    PCI device. So remove the requirement that an IRQ is
    assigned. If an IRQ is not assigned and a userspace
    driver tries to read()/write(), the generic uio
    framework will just return -EIO.

    This allows binding uio_pci_generic to devices which
    cannot get an IRQ assigned, such as an NVMe controller
    behind Intel Volume Management Device (VMD), since VMD
    does not support INTx interrupts.

    Signed-off-by: Jim Harris
    Acked-by: Michael S. Tsirkin
    Signed-off-by: Greg Kroah-Hartman

    Jim Harris
     

17 May, 2017

1 commit

  • Commit 75f0aef6220d ("uio: fix memory leak") has fixed up some
    memory leaks during the failure paths of the addition of uio
    attributes, but still is not correct entirely. A kobject_uevent()
    failure still needs a kobject_put() and the kobject container
    structure allocation failure before the kobject_init() doesn't
    need a kobject_put(). Fix this properly.

    Fixes: 75f0aef6220d ("uio: fix memory leak")
    Signed-off-by: Suman Anna
    Signed-off-by: Greg Kroah-Hartman

    Suman Anna
     

09 Apr, 2017

1 commit

  • mf624 card has its registers not aligned to pages. Since commit
    b65502879556 ("uio: we cannot mmap unaligned page contents") mmap()ing
    mf624 registers fails, because now the uio drivers must set
    uio_mem->addr to be page-aligned.

    We align the address here and set the newly introduced offs field to
    the offset of the mf264 registers within the page so that userspace
    can find the address of the mmap()ed register by reading
    /sys/class/uio/uio?/maps/map?/offset.

    Tested with real mf624 card.

    Signed-off-by: Michal Sojka
    Signed-off-by: Greg Kroah-Hartman

    Michal Sojka