All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Safonov <dsafonov@virtuozzo.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: <linux-kernel@vger.kernel.org>, <0x7f454c46@gmail.com>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@suse.de>,
	<x86@kernel.org>, <linux-mm@kvack.org>
Subject: Re: [PATCHv4 3/5] x86/mm: fix 32-bit mmap() for 64-bit ELF
Date: Tue, 14 Feb 2017 18:24:23 +0300	[thread overview]
Message-ID: <397ddf67-92bb-f210-bb8b-09580db41385@virtuozzo.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1702111513460.3734@nanos>

On 02/11/2017 10:49 PM, Thomas Gleixner wrote:
> On Mon, 30 Jan 2017, Dmitry Safonov wrote:
>
>> Fix 32-bit compat_sys_mmap() mapping VMA over 4Gb in 64-bit binaries
>> and 64-bit sys_mmap() mapping VMA only under 4Gb in 32-bit binaries.
>> Introduced new bases for compat syscalls in mm_struct:
>> mmap_compat_base and mmap_compat_legacy_base for top-down and
>> bottom-up allocations accordingly.
>> Taught arch_get_unmapped_area{,_topdown}() to use the new mmap_bases
>> in compat syscalls for high/low limits in vm_unmapped_area().
>>
>> I discovered that bug on ZDTM tests for compat 32-bit C/R.
>> Working compat sys_mmap() in 64-bit binaries is really needed for that
>> purpose, as 32-bit applications are restored from 64-bit CRIU binary.
>
> Again that changelog sucks.
>
> Explain the problem/bug first. Then explain the way to fix it and do not
> tell fairy tales about what you did without explaing the bug in the first
> place.
>
> Documentation....SubittingPatches explains that very well.

Rewrote changelog.

>> +config HAVE_ARCH_COMPAT_MMAP_BASES
>> +	bool
>> +	help
>> +	  If this is set, one program can do native and compatible syscall
>> +	  mmap() on architecture. Thus kernel has different bases to
>> +	  compute high and low virtual address limits for allocation.
>
> Sigh. How is a user supposed to decode this?
>
> 	  This allows 64bit applications to invoke syscalls in 64bit and
> 	  32bit mode. Required for ....

Ok

>>
>> @@ -113,10 +114,19 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
>>  		if (current->flags & PF_RANDOMIZE) {
>>  			*begin = randomize_page(*begin, 0x02000000);
>>  		}
>> -	} else {
>> -		*begin = current->mm->mmap_legacy_base;
>> -		*end = TASK_SIZE;
>> +		return;
>>  	}
>> +
>> +#ifdef CONFIG_COMPAT
>
> Can you please find a solution which does not create that ifdef horror in
> the code? Just a few accessors to those compat fields are required to do
> that.

I'll try

>> +
>> +#ifdef CONFIG_COMPAT
>> +	arch_pick_mmap_base(&mm->mmap_compat_base, &mm->mmap_compat_legacy_base,
>> +			arch_compat_rnd(), IA32_PAGE_OFFSET);
>> +#endif
>
> Ditto
>
> Thanks,
>
> 	tglx
>


-- 
              Dmitry

WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Safonov <dsafonov@virtuozzo.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, 0x7f454c46@gmail.com,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@suse.de>,
	x86@kernel.org, linux-mm@kvack.org
Subject: Re: [PATCHv4 3/5] x86/mm: fix 32-bit mmap() for 64-bit ELF
Date: Tue, 14 Feb 2017 18:24:23 +0300	[thread overview]
Message-ID: <397ddf67-92bb-f210-bb8b-09580db41385@virtuozzo.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1702111513460.3734@nanos>

On 02/11/2017 10:49 PM, Thomas Gleixner wrote:
> On Mon, 30 Jan 2017, Dmitry Safonov wrote:
>
>> Fix 32-bit compat_sys_mmap() mapping VMA over 4Gb in 64-bit binaries
>> and 64-bit sys_mmap() mapping VMA only under 4Gb in 32-bit binaries.
>> Introduced new bases for compat syscalls in mm_struct:
>> mmap_compat_base and mmap_compat_legacy_base for top-down and
>> bottom-up allocations accordingly.
>> Taught arch_get_unmapped_area{,_topdown}() to use the new mmap_bases
>> in compat syscalls for high/low limits in vm_unmapped_area().
>>
>> I discovered that bug on ZDTM tests for compat 32-bit C/R.
>> Working compat sys_mmap() in 64-bit binaries is really needed for that
>> purpose, as 32-bit applications are restored from 64-bit CRIU binary.
>
> Again that changelog sucks.
>
> Explain the problem/bug first. Then explain the way to fix it and do not
> tell fairy tales about what you did without explaing the bug in the first
> place.
>
> Documentation....SubittingPatches explains that very well.

Rewrote changelog.

>> +config HAVE_ARCH_COMPAT_MMAP_BASES
>> +	bool
>> +	help
>> +	  If this is set, one program can do native and compatible syscall
>> +	  mmap() on architecture. Thus kernel has different bases to
>> +	  compute high and low virtual address limits for allocation.
>
> Sigh. How is a user supposed to decode this?
>
> 	  This allows 64bit applications to invoke syscalls in 64bit and
> 	  32bit mode. Required for ....

Ok

>>
>> @@ -113,10 +114,19 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
>>  		if (current->flags & PF_RANDOMIZE) {
>>  			*begin = randomize_page(*begin, 0x02000000);
>>  		}
>> -	} else {
>> -		*begin = current->mm->mmap_legacy_base;
>> -		*end = TASK_SIZE;
>> +		return;
>>  	}
>> +
>> +#ifdef CONFIG_COMPAT
>
> Can you please find a solution which does not create that ifdef horror in
> the code? Just a few accessors to those compat fields are required to do
> that.

I'll try

>> +
>> +#ifdef CONFIG_COMPAT
>> +	arch_pick_mmap_base(&mm->mmap_compat_base, &mm->mmap_compat_legacy_base,
>> +			arch_compat_rnd(), IA32_PAGE_OFFSET);
>> +#endif
>
> Ditto
>
> Thanks,
>
> 	tglx
>


-- 
              Dmitry

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-02-14 15:28 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-30 12:04 [PATCHv4 0/5] Fix compatible mmap() return pointer over 4Gb Dmitry Safonov
2017-01-30 12:04 ` Dmitry Safonov
2017-01-30 12:04 ` [PATCHv4 1/5] x86/mm: split arch_mmap_rnd() on compat/native versions Dmitry Safonov
2017-01-30 12:04   ` Dmitry Safonov
2017-02-09 13:55   ` Borislav Petkov
2017-02-09 23:06     ` Andy Lutomirski
2017-02-09 23:06       ` Andy Lutomirski
2017-02-10 20:10     ` Thomas Gleixner
2017-02-10 20:10       ` Thomas Gleixner
2017-02-10 20:25       ` Borislav Petkov
2017-02-10 20:25         ` Borislav Petkov
2017-02-10 21:28       ` Dmitry Safonov
2017-02-10 21:28         ` Dmitry Safonov
2017-02-11  8:23         ` Thomas Gleixner
2017-02-11  8:23           ` Thomas Gleixner
2017-02-13 11:12           ` Dmitry Safonov
2017-02-13 11:12             ` Dmitry Safonov
2017-02-13 11:22             ` Thomas Gleixner
2017-02-13 11:22               ` Thomas Gleixner
2017-01-30 12:04 ` [PATCHv4 2/5] x86/mm: introduce mmap{,_legacy}_base Dmitry Safonov
2017-01-30 12:04   ` Dmitry Safonov
2017-02-11 14:13   ` Thomas Gleixner
2017-02-11 14:13     ` Thomas Gleixner
2017-02-13 13:02     ` Dmitry Safonov
2017-02-13 13:02       ` Dmitry Safonov
2017-02-13 13:13       ` Thomas Gleixner
2017-02-13 13:13         ` Thomas Gleixner
2017-02-13 14:37     ` Dmitry Safonov
2017-02-13 14:37       ` Dmitry Safonov
2017-02-13 15:35       ` Thomas Gleixner
2017-02-13 15:35         ` Thomas Gleixner
2017-01-30 12:04 ` [PATCHv4 3/5] x86/mm: fix 32-bit mmap() for 64-bit ELF Dmitry Safonov
2017-01-30 12:04   ` Dmitry Safonov
2017-02-11 19:49   ` Thomas Gleixner
2017-02-11 19:49     ` Thomas Gleixner
2017-02-14 15:24     ` Dmitry Safonov [this message]
2017-02-14 15:24       ` Dmitry Safonov
2017-01-30 12:04 ` [PATCHv4 4/5] x86/mm: check in_compat_syscall() instead TIF_ADDR32 for mmap(MAP_32BIT) Dmitry Safonov
2017-01-30 12:04   ` Dmitry Safonov
2017-02-11 20:13   ` Thomas Gleixner
2017-02-11 20:13     ` Thomas Gleixner
2017-02-14 16:11     ` Dmitry Safonov
2017-02-14 16:11       ` Dmitry Safonov
2017-02-14 16:14       ` Dmitry Safonov
2017-02-14 16:14         ` Dmitry Safonov
2017-01-30 12:04 ` [PATCHv4 5/5] selftests/x86: add test to check compat mmap() return addr Dmitry Safonov
2017-01-30 12:04   ` Dmitry Safonov
2017-02-06 16:46 ` [PATCHv4 0/5] Fix compatible mmap() return pointer over 4Gb Dmitry Safonov
2017-02-06 16:46   ` Dmitry Safonov

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=397ddf67-92bb-f210-bb8b-09580db41385@virtuozzo.com \
    --to=dsafonov@virtuozzo.com \
    --cc=0x7f454c46@gmail.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.