From: Dmitry Safonov <dsafonov@virtuozzo.com>
To: Oleg Nesterov <oleg@redhat.com>, Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Hugh Dickins <hughd@google.com>, Andrey Vagin <avagin@openvz.org>,
LKML <linux-kernel@vger.kernel.org>,
Pavel Emelyanov <xemul@virtuozzo.com>,
Andrew Morton <akpm@linuxfoundation.org>,
Adrian Reber <areber@redhat.com>
Subject: Re: [criu] 1M guard page ruined restore
Date: Wed, 21 Jun 2017 20:19:34 +0300 [thread overview]
Message-ID: <2551ee70-a4b6-4f38-7d3a-4eb2cddc96a5@virtuozzo.com> (raw)
In-Reply-To: <a747d0be-ddf9-d338-06de-223337a03a67@virtuozzo.com>
On 06/21/2017 08:15 PM, Dmitry Safonov wrote:
> On 06/21/2017 08:01 PM, Oleg Nesterov wrote:
>> On 06/21, Cyrill Gorcunov wrote:
>>>
>>> On Wed, Jun 21, 2017 at 05:57:30PM +0200, Oleg Nesterov wrote:
>>>>>
>>>>> p = fake_grow_down;
>>>>> *p-- = 'c';
>>>>
>>>> I guess this works? I mean, *p-- = 'c' should not fail...
>>>
>>> It fails.
>>
>> Hmm. Impossible ;) could you add the additional printf's to re-check?
>>
>>> Here is the complete code. It supposed to _extend_ stack but it fails
>>> on the latest master + Hugh's [PATCH] mm: fix new crash in
>>> unmapped_area_topdown()
>>> ---
>>> [root@fc2 criu]# ~/st2
>>> start_addr 7fe6162a8000
>>> start_addr 7fe6163d9000
>>> Segmentation fault (core dumped)
>>> ---
>>> #include <stdio.h>
>>> #include <stdlib.h>
>>> #include <errno.h>
>>> #include <stdlib.h>
>>> #include <string.h>
>>> #include <unistd.h>
>>>
>>> #include <sys/mman.h>
>>>
>>> #define PAGE_SIZE 4096
>>>
>>> int main(int argc, char **argv)
>>> {
>>> char *start_addr, *start_addr1, *fake_grow_down, *test_addr,
>>> *grow_down;
>>> volatile char *p;
>>>
>>> start_addr = mmap(NULL, PAGE_SIZE * 512, PROT_READ | PROT_WRITE,
>>> MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
>>> if (start_addr == MAP_FAILED) {
>>> printf("Can't mal a new region");
>>> return 1;
>>> }
>>> printf("start_addr %lx\n", start_addr);
>>> munmap(start_addr, PAGE_SIZE * 512);
>>>
>>> start_addr += PAGE_SIZE * 300;
>>>
>>> fake_grow_down = mmap(start_addr + PAGE_SIZE * 5, PAGE_SIZE,
>>> PROT_READ | PROT_WRITE,
>>> MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED | MAP_GROWSDOWN,
>>> -1, 0);
>>> if (fake_grow_down == MAP_FAILED) {
>>> printf("Can't mal a new region");
>>> return 1;
>>> }
>>> printf("start_addr %lx\n", fake_grow_down);
>>>
>>> p = fake_grow_down;
>>> *p-- = 'c';
>>
>> once again, I can't believe this STORE can fail...
>>
>>> *p = 'b';
>>
>> Ah. I forgot about another kernel "feature" ;) not related to the
>> recent guard
>> page changes...
>>
>> Could you test the patch below?
>
> Well, for me only the second store caused segfault.
> With your patch it passes..
The only question I have - how is it connected to guard page?
Before the former patch the test has passed. Why?
And this thing seems to be in kernel since 2009.
>
>>
>>
>> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
>> index 8ad91a0..edc5d68 100644
>> --- a/arch/x86/mm/fault.c
>> +++ b/arch/x86/mm/fault.c
>> @@ -1416,7 +1416,7 @@ __do_page_fault(struct pt_regs *regs, unsigned
>> long error_code,
>> * and pusha to work. ("enter $65535, $31" pushes
>> * 32 pointers and then decrements %sp by 65535.)
>> */
>> - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) <
>> regs->sp)) {
>> +if (0) if (unlikely(address + 65536 + 32 * sizeof(unsigned
>> long) < regs->sp)) {
>> bad_area(regs, error_code, address);
>> return;
>> }
>>
>
--
Dmitry
next prev parent reply other threads:[~2017-06-21 17:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 7:52 Cyrill Gorcunov
2017-06-20 10:23 ` Hugh Dickins
2017-06-20 10:41 ` Cyrill Gorcunov
2017-06-21 15:22 ` Cyrill Gorcunov
2017-06-21 15:48 ` Cyrill Gorcunov
2017-06-21 15:57 ` Oleg Nesterov
2017-06-21 16:04 ` Cyrill Gorcunov
2017-06-21 17:01 ` Oleg Nesterov
2017-06-21 17:15 ` Dmitry Safonov
2017-06-21 17:19 ` Dmitry Safonov [this message]
2017-06-21 17:31 ` Oleg Nesterov
2017-06-21 17:37 ` Dmitry Safonov
2017-06-21 17:52 ` Dmitry Safonov
2017-06-22 1:24 ` Hugh Dickins
2017-06-22 8:06 ` Cyrill Gorcunov
2017-06-21 17:15 ` Oleg Nesterov
2017-06-21 17:53 ` Cyrill Gorcunov
2017-06-21 17:16 ` Willy Tarreau
2017-06-22 14:23 ` Oleg Nesterov
2017-06-22 15:05 ` Cyrill Gorcunov
2017-06-20 10:51 ` Oleg Nesterov
2017-06-20 11:10 ` Cyrill Gorcunov
2017-06-20 11:55 ` Cyrill Gorcunov
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=2551ee70-a4b6-4f38-7d3a-4eb2cddc96a5@virtuozzo.com \
--to=dsafonov@virtuozzo.com \
--cc=akpm@linuxfoundation.org \
--cc=areber@redhat.com \
--cc=avagin@openvz.org \
--cc=gorcunov@gmail.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=xemul@virtuozzo.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
all inboxes | Powered by JetHome®