Skip to content

Commit 9c49e5d

Browse files
sjp38akpm00
authored andcommitted
mm/madvise: handle madvise_lock() failure during race unwinding
When unwinding race on -ERESTARTNOINTR handling of process_madvise(), madvise_lock() failure is ignored. Check the failure and abort remaining works in the case. Link: https://lkml.kernel.org/r/[email protected] Fixes: 4000e3d ("mm/madvise: remove redundant mmap_lock operations from process_madvise()") Signed-off-by: SeongJae Park <[email protected]> Reported-by: Barry Song <[email protected]> Closes: https://lore.kernel.org/CAGsJ_4xJXXO0G+4BizhohSZ4yDteziPw43_uF8nPXPWxUVChzw@mail.gmail.com Reviewed-by: Jann Horn <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Acked-by: David Hildenbrand <[email protected]> Reviewed-by: Shakeel Butt <[email protected]> Reviewed-by: Barry Song <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6840881 commit 9c49e5d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mm/madvise.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,9 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
18811881
/* Drop and reacquire lock to unwind race. */
18821882
madvise_finish_tlb(&madv_behavior);
18831883
madvise_unlock(mm, behavior);
1884-
madvise_lock(mm, behavior);
1884+
ret = madvise_lock(mm, behavior);
1885+
if (ret)
1886+
goto out;
18851887
madvise_init_tlb(&madv_behavior, mm);
18861888
continue;
18871889
}
@@ -1892,6 +1894,7 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
18921894
madvise_finish_tlb(&madv_behavior);
18931895
madvise_unlock(mm, behavior);
18941896

1897+
out:
18951898
ret = (total_len - iov_iter_count(iter)) ? : ret;
18961899

18971900
return ret;

0 commit comments

Comments
 (0)