Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1599153 > unrolled thread

Re: [PATCHv6 4/5] x86/mm: check in_compat_syscall() instead TIF_ADDR32 for mmap(MAP_32BIT)

Started byThomas Gleixner <tglx@linutronix.de>
First post2017-03-13 10:50 +0100
Last post2017-03-13 16:40 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCHv6 4/5] x86/mm: check in_compat_syscall() instead TIF_ADDR32  for mmap(MAP_32BIT) Thomas Gleixner <tglx@linutronix.de> - 2017-03-13 10:50 +0100
    Re: [PATCHv6 4/5] x86/mm: check in_compat_syscall() instead TIF_ADDR32  for mmap(MAP_32BIT) Thomas Gleixner <tglx@linutronix.de> - 2017-03-13 14:50 +0100
      Re: [PATCHv6 4/5] x86/mm: check in_compat_syscall() instead TIF_ADDR32  for mmap(MAP_32BIT) Thomas Gleixner <tglx@linutronix.de> - 2017-03-13 15:10 +0100
      Re: [PATCHv6 4/5] x86/mm: check in_compat_syscall() instead  TIF_ADDR32 for mmap(MAP_32BIT) Andy Lutomirski <luto@amacapital.net> - 2017-03-13 16:40 +0100

#1599153 — Re: [PATCHv6 4/5] x86/mm: check in_compat_syscall() instead TIF_ADDR32 for mmap(MAP_32BIT)

FromThomas Gleixner <tglx@linutronix.de>
Date2017-03-13 10:50 +0100
SubjectRe: [PATCHv6 4/5] x86/mm: check in_compat_syscall() instead TIF_ADDR32 for mmap(MAP_32BIT)
Message-ID<tkuM3-717-27@gated-at.bofh.it>
On Mon, 6 Mar 2017, Dmitry Safonov wrote:

> Result of mmap() calls with MAP_32BIT flag at this moment depends
> on thread flag TIF_ADDR32, which is set during exec() for 32-bit apps.
> It's broken as the behavior of mmap() shouldn't depend on exec-ed
> application's bitness. Instead, it should check the bitness of mmap()
> syscall.
> How it worked before:
> o for 32-bit compatible binaries it is completely ignored. Which was
> fine when there were one mmap_base, computed for 32-bit syscalls.
> After introducing mmap_compat_base 64-bit syscalls do use computed
> for 64-bit syscalls mmap_base, which means that we can allocate 64-bit
> address with 64-bit syscall in application launched from 32-bit
> compatible binary. And ignoring this flag is not expected behavior.

Well, the real question here is, whether we should allow 32bit applications
to obtain 64bit mappings at all. We can very well force 32bit applications
into the 4GB address space as it was before your mmap base splitup and be
done with it.

Thanks,

	tglx

[toc] | [next] | [standalone]


#1599388

FromThomas Gleixner <tglx@linutronix.de>
Date2017-03-13 14:50 +0100
Message-ID<tkywi-1es-37@gated-at.bofh.it>
In reply to#1599153
On Mon, 13 Mar 2017, Dmitry Safonov wrote:
> On 03/13/2017 12:39 PM, Thomas Gleixner wrote:
> > On Mon, 6 Mar 2017, Dmitry Safonov wrote:
> > 
> > > Result of mmap() calls with MAP_32BIT flag at this moment depends
> > > on thread flag TIF_ADDR32, which is set during exec() for 32-bit apps.
> > > It's broken as the behavior of mmap() shouldn't depend on exec-ed
> > > application's bitness. Instead, it should check the bitness of mmap()
> > > syscall.
> > > How it worked before:
> > > o for 32-bit compatible binaries it is completely ignored. Which was
> > > fine when there were one mmap_base, computed for 32-bit syscalls.
> > > After introducing mmap_compat_base 64-bit syscalls do use computed
> > > for 64-bit syscalls mmap_base, which means that we can allocate 64-bit
> > > address with 64-bit syscall in application launched from 32-bit
> > > compatible binary. And ignoring this flag is not expected behavior.
> > 
> > Well, the real question here is, whether we should allow 32bit applications
> > to obtain 64bit mappings at all. We can very well force 32bit applications
> > into the 4GB address space as it was before your mmap base splitup and be
> > done with it.
> 
> Hmm, yes, we could restrict 32bit applications to 32bit mappings only.
> But the approach which I tried to follow in the patches set, it was do
> not base the logic on the bitness of launched applications
> (native/compat) - only base on bitness of the performing syscall.
> The idea was suggested by Andy and I made mmap() logic here independent
> from original application's bitness.
> 
> It also seems to me simpler:
> if 32-bit application wants to allocate 64-bit mapping, it should
> long-jump with 64-bit segment descriptor and do `syscall` instruction
> for 64-bit syscall entry path. So, in my point of view after this dance
> the application does not differ much from native 64-bit binary and can
> have 64-bit address mapping.

Works for me, but it lacks documentation .....

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1599405

FromThomas Gleixner <tglx@linutronix.de>
Date2017-03-13 15:10 +0100
Message-ID<tkyPD-1D6-15@gated-at.bofh.it>
In reply to#1599388
On Mon, 13 Mar 2017, Dmitry Safonov wrote:
> On 03/13/2017 04:47 PM, Thomas Gleixner wrote:
> > On Mon, 13 Mar 2017, Dmitry Safonov wrote:
> > > On 03/13/2017 12:39 PM, Thomas Gleixner wrote:
> > > > On Mon, 6 Mar 2017, Dmitry Safonov wrote:
> > > > 
> > > > > Result of mmap() calls with MAP_32BIT flag at this moment depends
> > > > > on thread flag TIF_ADDR32, which is set during exec() for 32-bit apps.
> > > > > It's broken as the behavior of mmap() shouldn't depend on exec-ed
> > > > > application's bitness. Instead, it should check the bitness of mmap()
> > > > > syscall.
> > > > > How it worked before:
> > > > > o for 32-bit compatible binaries it is completely ignored. Which was
> > > > > fine when there were one mmap_base, computed for 32-bit syscalls.
> > > > > After introducing mmap_compat_base 64-bit syscalls do use computed
> > > > > for 64-bit syscalls mmap_base, which means that we can allocate 64-bit
> > > > > address with 64-bit syscall in application launched from 32-bit
> > > > > compatible binary. And ignoring this flag is not expected behavior.
> > > > 
> > > > Well, the real question here is, whether we should allow 32bit
> > > > applications
> > > > to obtain 64bit mappings at all. We can very well force 32bit
> > > > applications
> > > > into the 4GB address space as it was before your mmap base splitup and
> > > > be
> > > > done with it.
> > > 
> > > Hmm, yes, we could restrict 32bit applications to 32bit mappings only.
> > > But the approach which I tried to follow in the patches set, it was do
> > > not base the logic on the bitness of launched applications
> > > (native/compat) - only base on bitness of the performing syscall.
> > > The idea was suggested by Andy and I made mmap() logic here independent
> > > from original application's bitness.
> > > 
> > > It also seems to me simpler:
> > > if 32-bit application wants to allocate 64-bit mapping, it should
> > > long-jump with 64-bit segment descriptor and do `syscall` instruction
> > > for 64-bit syscall entry path. So, in my point of view after this dance
> > > the application does not differ much from native 64-bit binary and can
> > > have 64-bit address mapping.
> > 
> > Works for me, but it lacks documentation .....
> 
> Sure, could you recommend a better place for it?
> Should it be in-code comment in x86 mmap() code or Documentation/*
> change or a patch to man-pages?

I added a comment in the code and fixed up the changelogs. man-page needs
some care as well.

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1599512 — Re: [PATCHv6 4/5] x86/mm: check in_compat_syscall() instead TIF_ADDR32 for mmap(MAP_32BIT)

FromAndy Lutomirski <luto@amacapital.net>
Date2017-03-13 16:40 +0100
SubjectRe: [PATCHv6 4/5] x86/mm: check in_compat_syscall() instead TIF_ADDR32 for mmap(MAP_32BIT)
Message-ID<tkAeJ-2xf-1@gated-at.bofh.it>
In reply to#1599388
On Mon, Mar 13, 2017 at 6:47 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Mon, 13 Mar 2017, Dmitry Safonov wrote:
>> On 03/13/2017 12:39 PM, Thomas Gleixner wrote:
>> > On Mon, 6 Mar 2017, Dmitry Safonov wrote:
>> >
>> > > Result of mmap() calls with MAP_32BIT flag at this moment depends
>> > > on thread flag TIF_ADDR32, which is set during exec() for 32-bit apps.
>> > > It's broken as the behavior of mmap() shouldn't depend on exec-ed
>> > > application's bitness. Instead, it should check the bitness of mmap()
>> > > syscall.
>> > > How it worked before:
>> > > o for 32-bit compatible binaries it is completely ignored. Which was
>> > > fine when there were one mmap_base, computed for 32-bit syscalls.
>> > > After introducing mmap_compat_base 64-bit syscalls do use computed
>> > > for 64-bit syscalls mmap_base, which means that we can allocate 64-bit
>> > > address with 64-bit syscall in application launched from 32-bit
>> > > compatible binary. And ignoring this flag is not expected behavior.
>> >
>> > Well, the real question here is, whether we should allow 32bit applications
>> > to obtain 64bit mappings at all. We can very well force 32bit applications
>> > into the 4GB address space as it was before your mmap base splitup and be
>> > done with it.
>>
>> Hmm, yes, we could restrict 32bit applications to 32bit mappings only.
>> But the approach which I tried to follow in the patches set, it was do
>> not base the logic on the bitness of launched applications
>> (native/compat) - only base on bitness of the performing syscall.
>> The idea was suggested by Andy and I made mmap() logic here independent
>> from original application's bitness.
>>
>> It also seems to me simpler:
>> if 32-bit application wants to allocate 64-bit mapping, it should
>> long-jump with 64-bit segment descriptor and do `syscall` instruction
>> for 64-bit syscall entry path. So, in my point of view after this dance
>> the application does not differ much from native 64-bit binary and can
>> have 64-bit address mapping.

I agree.

>
> Works for me, but it lacks documentation .....
>
> Thanks,
>
>         tglx



-- 
Andy Lutomirski
AMA Capital Management, LLC

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web