]> git.baikalelectronics.ru Git - kernel.git/commit
mm: fix anon_vma_clone() error treatment
authorDaniel Forrest <dan.forrest@ssec.wisc.edu>
Tue, 2 Dec 2014 23:59:42 +0000 (15:59 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 3 Dec 2014 17:36:04 +0000 (09:36 -0800)
commit1d2a263a7cc53dcea220dadb4184a76d7889ee5a
tree528a94f26b4e2bc1ca8652a6dfa9a34d746c4d4f
parent7869b77723b2a361c9bd73c435c9a88f4615431e
mm: fix anon_vma_clone() error treatment

Andrew Morton noticed that the error return from anon_vma_clone() was
being dropped and replaced with -ENOMEM (which is not itself a bug
because the only error return value from anon_vma_clone() is -ENOMEM).

I did an audit of callers of anon_vma_clone() and discovered an actual
bug where the error return was being lost.  In __split_vma(), between
Linux 3.11 and 3.12 the code was changed so the err variable is used
before the call to anon_vma_clone() and the default initial value of
-ENOMEM is overwritten.  So a failure of anon_vma_clone() will return
success since err at this point is now zero.

Below is a patch which fixes this bug and also propagates the error
return value from anon_vma_clone() in all cases.

Fixes: 815fc50dfc21 ("mm: mempolicy: turn vma_set_policy() into vma_dup_policy()")
Signed-off-by: Daniel Forrest <dan.forrest@ssec.wisc.edu>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Tim Hartrick <tim@edgecast.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org> [3.12+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/mmap.c
mm/rmap.c