<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/uio, branch v4.19.112</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v4.19.112</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v4.19.112'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2020-02-24T07:34:37+00:00</updated>
<entry>
<title>uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()</title>
<updated>2020-02-24T07:34:37+00:00</updated>
<author>
<name>Jia-Ju Bai</name>
<email>baijiaju1990@gmail.com</email>
</author>
<published>2019-12-18T09:44:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ea6b7b1d58790ffb36bace723f6e62a1c8595c77'/>
<id>urn:sha1:ea6b7b1d58790ffb36bace723f6e62a1c8595c77</id>
<content type='text'>
[ Upstream commit b74351287d4bd90636c3f48bc188c2f53824c2d4 ]

The driver may sleep while holding a spinlock.
The function call path (from bottom to top) in Linux 4.19 is:

kernel/irq/manage.c, 523:
	synchronize_irq in disable_irq
drivers/uio/uio_dmem_genirq.c, 140:
	disable_irq in uio_dmem_genirq_irqcontrol
drivers/uio/uio_dmem_genirq.c, 134:
	_raw_spin_lock_irqsave in uio_dmem_genirq_irqcontrol

synchronize_irq() can sleep at runtime.

To fix this bug, disable_irq() is called without holding the spinlock.

This bug is found by a static analysis tool STCheck written by myself.

Signed-off-by: Jia-Ju Bai &lt;baijiaju1990@gmail.com&gt;
Link: https://lore.kernel.org/r/20191218094405.6009-1-baijiaju1990@gmail.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>driver: uio: fix possible use-after-free in __uio_register_device</title>
<updated>2020-01-27T13:50:17+00:00</updated>
<author>
<name>Liu Jian</name>
<email>liujian56@huawei.com</email>
</author>
<published>2019-01-22T22:45:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3b3f78a629a4df86f7db72268c2636f3135f0cdc'/>
<id>urn:sha1:3b3f78a629a4df86f7db72268c2636f3135f0cdc</id>
<content type='text'>
[ Upstream commit 221a1f4ac12d2ab46246c160b2e00d1b1160d5d9 ]

In uio_dev_add_attributes() error handing case, idev is used after
device_unregister(), in which 'idev' has been released, touch idev cause
use-after-free.

Fixes: a93e7b331568 ("uio: Prevent device destruction while fds are open")
Signed-off-by: Liu Jian &lt;liujian56@huawei.com&gt;
Reviewed-by: Hamish Martin &lt;hamish.martin@alliedtelesis.co.nz&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>driver: uio: fix possible memory leak in __uio_register_device</title>
<updated>2020-01-27T13:50:16+00:00</updated>
<author>
<name>Liu Jian</name>
<email>liujian56@huawei.com</email>
</author>
<published>2019-01-22T22:45:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3b656e7c166d14d8cb6acecd26e5761274ba2b73'/>
<id>urn:sha1:3b656e7c166d14d8cb6acecd26e5761274ba2b73</id>
<content type='text'>
[ Upstream commit 1a392b3de7c5747506b38fc14b2e79977d3c7770 ]

'idev' is malloced in __uio_register_device() and leak free it before
leaving from the uio_get_minor() error handing case, it will cause
memory leak.

Fixes: a93e7b331568 ("uio: Prevent device destruction while fds are open")
Signed-off-by: Liu Jian &lt;liujian56@huawei.com&gt;
Reviewed-by: Hamish Martin &lt;hamish.martin@alliedtelesis.co.nz&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vmbus: keep pointer to ring buffer page</title>
<updated>2019-11-20T17:47:31+00:00</updated>
<author>
<name>Stephen Hemminger</name>
<email>stephen@networkplumber.org</email>
</author>
<published>2018-09-14T16:10:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=86f886e91dcff23f34ab3ccdc1a8b130763004cb'/>
<id>urn:sha1:86f886e91dcff23f34ab3ccdc1a8b130763004cb</id>
<content type='text'>
[ Upstream commit 52a42c2a90226dc61c99bbd0cb096deeb52c334b ]

Avoid going from struct page to virt address (and back) by just
keeping pointer to the allocated pages instead of virt address.

Signed-off-by: Stephen Hemminger &lt;sthemmin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>uio: Fix an Oops on load</title>
<updated>2018-11-27T15:13:09+00:00</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2018-10-26T07:19:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=8600660ce149b32961d0f298eb6cd1c22a161fb1'/>
<id>urn:sha1:8600660ce149b32961d0f298eb6cd1c22a161fb1</id>
<content type='text'>
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-&gt;uio_dev" but it's not set yet.

This patch puts the original initialization back to how it was and just
sets info-&gt;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 &lt;Mathias.Thore@infinera.com&gt;
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Cc: stable &lt;stable@vger.kernel.org&gt;
Tested-by: Mathias Thore &lt;Mathias.Thore@infinera.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>uio: ensure class is registered before devices</title>
<updated>2018-11-13T19:08:37+00:00</updated>
<author>
<name>Alexandre Belloni</name>
<email>alexandre.belloni@bootlin.com</email>
</author>
<published>2018-08-16T07:39:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c21099be02331a82c28a7bad1d956b6cd64a3782'/>
<id>urn:sha1:c21099be02331a82c28a7bad1d956b6cd64a3782</id>
<content type='text'>
[ 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
[...]
[&lt;ffff0000089cc234&gt;] _raw_spin_lock+0x14/0x48
[&lt;ffff0000084f56bc&gt;] device_add+0x154/0x6a0
[&lt;ffff0000084f5e48&gt;] device_create_groups_vargs+0x120/0x128
[&lt;ffff0000084f5edc&gt;] device_create+0x54/0x60
[&lt;ffff0000086e72c0&gt;] __uio_register_device+0x120/0x4a8
[&lt;ffff000008528b7c&gt;] jaguar2_pci_probe+0x2d4/0x558
[&lt;ffff0000083fc18c&gt;] local_pci_probe+0x3c/0xb8
[&lt;ffff0000083fd81c&gt;] pci_device_probe+0x11c/0x180
[&lt;ffff0000084f88bc&gt;] driver_probe_device+0x22c/0x2d8
[&lt;ffff0000084f8a24&gt;] __driver_attach+0xbc/0xc0
[&lt;ffff0000084f69fc&gt;] bus_for_each_dev+0x4c/0x98
[&lt;ffff0000084f81b8&gt;] driver_attach+0x20/0x28
[&lt;ffff0000084f7d08&gt;] bus_add_driver+0x1b8/0x228
[&lt;ffff0000084f93c0&gt;] driver_register+0x60/0xf8
[&lt;ffff0000083fb918&gt;] __pci_register_driver+0x40/0x48

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

Signed-off-by: Alexandre Belloni &lt;alexandre.belloni@bootlin.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'char-misc-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc</title>
<updated>2018-08-19T16:30:44+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2018-08-19T16:30:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=1d0926e99de7b486321e3db924b445531eea5e18'/>
<id>urn:sha1:1d0926e99de7b486321e3db924b445531eea5e18</id>
<content type='text'>
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"
</content>
</entry>
<entry>
<title>Revert "uio: use request_threaded_irq instead"</title>
<updated>2018-08-12T15:30:58+00:00</updated>
<author>
<name>Xiubo Li</name>
<email>xiubli@redhat.com</email>
</author>
<published>2018-08-12T11:58:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=3d27c4de8d4fb2d4099ff324671792aa2578c6f9'/>
<id>urn:sha1:3d27c4de8d4fb2d4099ff324671792aa2578c6f9</id>
<content type='text'>
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 &lt;ahsan.atta@intel.com&gt;
Signed-off-by: Xiubo Li &lt;xiubli@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>uio: potential double frees if __uio_register_device() fails</title>
<updated>2018-08-02T08:42:25+00:00</updated>
<author>
<name>Dan Carpenter</name>
<email>dan.carpenter@oracle.com</email>
</author>
<published>2018-08-02T08:24:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f019f07ecf6a6b8bd6d7853bce70925d90af02d1'/>
<id>urn:sha1:f019f07ecf6a6b8bd6d7853bce70925d90af02d1</id>
<content type='text'>
The uio_unregister_device() function assumes that if "info-&gt;uio_dev" is
non-NULL that means "info" is fully allocated.  Setting info-&gt;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-&gt;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 &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>uio: fix possible circular locking dependency</title>
<updated>2018-08-02T08:14:26+00:00</updated>
<author>
<name>Xiubo Li</name>
<email>xiubli@redhat.com</email>
</author>
<published>2018-07-30T07:11:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b34e9a15b37b8ddbf06a4da142b0c39c74211eb4'/>
<id>urn:sha1:b34e9a15b37b8ddbf06a4da142b0c39c74211eb4</id>
<content type='text'>
The call trace:
XXX/1910 is trying to acquire lock:
 (&amp;mm-&gt;mmap_sem){++++++}, at: [&lt;ffffffff97008c87&gt;] might_fault+0x57/0xb0

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

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-&gt; #1 (&amp;idev-&gt;info_lock){+.+...}:
       [&lt;ffffffff96f31fc9&gt;] lock_acquire+0x99/0x1e0
       [&lt;ffffffff975edad3&gt;] mutex_lock_nested+0x93/0x410
       [&lt;ffffffffc063873d&gt;] uio_mmap+0x2d/0x170 [uio]
       [&lt;ffffffff97016b58&gt;] mmap_region+0x428/0x650
       [&lt;ffffffff97017138&gt;] do_mmap+0x3b8/0x4e0
       [&lt;ffffffff96ffaba3&gt;] vm_mmap_pgoff+0xd3/0x120
       [&lt;ffffffff97015261&gt;] SyS_mmap_pgoff+0x1f1/0x270
       [&lt;ffffffff96e387c2&gt;] SyS_mmap+0x22/0x30
       [&lt;ffffffff975ff315&gt;] system_call_fastpath+0x1c/0x21

-&gt; #0 (&amp;mm-&gt;mmap_sem){++++++}:
       [&lt;ffffffff96f30e9c&gt;] __lock_acquire+0xdac/0x15f0
       [&lt;ffffffff96f31fc9&gt;] lock_acquire+0x99/0x1e0
       [&lt;ffffffff97008cb4&gt;] might_fault+0x84/0xb0
       [&lt;ffffffffc0638a74&gt;] uio_write+0xb4/0x130 [uio]
       [&lt;ffffffff9706ffa3&gt;] vfs_write+0xc3/0x1f0
       [&lt;ffffffff97070e2a&gt;] SyS_write+0x8a/0x100
       [&lt;ffffffff975ff315&gt;] system_call_fastpath+0x1c/0x21

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

 *** DEADLOCK ***
1 lock held by XXX/1910:
 #0:  (&amp;idev-&gt;info_lock){+.+...}, at: [&lt;ffffffffc0638a06&gt;] 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:
 [&lt;ffffffff975e9211&gt;] dump_stack+0x19/0x1b
 [&lt;ffffffff975e260a&gt;] print_circular_bug+0x1f9/0x207
 [&lt;ffffffff96f2f6a7&gt;] check_prevs_add+0x957/0x960
 [&lt;ffffffff96f30e9c&gt;] __lock_acquire+0xdac/0x15f0
 [&lt;ffffffff96f2fb19&gt;] ? mark_held_locks+0xb9/0x140
 [&lt;ffffffff96f31fc9&gt;] lock_acquire+0x99/0x1e0
 [&lt;ffffffff97008c87&gt;] ? might_fault+0x57/0xb0
 [&lt;ffffffff97008cb4&gt;] might_fault+0x84/0xb0
 [&lt;ffffffff97008c87&gt;] ? might_fault+0x57/0xb0
 [&lt;ffffffffc0638a74&gt;] uio_write+0xb4/0x130 [uio]
 [&lt;ffffffff9706ffa3&gt;] vfs_write+0xc3/0x1f0
 [&lt;ffffffff9709349c&gt;] ? fget_light+0xfc/0x510
 [&lt;ffffffff97070e2a&gt;] SyS_write+0x8a/0x100
 [&lt;ffffffff975ff315&gt;] system_call_fastpath+0x1c/0x21

Signed-off-by: Xiubo Li &lt;xiubli@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
