From: Song Liu <songliubraving@fb.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: open list <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"matthew.wilcox@oracle.com" <matthew.wilcox@oracle.com>,
Kernel Team <Kernel-team@fb.com>,
"william.kucharski@oracle.com" <william.kucharski@oracle.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Subject: Re: [PATCH 4/4] uprobe: only do FOLL_SPLIT_PMD for uprobe register
Date: Thu, 17 Oct 2019 14:05:19 +0000 [thread overview]
Message-ID: <A1DBC6EA-CBAB-45FE-919D-6D77D29DDE1D@fb.com> (raw)
In-Reply-To: <20191017084714.GB17513@redhat.com>
> On Oct 17, 2019, at 1:47 AM, Oleg Nesterov <oleg@redhat.com> wrote:
>
> On 10/16, Song Liu wrote:
>>
>>> On Oct 16, 2019, at 5:10 AM, Oleg Nesterov <oleg@redhat.com> wrote:
>>>
>>>> @@ -489,6 +492,9 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
>>>> if (ret <= 0)
>>>> goto put_old;
>>>>
>>>> + WARN(!is_register && PageCompound(old_page),
>>>> + "uprobe unregister should never work on compound page\n");
>>>
>>> But this can happen with the change above. You can't know if *vaddr was
>>> previously changed by install_breakpoint() or not.
>>
>>> If not, verify_opcode() should likely save us, but we can't rely on it.
>>> Say, someone can write "int3" into vm_file at uprobe->offset.
>>
>> I think this won't really happen. With is_register == false, we already
>> know opcode is not "int3", so current call must be from set_orig_insn().
>> Therefore, old_page must be installed by uprobe, and cannot be compound.
>>
>> The other way is not guaranteed. With is_register == true, it is still
>> possible current call is from set_orig_insn(). However, we do not rely
>> on this path.
>
> Quite contrary.
>
> When is_register == true we know that a) the caller is install_breakpoint()
> and b) the original insn is NOT int3 unless this page was alreadt COW'ed by
> userspace, say, by gdb.
>
> If is_register == false we only know that the caller is remove_breakpoint().
> We can't know if this page was COW'ed by uprobes or userspace, we can not
> know if the insn we are going to replace is int3 or not, thus we can not
> assume that verify_opcode() will fail and save us.
So the case we worry about is:
old_page is COW by user space, target insn is int3, and it is a huge page;
then uprobe calls remove_breakpoint();
Yeah, I guess this could happen.
For the fix, I guess return -Esomething in such case should be sufficient?
Thanks,
Song
next prev parent reply other threads:[~2019-10-17 14:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 7:37 [PATCH 0/4] Fixes for THP in page cache Song Liu
2019-10-16 7:37 ` [PATCH 1/4] proc/meminfo: fix output alignment Song Liu
2019-10-16 7:37 ` [PATCH 2/4] mm/thp: fix node page state in split_huge_page_to_list() Song Liu
2019-10-16 7:37 ` [PATCH 3/4] mm/thp: allow drop THP from page cache Song Liu
2019-10-17 16:12 ` Matthew Wilcox
2019-10-17 16:36 ` Song Liu
2019-10-16 7:37 ` [PATCH 4/4] uprobe: only do FOLL_SPLIT_PMD for uprobe register Song Liu
2019-10-16 12:10 ` Oleg Nesterov
2019-10-16 16:10 ` Song Liu
2019-10-17 8:47 ` Oleg Nesterov
2019-10-17 14:05 ` Song Liu [this message]
2019-10-17 14:28 ` Oleg Nesterov
2019-10-17 15:34 ` 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=A1DBC6EA-CBAB-45FE-919D-6D77D29DDE1D@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=akpm@linux-foundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=matthew.wilcox@oracle.com \
--cc=oleg@redhat.com \
--cc=srikar@linux.vnet.ibm.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