From nobody Thu Apr 2 17:01:54 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14A8130F7F7 for ; Fri, 27 Mar 2026 09:06:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774602412; cv=none; b=UpQz2fVoGXo4pZFITBul2j1u2HjihopIJ2Tyd1SqRGMj5H4LxO8DIHeKxiwLIL6ebZLWmlSU5wgBY0ZMQuLC4IWswLTTlo7MIwT06XXsRL9VwZmBhZ6Z76XbPwJWpbxXPxjTff5UEZJ0hOYT3VkETSdjv8TvPQVVI8Vh17bgsK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774602412; c=relaxed/simple; bh=zCUe+10pc9NzniBg+3H/fjkn66/IAuhTCiP2Sjn9XC8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=naHu67mOTB0ajeP/9Ed8BQsUkDqZETzED6b8PawGJFV3RInSmlC9yMRfy+RA6J1qJeHXZQ7T8mmKbAQ4y4oCqA6RLKMcWYyiHQwsdWy0O7QgH/jlCo0fVSwZ8PNWSXGX0s2/jZlpsEq3izuOkgAbgZyDQFcA0DWXmFBJsmLjRgc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UaQ7wuq2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UaQ7wuq2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25144C19423; Fri, 27 Mar 2026 09:06:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774602411; bh=zCUe+10pc9NzniBg+3H/fjkn66/IAuhTCiP2Sjn9XC8=; h=From:To:Cc:Subject:Date:From; b=UaQ7wuq2LAVDVorSRlR0v5oN+8l1EEzicAlpp5W4EDxXAK5kRe8atolhh4sMDtikF 3mTTtK3OCvoA4Rm1nxfitvZTBUQt2rjQjG6P337FZlyKL5jLrNemJ9S7nuVORSJKvj BH3ROLdHgu12qlZvVYwXiGOeQnKO+F09fYDRGKr0vdTuhcSZpKm16qbuMvfyuPpdhh TQs1+wMN1T1InPplQ3whdLM/FxnK8uF5Vxkx8G66Pb/oHem1/jMVYGY0YxvNijyhhy 3uzDNAnjDM3hZ1b/hZVkB5dPgh4rKuLJ77L0AspVA4So2lkk3aW2xUJvFQH6oNB371 oS64tR6eMLAQg== From: "Lorenzo Stoakes (Oracle)" To: Andrew Morton Cc: "Liam R . Howlett" , Vlastimil Babka , Jann Horn , Pedro Falcato , Jeff Xu , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, antonius Subject: [PATCH mm-hotfixes] mm/mseal: update VMA end correctly on merge Date: Fri, 27 Mar 2026 09:06:40 +0000 Message-ID: <20260327090640.146308-1-ljs@kernel.org> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previously we stored the end of the current VMA in curr_end, and then upon iterating to the next VMA updated curr_start to curr_end to advance to the next VMA. However, this doesn't take into account the fact that a VMA might be updated due to a merge by vma_modify_flags(), which can result in curr_end being stale and thus, upon setting curr_start to curr_end, ending up with an incorrect curr_start on the next iteration. Resolve the issue by setting curr_end to vma->vm_end unconditionally to ensure this value remains updated should this occur. Signed-off-by: Lorenzo Stoakes (Oracle) Fixes: 6c2da14ae1e0 ("mm/mseal: rework mseal apply logic") Cc: Reported-by: Antonius Closes: https://lore.kernel.org/linux-mm/CAK8a0jyHXqBpt8Xe8v9SNDbnRiwz7OthA= 8SKY=3DNLRY7smPEP3Q@mail.gmail.com/ Acked-by: Vlastimil Babka (SUSE) Reviewed-by: Pedro Falcato --- mm/mseal.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/mseal.c b/mm/mseal.c index 316b5e1dec78..2d72a15d8ea1 100644 --- a/mm/mseal.c +++ b/mm/mseal.c @@ -66,7 +66,7 @@ static int mseal_apply(struct mm_struct *mm, prev =3D vma; for_each_vma_range(vmi, vma, end) { - const unsigned long curr_end =3D MIN(vma->vm_end, end); + unsigned long curr_end =3D MIN(vma->vm_end, end); if (!(vma->vm_flags & VM_SEALED)) { vm_flags_t vm_flags =3D vma->vm_flags | VM_SEALED; @@ -76,6 +76,7 @@ static int mseal_apply(struct mm_struct *mm, if (IS_ERR(vma)) return PTR_ERR(vma); vm_flags_set(vma, VM_SEALED); + curr_end =3D vma->vm_end; /* Merge may have updated. */ } prev =3D vma; -- 2.53.0