lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <279846b8-c7e1-40c3-823a-9a904ac48a62@suse.cz>
Date: Wed, 29 Jan 2025 15:45:28 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
 Andrew Morton <akpm@...ux-foundation.org>
Cc: "Liam R . Howlett" <Liam.Howlett@...cle.com>, Jann Horn
 <jannh@...gle.com>, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 4/5] mm: make vmg->target consistent and further simplify
 commit_merge()

On 1/27/25 16:50, Lorenzo Stoakes wrote:
> It is confusing for vmg->target to sometimes be the target merged VMA and
> in one case not.
> 
> Fix this by having commit_merge() use its awareness of the
> __VMG_FLAG_ADJUST_NEXT_START case to know that it is manipulating a
> separate vma, abstracted in the 'vma' local variable.
> 
> Place removal and adjust VMA determination logic into
> init_multi_vma_prep(), as the flags give us enough information to do so,
> and since this is the function that sets up the vma_prepare struct it makes
> sense to do so here.
> 
> Doing this significantly simplifies commit_merge(), allowing us to
> eliminate the 'merge_target' handling, initialise the VMA iterator in a
> more sensible place and simply return vmg->target consistently.
> 
> This also allows us to simplify setting vmg->target in
> vma_merge_existing_range() since we are then left only with two cases -
> merge left (or both) where the target is vmg->prev or merge right in which
> the target is vmg->next.
> 
> This makes it easy for somebody reading the code to know what VMA will
> actually be the one returned and merged into and removes a great deal of
> the confusing 'adjust' nonsense.
> 
> This patch has no change in functional behaviour.
> 
> Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>

Reviewed-by: Vlastimil Babka <vbabka@...e.cz>


> @@ -906,7 +911,6 @@ static __must_check struct vm_area_struct *vma_merge_existing_range(
>  			 * merged VMA is NOT vmg->target, but rather vmg->next.
>  			 */

Is this comment now also obsolete?

>  			vmg->merge_flags |= __VMG_FLAG_ADJUST_NEXT_START;
> -			vmg->target = middle;
>  			vmg->start = middle->vm_start;
>  			vmg->end = start;
>  			vmg->pgoff = middle->vm_pgoff;
> diff --git a/mm/vma.h b/mm/vma.h
> index ddf567359880..5be43e2bba3f 100644
> --- a/mm/vma.h
> +++ b/mm/vma.h
> @@ -113,11 +113,7 @@ struct vma_merge_struct {
>  	struct vm_area_struct *prev;
>  	struct vm_area_struct *middle;
>  	struct vm_area_struct *next;
> -	/*
> -	 * This is the VMA we ultimately target to become the merged VMA, except
> -	 * for the one exception of merge right, shrink next (for details of
> -	 * this scenario see vma_merge_existing_range()).
> -	 */
> +	/* This is the VMA we ultimately target to become the merged VMA. */
>  	struct vm_area_struct *target;
>  	/*
>  	 * Initially, the start, end, pgoff fields are provided by the caller


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ