From mboxrd@z Thu Jan 1 00:00:00 1970 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 287253DBD49 for ; Fri, 27 Mar 2026 09:16:32 +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=1774602993; cv=none; b=K6t7+its/HFZ7MDUttgJetXcPJKtorNhHqufP88qnKFYsZhelDqkh41FHb51HDee+E5mIbwEBmZvP35+V5Kk7ZQLS2WQG/46e5PJA8ERTA2FU0CpvfdIq1oCKCcgJXY0sPDD3BMTePKVSHM28BHerwUWICzPfD03B1tznkG0Kt4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774602993; c=relaxed/simple; bh=RA2+mnm1jePLgWpzmoLJsGPZhaLbocUvEdhhnN00Uh0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oVuCy5UCYfsT2D2SRLsEYsYncx8K8pYZuoQB+HDLXIuDXq7r73IXmNmCZ2WbGSfinLVFYD5h8rFoG40Kj+oRkXFAXE15hMz0/PByjAgaJem/ifaES0M3zFEbJezx2ZAcmaPYc0rJkMFGJDrm9pia7p7fGdlA9fxB0nfj1SoB+Hw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mIFg8aVL; 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="mIFg8aVL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7F41C19423; Fri, 27 Mar 2026 09:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774602992; bh=RA2+mnm1jePLgWpzmoLJsGPZhaLbocUvEdhhnN00Uh0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mIFg8aVLPSTmq8Rv94QjNKfuvs8E1kB7ttXFs491G7/ggD+gM+wusHpPgCNiJIahM xJtTi1gznRljpi/mnJJ6n5hyRoH6w0EsjrupxoUo8voigCx7cp0n4siS6m9Aw+wMOA AT1Izmy7aSZyyuTZ+Jss89NN6CZIa/otnc/0gCjN2RTOFzUtEa9MsX+27LXoq4X4GP emIfV+rr5K+88nw3G3XiNjKNiPDoZQ+k6EMqH6Ym6o5H4QY3m/BLUv5w5TZHlmi4Un ZcPSaeWsfXRwc2IYDlGza1rnmmyHVIcyNXpNKpQZQrSetsJphRda1U1mSZZgPDKZig dH6sCAPBXCUVg== Date: Fri, 27 Mar 2026 09:16:29 +0000 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: Re: [PATCH mm-hotfixes] mm/mseal: update VMA end correctly on merge Message-ID: References: <20260327090640.146308-1-ljs@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260327090640.146308-1-ljs@kernel.org> On Fri, Mar 27, 2026 at 09:06:40AM +0000, Lorenzo Stoakes (Oracle) wrote: > 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/CAK8a0jyHXqBpt8Xe8v9SNDbnRiwz7OthA8SKY=NLRY7smPEP3Q@mail.gmail.com/ Oops, Closes should be: https://lore.kernel.org/linux-mm/CAK8a0jwWGj9-SgFk0yKFh7i8jMkwKm5b0ao9=kmXWjO54veX2g@mail.gmail.com/ Cheers, Lorenzo > --- > 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 = vma; > > for_each_vma_range(vmi, vma, end) { > - const unsigned long curr_end = MIN(vma->vm_end, end); > + unsigned long curr_end = MIN(vma->vm_end, end); > > if (!(vma->vm_flags & VM_SEALED)) { > vm_flags_t vm_flags = 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 = vma->vm_end; /* Merge may have updated. */ > } > > prev = vma; > -- > 2.53.0