linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Song Liu <songliubraving@fb.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, matthew.wilcox@oracle.com,
	kirill.shutemov@linux.intel.com, peterz@infradead.org,
	rostedt@goodmis.org, kernel-team@fb.com,
	william.kucharski@oracle.com
Subject: Re: [PATCH v8 2/4] uprobe: use original page when all uprobes are removed
Date: Wed, 24 Jul 2019 13:37:11 +0200	[thread overview]
Message-ID: <20190724113711.GE21599@redhat.com> (raw)
In-Reply-To: <20190724083600.832091-3-songliubraving@fb.com>

On 07/24, Song Liu wrote:
>
>  	lock_page(old_page);
> @@ -177,15 +180,24 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
>  	mmu_notifier_invalidate_range_start(&range);
>  	err = -EAGAIN;
>  	if (!page_vma_mapped_walk(&pvmw)) {
> -		mem_cgroup_cancel_charge(new_page, memcg, false);
> +		if (!orig)
> +			mem_cgroup_cancel_charge(new_page, memcg, false);
>  		goto unlock;
>  	}
>  	VM_BUG_ON_PAGE(addr != pvmw.address, old_page);
>  
>  	get_page(new_page);
> -	page_add_new_anon_rmap(new_page, vma, addr, false);
> -	mem_cgroup_commit_charge(new_page, memcg, false, false);
> -	lru_cache_add_active_or_unevictable(new_page, vma);
> +	if (orig) {
> +		lock_page(new_page);  /* for page_add_file_rmap() */
> +		page_add_file_rmap(new_page, false);


Shouldn't we re-check new_page->mapping after lock_page() ? Or we can't
race with truncate?


and I am worried this code can try to lock the same page twice...
Say, the probed application does MADV_DONTNEED and then writes "int3"
into vma->vm_file at the same address to fool verify_opcode().

Oleg.


  parent reply	other threads:[~2019-07-24 11:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-24  8:35 [PATCH v8 0/4] THP aware uprobe Song Liu
2019-07-24  8:35 ` [PATCH v8 1/4] mm: move memcmp_pages() and pages_identical() Song Liu
2019-07-24  8:35 ` [PATCH v8 2/4] uprobe: use original page when all uprobes are removed Song Liu
2019-07-24  9:07   ` Oleg Nesterov
2019-07-24  9:17     ` Oleg Nesterov
2019-07-24  9:20       ` Song Liu
2019-07-24 11:37   ` Oleg Nesterov [this message]
2019-07-24 18:52     ` Song Liu
2019-07-25  8:14       ` Oleg Nesterov
2019-07-25 18:17         ` Song Liu
2019-07-26  6:07           ` Song Liu
2019-07-26  8:44           ` Oleg Nesterov
2019-07-26 21:19             ` Song Liu
2019-07-24  8:35 ` [PATCH v8 3/4] mm, thp: introduce FOLL_SPLIT_PMD Song Liu
2019-07-24  8:36 ` [PATCH v8 4/4] uprobe: use FOLL_SPLIT_PMD instead of FOLL_SPLIT Song Liu

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=20190724113711.GE21599@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=kernel-team@fb.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.wilcox@oracle.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=songliubraving@fb.com \
    --cc=william.kucharski@oracle.com \
    /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