Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1189668 > unrolled thread
| Started by | Ingo Molnar <mingo@kernel.org> |
|---|---|
| First post | 2015-07-22 08:10 +0200 |
| Last post | 2015-07-22 14:40 +0200 |
| Articles | 4 — 3 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.
Re: [PATCH v2 2/3] x86/ldt: Make modify_ldt optional Ingo Molnar <mingo@kernel.org> - 2015-07-22 08:10 +0200
Re: [PATCH v2 2/3] x86/ldt: Make modify_ldt optional Andy Lutomirski <luto@amacapital.net> - 2015-07-22 08:30 +0200
Re: [PATCH v2 2/3] x86/ldt: Make modify_ldt optional Ingo Molnar <mingo@kernel.org> - 2015-07-22 08:30 +0200
Re: [PATCH v2 2/3] x86/ldt: Make modify_ldt optional Willy Tarreau <w@1wt.eu> - 2015-07-22 14:40 +0200
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2015-07-22 08:10 +0200 |
| Subject | Re: [PATCH v2 2/3] x86/ldt: Make modify_ldt optional |
| Message-ID | <pOVo6-6MK-5@gated-at.bofh.it> |
* Andy Lutomirski <luto@amacapital.net> wrote: > On Tue, Jul 21, 2015 at 1:28 PM, Brian Gerst <brgerst@gmail.com> wrote: > > On Tue, Jul 21, 2015 at 3:59 PM, Andy Lutomirski <luto@kernel.org> wrote: > >> > >> The modify_ldt syscall exposes a large attack surface and is unnecessary for > >> modern userspace. Make it optional. > >> > >> Signed-off-by: Andy Lutomirski <luto@kernel.org> > >> --- > >> arch/x86/Kconfig | 17 +++++++++++++++++ > >> arch/x86/include/asm/mmu.h | 2 ++ > >> arch/x86/include/asm/mmu_context.h | 31 +++++++++++++++++++++++-------- > >> arch/x86/kernel/Makefile | 3 ++- > >> arch/x86/kernel/cpu/perf_event.c | 4 ++++ > >> arch/x86/kernel/process_64.c | 2 ++ > >> arch/x86/kernel/step.c | 2 ++ > >> kernel/sys_ni.c | 1 + > >> 8 files changed, 53 insertions(+), 9 deletions(-) > >> > >> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > >> index 55bced17dc95..a7ff3980bd65 100644 > >> --- a/arch/x86/Kconfig > >> +++ b/arch/x86/Kconfig > >> @@ -1009,6 +1009,7 @@ config VM86 > >> config X86_16BIT > >> bool "Enable support for 16-bit segments" if EXPERT > >> default y > >> + depends on MODIFY_LDT_SYSCALL > >> ---help--- > >> This option is required by programs like Wine to run 16-bit > >> protected mode legacy code on x86 processors. Disabling > >> @@ -2047,6 +2048,22 @@ config CMDLINE_OVERRIDE > >> This is used to work around broken boot loaders. This should > >> be set to 'N' under normal conditions. > >> > >> +config MODIFY_LDT_SYSCALL > >> + bool "Enable the LDT (local descriptor table)" if EXPERT > >> + default y > >> + ---help--- > >> + Linux can allow user programs to install a per-process x86 > >> + Local Descriptor Table (LDT) using the modify_ldt(2) system > >> + call. This is required to run 16-bit or segmented code such as > >> + DOSEMU or some Wine programs. It is also used by some very old > >> + threading libraries. > >> + > >> + Enabling this feature adds a small amount of overhead to > >> + context switches and increases the low-level kernel attack > >> + surface. Disabling it removes the modify_ldt(2) system call. > >> + > >> + Saying 'N' here may make sense for embedded or server kernels. > >> + > > > > I believe Wine still uses the LDT for thread-local data, even for 32 > > and 64-bit programs. This is separate from the Linux runtime TLS. > > > > Really? I thought the whole reason we had three set_thread_area slots > was for Wine. Too bad we have to guess, if only we had the Wine source code under a nicely accessible Git archive or so to check? git clone git://source.winehq.org/git/wine.git ;-) Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2015-07-22 08:30 +0200 |
| Message-ID | <pOVHs-78W-3@gated-at.bofh.it> |
| In reply to | #1189668 |
On Tue, Jul 21, 2015 at 11:06 PM, Ingo Molnar <mingo@kernel.org> wrote: > > * Andy Lutomirski <luto@amacapital.net> wrote: > >> On Tue, Jul 21, 2015 at 1:28 PM, Brian Gerst <brgerst@gmail.com> wrote: >> > On Tue, Jul 21, 2015 at 3:59 PM, Andy Lutomirski <luto@kernel.org> wrote: >> >> >> >> The modify_ldt syscall exposes a large attack surface and is unnecessary for >> >> modern userspace. Make it optional. >> >> >> >> Signed-off-by: Andy Lutomirski <luto@kernel.org> >> >> --- >> >> arch/x86/Kconfig | 17 +++++++++++++++++ >> >> arch/x86/include/asm/mmu.h | 2 ++ >> >> arch/x86/include/asm/mmu_context.h | 31 +++++++++++++++++++++++-------- >> >> arch/x86/kernel/Makefile | 3 ++- >> >> arch/x86/kernel/cpu/perf_event.c | 4 ++++ >> >> arch/x86/kernel/process_64.c | 2 ++ >> >> arch/x86/kernel/step.c | 2 ++ >> >> kernel/sys_ni.c | 1 + >> >> 8 files changed, 53 insertions(+), 9 deletions(-) >> >> >> >> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig >> >> index 55bced17dc95..a7ff3980bd65 100644 >> >> --- a/arch/x86/Kconfig >> >> +++ b/arch/x86/Kconfig >> >> @@ -1009,6 +1009,7 @@ config VM86 >> >> config X86_16BIT >> >> bool "Enable support for 16-bit segments" if EXPERT >> >> default y >> >> + depends on MODIFY_LDT_SYSCALL >> >> ---help--- >> >> This option is required by programs like Wine to run 16-bit >> >> protected mode legacy code on x86 processors. Disabling >> >> @@ -2047,6 +2048,22 @@ config CMDLINE_OVERRIDE >> >> This is used to work around broken boot loaders. This should >> >> be set to 'N' under normal conditions. >> >> >> >> +config MODIFY_LDT_SYSCALL >> >> + bool "Enable the LDT (local descriptor table)" if EXPERT >> >> + default y >> >> + ---help--- >> >> + Linux can allow user programs to install a per-process x86 >> >> + Local Descriptor Table (LDT) using the modify_ldt(2) system >> >> + call. This is required to run 16-bit or segmented code such as >> >> + DOSEMU or some Wine programs. It is also used by some very old >> >> + threading libraries. >> >> + >> >> + Enabling this feature adds a small amount of overhead to >> >> + context switches and increases the low-level kernel attack >> >> + surface. Disabling it removes the modify_ldt(2) system call. >> >> + >> >> + Saying 'N' here may make sense for embedded or server kernels. >> >> + >> > >> > I believe Wine still uses the LDT for thread-local data, even for 32 >> > and 64-bit programs. This is separate from the Linux runtime TLS. >> > >> >> Really? I thought the whole reason we had three set_thread_area slots >> was for Wine. > > Too bad we have to guess, if only we had the Wine source code under a nicely > accessible Git archive or so to check? > > git clone git://source.winehq.org/git/wine.git > > ;-) You don't say? It appears that Wine uses set_thread_area with a fallback to modify_ldt for 32-bit binaries and arch_prctl for 64-bit. --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2015-07-22 08:30 +0200 |
| Message-ID | <pOVHs-78W-5@gated-at.bofh.it> |
| In reply to | #1189670 |
* Andy Lutomirski <luto@amacapital.net> wrote: > On Tue, Jul 21, 2015 at 11:06 PM, Ingo Molnar <mingo@kernel.org> wrote: > > > > * Andy Lutomirski <luto@amacapital.net> wrote: > > > >> On Tue, Jul 21, 2015 at 1:28 PM, Brian Gerst <brgerst@gmail.com> wrote: > >> > On Tue, Jul 21, 2015 at 3:59 PM, Andy Lutomirski <luto@kernel.org> wrote: > >> >> > >> >> The modify_ldt syscall exposes a large attack surface and is unnecessary for > >> >> modern userspace. Make it optional. > >> >> > >> >> Signed-off-by: Andy Lutomirski <luto@kernel.org> > >> >> --- > >> >> arch/x86/Kconfig | 17 +++++++++++++++++ > >> >> arch/x86/include/asm/mmu.h | 2 ++ > >> >> arch/x86/include/asm/mmu_context.h | 31 +++++++++++++++++++++++-------- > >> >> arch/x86/kernel/Makefile | 3 ++- > >> >> arch/x86/kernel/cpu/perf_event.c | 4 ++++ > >> >> arch/x86/kernel/process_64.c | 2 ++ > >> >> arch/x86/kernel/step.c | 2 ++ > >> >> kernel/sys_ni.c | 1 + > >> >> 8 files changed, 53 insertions(+), 9 deletions(-) > >> >> > >> >> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > >> >> index 55bced17dc95..a7ff3980bd65 100644 > >> >> --- a/arch/x86/Kconfig > >> >> +++ b/arch/x86/Kconfig > >> >> @@ -1009,6 +1009,7 @@ config VM86 > >> >> config X86_16BIT > >> >> bool "Enable support for 16-bit segments" if EXPERT > >> >> default y > >> >> + depends on MODIFY_LDT_SYSCALL > >> >> ---help--- > >> >> This option is required by programs like Wine to run 16-bit > >> >> protected mode legacy code on x86 processors. Disabling > >> >> @@ -2047,6 +2048,22 @@ config CMDLINE_OVERRIDE > >> >> This is used to work around broken boot loaders. This should > >> >> be set to 'N' under normal conditions. > >> >> > >> >> +config MODIFY_LDT_SYSCALL > >> >> + bool "Enable the LDT (local descriptor table)" if EXPERT > >> >> + default y > >> >> + ---help--- > >> >> + Linux can allow user programs to install a per-process x86 > >> >> + Local Descriptor Table (LDT) using the modify_ldt(2) system > >> >> + call. This is required to run 16-bit or segmented code such as > >> >> + DOSEMU or some Wine programs. It is also used by some very old > >> >> + threading libraries. > >> >> + > >> >> + Enabling this feature adds a small amount of overhead to > >> >> + context switches and increases the low-level kernel attack > >> >> + surface. Disabling it removes the modify_ldt(2) system call. > >> >> + > >> >> + Saying 'N' here may make sense for embedded or server kernels. > >> >> + > >> > > >> > I believe Wine still uses the LDT for thread-local data, even for 32 > >> > and 64-bit programs. This is separate from the Linux runtime TLS. > >> > > >> > >> Really? I thought the whole reason we had three set_thread_area slots > >> was for Wine. > > > > Too bad we have to guess, if only we had the Wine source code under a nicely > > accessible Git archive or so to check? > > > > git clone git://source.winehq.org/git/wine.git > > > > ;-) > > You don't say? > > It appears that Wine uses set_thread_area with a fallback to > modify_ldt for 32-bit binaries and arch_prctl for 64-bit. I also think it uses modify_ldt() unconditionally for 16-bit APIs: triton:~/wine> git grep wine_ldt_set_entry dlls/krnl386.exe16/dosvm.c: wine_ldt_set_entry( sel, &entry ); dlls/krnl386.exe16/int31.c: wine_ldt_set_entry( sel, &entry ); dlls/krnl386.exe16/int31.c: wine_ldt_set_entry( BX_reg(context), entry ); dlls/krnl386.exe16/selector.c: if (wine_ldt_set_entry( sel + (i << __AHSHIFT), &entry ) < 0) dlls/krnl386.exe16/selector.c: wine_ldt_set_entry( newsel + (i << __AHSHIFT), &entry ); dlls/krnl386.exe16/selector.c: if (wine_ldt_set_entry( sel + (i << __AHSHIFT), &entry ) < 0) return FALSE; dlls/krnl386.exe16/selector.c: wine_ldt_set_entry( selDst, &entry ); dlls/krnl386.exe16/selector.c: if (wine_ldt_set_entry( newsel, &entry ) >= 0) return newsel; dlls/krnl386.exe16/selector.c: if (wine_ldt_set_entry( newsel, &entry ) >= 0) return newsel; dlls/krnl386.exe16/selector.c: wine_ldt_set_entry( SELECTOROF(ptr), &entry ); dlls/krnl386.exe16/selector.c: if (wine_ldt_set_entry( sel, &entry ) < 0) sel = 0; dlls/krnl386.exe16/selector.c: if (wine_ldt_set_entry( sel, &entry ) < 0) sel = 0; dlls/krnl386.exe16/selector.c: wine_ldt_set_entry( sel, &entry ); dlls/krnl386.exe16/wowthunk.c: wine_ldt_set_entry( codesel, &entry ); dlls/user.exe16/message.c: wine_ldt_set_entry( thunk_selector, &entry ); include/wine/library.h:extern int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry ); libs/wine/ldt.c: * wine_ldt_set_entry libs/wine/ldt.c:int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry ) libs/wine/wine.map: wine_ldt_set_entry; So the situation looks mostly encouraging, IMHO. Plus an 'strace -fc' output of a modern, Wine driven Windows game would probably tell us pretty definitely whether there's anything particularly performance sensitive about modify_ldt(). Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Willy Tarreau <w@1wt.eu> |
|---|---|
| Date | 2015-07-22 14:40 +0200 |
| Message-ID | <pP1tw-6UG-11@gated-at.bofh.it> |
| In reply to | #1189670 |
On Tue, Jul 21, 2015 at 11:23:02PM -0700, Andy Lutomirski wrote: > >> >> +config MODIFY_LDT_SYSCALL > >> >> + bool "Enable the LDT (local descriptor table)" if EXPERT > >> >> + default y > >> >> + ---help--- > >> >> + Linux can allow user programs to install a per-process x86 > >> >> + Local Descriptor Table (LDT) using the modify_ldt(2) system > >> >> + call. This is required to run 16-bit or segmented code such as > >> >> + DOSEMU or some Wine programs. It is also used by some very old > >> >> + threading libraries. > >> >> + > >> >> + Enabling this feature adds a small amount of overhead to > >> >> + context switches and increases the low-level kernel attack > >> >> + surface. Disabling it removes the modify_ldt(2) system call. > >> >> + > >> >> + Saying 'N' here may make sense for embedded or server kernels. > >> >> + > >> > > >> > I believe Wine still uses the LDT for thread-local data, even for 32 > >> > and 64-bit programs. This is separate from the Linux runtime TLS. > >> > > >> > >> Really? I thought the whole reason we had three set_thread_area slots > >> was for Wine. > > > > Too bad we have to guess, if only we had the Wine source code under a nicely > > accessible Git archive or so to check? > > > > git clone git://source.winehq.org/git/wine.git > > > > ;-) > > You don't say? > > It appears that Wine uses set_thread_area with a fallback to > modify_ldt for 32-bit binaries and arch_prctl for 64-bit. Why wouldn't we have this (as well as X86_16BIT) as a sysctl for the long term, just like we've finally got rid of NULL mapping ? We would encourage distros to ship with those settings disabled by default and to only enable them when breakage is *observed*. Currently I think that adding new config options will just make distro ship with the option enabled "just in case". It's also a nice way to discover users of these mechanisms and to suggest their developers to contemplate other options or to whine loudly. Willy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web