Bug 1571292

Summary: VDO misuses GFP flags to __vmalloc
Product: Red Hat Enterprise Linux 7 Reporter: Sweet Tea Dorminy <sweettea>
Component: kmod-kvdoAssignee: Thomas Jaskiewicz <tjaskiew>
Status: CLOSED ERRATA QA Contact: Jakub Krysl <jkrysl>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.6CC: awalsh, bgurney, jkrysl, limershe
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 6.1.1.113 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 09:39:31 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sweet Tea Dorminy 2018-04-24 13:08:50 UTC
Description of problem:
VDO has a central allocation function, allocateMemory(). It attempts to use kmalloc or __vmalloc to satisfy allocations. This should probably be kvmalloc, as is the standard kernel practice. Moreover, it passes the same flags to __vmalloc as to kmalloc, including GFP_NOIO when IO is unsafe to do to satisfy the allocation, and __GFP_REPEAT/__GFP_RETRY_MAYFAIL. 

As per [1], using __vmalloc in a situation where IO is unsafe at all is unsafe, even if GFP_NOIO is pased to __vmalloc, because it may do a kmalloc without GFP_NOIO. This could lead to a deadlock in certain lowmem situations. Furthermore, as per [2], the use of retry modifiers (i.e. __GFP_RETRY_MAYFAIL) as parameters to __vmalloc is not supported.


[1] http://lkml.iu.edu/hypermail/linux/kernel/1706.3/04681.html
[2] https://elixir.bootlin.com/linux/latest/source/mm/vmalloc.c#L1780

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

Actual results:
Extremely rare (theoretical) deadlock under low memory conditions.

Expected results:
No deadlock even under low memory conditions.

Additional info:
Probably SanityOnly.

Comment 2 Thomas Jaskiewicz 2018-07-17 19:00:54 UTC
We will stop using the __GFP_NORETRY flag.

We will stop using GFP_NOIO, and instead use the memalloc_noio_save and memalloc_noio_restore methods, which have been backported to RHEL7.5

Comment 3 Thomas Jaskiewicz 2018-07-18 00:59:30 UTC
Fixed in version 6.1.1.113

Comment 5 Jakub Krysl 2018-08-30 14:59:20 UTC
As reproducing this is extremely hard (one has to dump traces of all threads and look for deadlocking conditions on the same memory ranges), sanity only testing was performed.
This passed on kmod-kvdo-6.1.1.120-2.el7.

Comment 7 errata-xmlrpc 2018-10-30 09:39:31 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3094