Skip to contentSkip to conversation

FAILED: patch "[PATCH] mm/madvise: handle madvise_lock() failure during race" failed to apply to 6.15-stable tree

PATCH In review [email protected] 3 participants 3 messages Jun 20, 2025 – Jun 21, 2025

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.15.y
git checkout FETCH_HEAD
git cherry-pick -x 9c49e5d09f076001e05537734d7df002162eb2b5
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025062020-gambling-poker-8b0c@gregkh' --subject-prefix 'PATCH 6.15.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 9c49e5d09f076001e05537734d7df002162eb2b5 Mon Sep 17 00:00:00 2001
From: SeongJae Park <[email protected]>
Date: Mon, 2 Jun 2025 10:49:26 -0700
Subject: [PATCH] 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.

mm/madvise.c +4 -1
index 8433ac9b27e0..5f7a66a1617e 100644
@@ -1881,7 +1881,9 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
 			/* Drop and reacquire lock to unwind race. */
 			madvise_finish_tlb(&madv_behavior);
 			madvise_unlock(mm, behavior);
-			madvise_lock(mm, behavior);
+			ret = madvise_lock(mm, behavior);
+			if (ret)
+				goto out;
 			madvise_init_tlb(&madv_behavior, mm);
 			continue;
 		}
@@ -1892,6 +1894,7 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
 	madvise_finish_tlb(&madv_behavior);
 	madvise_unlock(mm, behavior);
 
+out:
 	ret = (total_len - iov_iter_count(iter)) ? : ret;
 
 	return ret;
#1 lore raw

PATCH 1/1 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.

Fixes 4000e3d0a367 ("mm/madvise: remove redundant mmap_lock operations from process_madvise()")
Cc Liam Howlett <[email protected]>
Cc Vlastimil Babka <[email protected]>
(cherry picked from commit 9c49e5d09f076001e05537734d7df002162eb2b5)
---
 mm/madvise.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
mm/madvise.c +4 -1
index b17f684322ad..69510e737783 100644
@@ -1830,7 +1830,9 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
 
 			/* Drop and reacquire lock to unwind race. */
 			madvise_unlock(mm, behavior);
-			madvise_lock(mm, behavior);
+			ret = madvise_lock(mm, behavior);
+			if (ret)
+				goto out;
 			continue;
 		}
 		if (ret < 0)
@@ -1839,6 +1841,7 @@ static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
 	}
 	madvise_unlock(mm, behavior);
 
+out:
 	ret = (total_len - iov_iter_count(iter)) ? : ret;
 
 	return ret;
Signature · 1 line
2.39.5
maintainer
#2 lore raw

Re: [PATCH 6.15.y] mm/madvise: handle madvise_lock() failure during race unwinding

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it

Found matching upstream commit: 9c49e5d09f076001e05537734d7df002162eb2b5

Note: The patch differs from the upstream commit:
---
1: 9c49e5d09f076 ! 1: 0f9b85d494656 mm/madvise: handle madvise_lock() failure during race unwinding

    @@ Commit message
         Cc: Vlastimil Babka <[email protected]>
         Cc: <[email protected]>
         Signed-off-by: Andrew Morton <[email protected]>
    +    (cherry picked from commit 9c49e5d09f076001e05537734d7df002162eb2b5)
     
      ## mm/madvise.c ##
     @@ mm/madvise.c: static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
    + 
      			/* Drop and reacquire lock to unwind race. */
    - 			madvise_finish_tlb(&madv_behavior);
      			madvise_unlock(mm, behavior);
     -			madvise_lock(mm, behavior);
     +			ret = madvise_lock(mm, behavior);
     +			if (ret)
     +				goto out;
    - 			madvise_init_tlb(&madv_behavior, mm);
      			continue;
      		}
    + 		if (ret < 0)
     @@ mm/madvise.c: static ssize_t vector_madvise(struct mm_struct *mm, struct iov_iter *iter,
    - 	madvise_finish_tlb(&madv_behavior);
    + 	}
      	madvise_unlock(mm, behavior);
      
     +out:

---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.15.y       |  Success    |  Success   |