Bug 1465619 - kernel/tcmu-runner: fix uio_poll crash during uio device removal
kernel/tcmu-runner: fix uio_poll crash during uio device removal
Status: NEW
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: tcmu-runner (Show other bugs)
7.4
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Mike Christie
Storage QE
:
Depends On:
Blocks: 1474188
  Show dependency treegraph
 
Reported: 2017-06-27 15:06 EDT by Mike Christie
Modified: 2017-07-24 01:49 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1474188 (view as bug list)
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mike Christie 2017-06-27 15:06:03 EDT
Description of problem:

During uio device removal we hit this trace:

[110889.918952] Call Trace:
[110889.920407]  [<ffffffff812172c7>] do_sys_poll+0x327/0x580
[110889.921844]  [<ffffffff810cdcbc>] ? dequeue_entity+0x11c/0x5d0
[110889.923264]  [<ffffffff810cd7d4>] ? update_curr+0x104/0x190
[110889.924657]  [<ffffffff810ca2de>] ? account_entity_dequeue+0xae/0xd0
[110889.926022]  [<ffffffff810cdcbc>] ? dequeue_entity+0x11c/0x5d0
[110889.927361]  [<ffffffff810ce58e>] ? dequeue_task_fair+0x41e/0x660
[110889.928681]  [<ffffffff810c7735>] ? sched_clock_cpu+0x85/0xc0
[110889.929969]  [<ffffffff81215e00>] ? poll_select_copy_remaining+0x150/0x150
[110889.931248]  [<ffffffff8109b62b>] ? recalc_sigpending+0x1b/0x50
[110889.932493]  [<ffffffff8109b756>] ? dequeue_signal+0x86/0x170
[110889.933721]  [<ffffffff8109e28f>] ? get_signal_to_deliver+0xff/0x5e0
[110889.934935]  [<ffffffff810f4f00>] ? futex_wake+0x90/0x180
[110889.936109]  [<ffffffff8102a467>] ? do_signal+0x57/0x6c0
[110889.937271]  [<ffffffff8133da6d>] ? list_del+0xd/0x30
[110889.938404]  [<ffffffff810b16b1>] ? remove_wait_queue+0x31/0x40
[110889.939531]  [<ffffffff81217569>] do_restart_poll+0x49/0x90
[110889.940641]  [<ffffffff816b423d>] ? int_signal+0x12/0x17
[110889.941710]  [<ffffffff8109e8ef>] sys_restart_syscall+0x1f/0x30
[110889.942753]  [<ffffffff816b3f89>] system_call_fastpath+0x16/0x1b
[110889.943767] Code: ff ff c3 0f 1f 84 00 00 00 00 00 66 66 66 66 90
55 b8 fb ff ff ff 48 89 e5 41 54 53 4c 8b a7 a8 00 00 00 49 8b 1c 24
48 8b 4b 40 <48> 83 b9 d0 01 00 00 00 75 06 5b 41 5c 5d c3 90 48 85 f6
74 19
[110889.945863] RIP  [<ffffffffc0304080>] uio_poll+0x20/0x70 [uio]
[110889.946851]  RSP <ffff88065de8fb08>



It looks like the problem is if the app is shutting down the user of a device and gets a signal while waiting in a poll call (before do_poll has called do_pollfd and that has done a fdget), the app shutting down the device will proceed to do the close on the uio device and the kernel will eventually do a uio_unregister_device which frees the uio device resources. However, the kernel could restart the poll like we see above. The restarted poll call could then race with the app shutdown and call into the uio_poll callout and reference memory freed by uio_unregister_device.

To fix this:

- It looks like the userspace app could use ppoll instead of poll since it does not support restarting poll from the kernel.

- Maybe the poll code could do a fdget/fget on the uio device's fd/file when it decides to the the restart (note uio does not have refcounting so we would need to add that to support this



Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Note You need to log in before you can comment on or make changes to this bug.