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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170913112509.mus2fuccajoe2l25@dhcp22.suse.cz>
Date:   Wed, 13 Sep 2017 13:25:09 +0200
From:   Michal Hocko <mhocko@...nel.org>
To:     Kirill Tkhai <ktkhai@...tuozzo.com>
Cc:     akpm@...ux-foundation.org, aarcange@...hat.com, minchan@...nel.org,
        zhongjiang@...wei.com, mingo@...nel.org,
        imbrenda@...ux.vnet.ibm.com, kirill.shutemov@...ux.intel.com,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Hugh Dickins <hughd@...gle.com>
Subject: Re: [PATCH] ksm: Fix unlocked iteration over vmas in
 cmp_and_merge_page()

[CC Claudio and Hugh]

On Mon 11-09-17 14:05:05, Kirill Tkhai wrote:
> In this place mm is unlocked, so vmas or list may change.
> Down read mmap_sem to protect them from modifications.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@...tuozzo.com>
> (and compile-tested-by)

Fixes: e86c59b1b12d ("mm/ksm: improve deduplication of zero pages with colouring")
AFAICS. Maybe even CC: stable as unstable vma can cause large variety of
issues including memory corruption.

The fix lookds good to me
Acked-by: Michal Hocko <mhocko@...e.com>

> ---
>  mm/ksm.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/ksm.c b/mm/ksm.c
> index db20f8436bc3..86f0db3d6cdb 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -1990,6 +1990,7 @@ static void stable_tree_append(struct rmap_item *rmap_item,
>   */
>  static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
>  {
> +	struct mm_struct *mm = rmap_item->mm;
>  	struct rmap_item *tree_rmap_item;
>  	struct page *tree_page = NULL;
>  	struct stable_node *stable_node;
> @@ -2062,9 +2063,11 @@ static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
>  	if (ksm_use_zero_pages && (checksum == zero_checksum)) {
>  		struct vm_area_struct *vma;
>  
> -		vma = find_mergeable_vma(rmap_item->mm, rmap_item->address);
> +		down_read(&mm->mmap_sem);
> +		vma = find_mergeable_vma(mm, rmap_item->address);
>  		err = try_to_merge_one_page(vma, page,
>  					    ZERO_PAGE(rmap_item->address));
> +		up_read(&mm->mmap_sem);
>  		/*
>  		 * In case of failure, the page was not really empty, so we
>  		 * need to continue. Otherwise we're done.
> 

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ