public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, lorenzo.stoakes@oracle.com
Cc: Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 6.12.y] mm/vma: add give_up_on_oom option on modify/merge, use in uffd release
Date: Tue, 22 Apr 2025 15:17:56 -0400	[thread overview]
Message-ID: <20250422123659-a06f5f388320cbae@stable.kernel.org> (raw)
In-Reply-To: <20250422113216.110404-1-lorenzo.stoakes@oracle.com>

[ 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: 41e6ddcaa0f18dda4c3fadf22533775a30d6f72f

Status in newer kernel trees:
6.14.y | Not found

Note: The patch differs from the upstream commit:
---
1:  41e6ddcaa0f18 ! 1:  80c1bca5589f9 mm/vma: add give_up_on_oom option on modify/merge, use in uffd release
    @@ Commit message
         Suggested-by: Jann Horn <jannh@google.com>
         Cc: <stable@vger.kernel.org>
         Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    +    (cherry picked from commit 41e6ddcaa0f18dda4c3fadf22533775a30d6f72f)
     
      ## mm/userfaultfd.c ##
     @@ mm/userfaultfd.c: struct vm_area_struct *userfaultfd_clear_vma(struct vma_iterator *vmi,
    @@ mm/userfaultfd.c: int userfaultfd_register_range(struct userfaultfd_ctx *ctx,
      
     
      ## mm/vma.c ##
    -@@ mm/vma.c: static void vmg_adjust_set_range(struct vma_merge_struct *vmg)
    - /*
    -  * Actually perform the VMA merge operation.
    -  *
    -+ * IMPORTANT: We guarantee that, should vmg->give_up_on_oom is set, to not
    -+ * modify any VMAs or cause inconsistent state should an OOM condition arise.
    -+ *
    -  * Returns 0 on success, or an error value on failure.
    -  */
    - static int commit_merge(struct vma_merge_struct *vmg)
    -@@ mm/vma.c: static int commit_merge(struct vma_merge_struct *vmg)
    - 
    - 	init_multi_vma_prep(&vp, vma, vmg);
    - 
    -+	/*
    -+	 * If vmg->give_up_on_oom is set, we're safe, because we don't actually
    -+	 * manipulate any VMAs until we succeed at preallocation.
    -+	 *
    -+	 * Past this point, we will not return an error.
    -+	 */
    - 	if (vma_iter_prealloc(vmg->vmi, vma))
    - 		return -ENOMEM;
    - 
    -@@ mm/vma.c: static __must_check struct vm_area_struct *vma_merge_existing_range(
    +@@ mm/vma.c: static struct vm_area_struct *vma_merge_existing_range(struct vma_merge_struct *
      		if (anon_dup)
      			unlink_anon_vmas(anon_dup);
      
    @@ mm/vma.c: static __must_check struct vm_area_struct *vma_merge_existing_range(
      		return NULL;
      	}
      
    -@@ mm/vma.c: static __must_check struct vm_area_struct *vma_merge_existing_range(
    +@@ mm/vma.c: static struct vm_area_struct *vma_merge_existing_range(struct vma_merge_struct *
      abort:
      	vma_iter_set(vmg->vmi, start);
      	vma_iter_load(vmg->vmi);
    @@ mm/vma.c: static __must_check struct vm_area_struct *vma_merge_existing_range(
      	return NULL;
      }
      
    -@@ mm/vma.c: int vma_expand(struct vma_merge_struct *vmg)
    - 		/* This should already have been checked by this point. */
    - 		VM_WARN_ON_VMG(!can_merge_remove_vma(next), vmg);
    - 		vma_start_write(next);
    -+		/*
    -+		 * In this case we don't report OOM, so vmg->give_up_on_mm is
    -+		 * safe.
    -+		 */
    - 		ret = dup_anon_vma(middle, next, &anon_dup);
    - 		if (ret)
    - 			return ret;
     @@ mm/vma.c: int vma_expand(struct vma_merge_struct *vmg)
      	return 0;
      
    @@ mm/vma.c: struct vm_area_struct
     
      ## mm/vma.h ##
     @@ mm/vma.h: struct vma_merge_struct {
    - 	 */
    - 	bool just_expand :1;
    - 
    + 	struct anon_vma_name *anon_name;
    + 	enum vma_merge_flags merge_flags;
    + 	enum vma_merge_state state;
    ++
     +	/*
     +	 * If a merge is possible, but an OOM error occurs, give up and don't
     +	 * execute the merge, returning NULL.
     +	 */
     +	bool give_up_on_oom :1;
    -+
    - 	/* Internal flags set during merge process: */
    + };
      
    - 	/*
    -@@ mm/vma.h: __must_check struct vm_area_struct
    + static inline bool vmg_nomem(struct vma_merge_struct *vmg)
    +@@ mm/vma.h: struct vm_area_struct
      		       struct vm_area_struct *vma,
      		       unsigned long start, unsigned long end,
      		       unsigned long new_flags,
    @@ mm/vma.h: __must_check struct vm_area_struct
     +		       struct vm_userfaultfd_ctx new_ctx,
     +		       bool give_up_on_oom);
      
    - __must_check struct vm_area_struct
    - *vma_merge_new_range(struct vma_merge_struct *vmg);
    + struct vm_area_struct *vma_merge_new_range(struct vma_merge_struct *vmg);
    + 
---

Results of testing on various branches:

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

      reply	other threads:[~2025-04-22 19:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21 13:57 FAILED: patch "[PATCH] mm/vma: add give_up_on_oom option on modify/merge, use in" failed to apply to 6.12-stable tree gregkh
2025-04-22 11:32 ` [PATCH 6.12.y] mm/vma: add give_up_on_oom option on modify/merge, use in uffd release Lorenzo Stoakes
2025-04-22 19:17   ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250422123659-a06f5f388320cbae@stable.kernel.org \
    --to=sashal@kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox