Skip to content

x86: modify_ldt improvement, test, and config option

Andy Lutomirski lkml stable xen-devel 8 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest posting 2/24 patches 13 repliesIn review
  2. v6 posting 1/20 of 4 patches 0 repliesSuperseded
  3. v54 patches 39 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v4 posting 2/23 patches119 repliesSuperseded
v4 posting 1/20 of 3 patches0 repliesSuperseded
v3 posting 2/23 patches30 repliesSuperseded
v3 posting 1/20 of 3 patches0 repliesSuperseded
v23 patches35 repliesSuperseded

Changes in v6 from the cover letter

- Improve Xen bits, this time with comments that seem plausible.
- Fix debug_locks warning on exec.
- Add a test for exec preserving the LDT (!)

Patches in v6 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4x86/xen: Probe target addresses in set_aliased_prot before the hypercallarch/x86/xen/enlighten.c+40 -00 replies
1/4x86/xen: Probe target addresses in set_aliased_prot before the hypercallarch/x86/xen/enlighten.c+40 -02 replies
2/4x86/ldt: Make modify_ldt synchronousarch/x86/include/asm/desc.h arch/x86/include/asm/mmu.h arch/x86/include/asm/mmu_context.h +6 more+210 -1530 replies
2/4x86/ldt: Make modify_ldt synchronousarch/x86/include/asm/desc.h arch/x86/include/asm/mmu.h arch/x86/include/asm/mmu_context.h +6 more+210 -1534 replies
3/4selftests/x86, x86/ldt: Add a selftest for modify_ldttools/testing/selftests/x86/Makefile tools/testing/selftests/x86/ldt_gdt.c+577 -10 replies
3/4selftests/x86, x86/ldt: Add a selftest for modify_ldttools/testing/selftests/x86/Makefile tools/testing/selftests/x86/ldt_gdt.c+577 -10 replies
4/4x86/ldt: Make modify_ldt optionalarch/x86/Kconfig arch/x86/include/asm/mmu.h arch/x86/include/asm/mmu_context.h +5 more+51 -80 replies
4/4x86/ldt: Make modify_ldt optionalarch/x86/Kconfig arch/x86/include/asm/mmu.h arch/x86/include/asm/mmu_context.h +5 more+51 -82 replies

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchBorislav PetkovKees CookDavid Vrabel
1/4R-b R-b
1/4R-b R-b
2/4R-b R-b
2/4R-b R-b
3/4R-b R-b
3/4R-b R-b
4/4R-b R-b
4/4R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v6 thread

Cover letter [PATCH v6 0/4] x86: modify_ldt improvement, test, and config option

This is intended for x86/urgent. Sorry for taking so long, but it seemed nice to avoid breaking Xen.

This fixes the "dazed and confused" issue which was exposed by the CVE-2015-5157 fix. It's also probably a good general attack surface reduction, and it replaces some scary code with IMO less scary code.

Also, servers and embedded systems should probably turn off modify_ldt. This makes that possible.

Xen people, can you test patch 1? It works for me on my evil 32-bit Xen virtio setup.

Willy and Kees: I left the config option alone. The -tiny people will like it, and we can always add a sysctl of some sort later.

Changes from v5:
- Improve Xen bits, this time with comments that seem plausible.
- Fix debug_locks warning on exec.
- Add a test for exec preserving the LDT (!)

Changes from v4:
- Fix Xen even better (patch 1 is new).
- Reorder the patches to make a little more sense.

Changes from v3:
- Hopefully fixed Xen.
- Fixed 32-bit test case on 32-bit native kernel.
- Fix bogus vumnap for some LDT sizes.
- Strengthen test case to check all LDT sizes (catches bogus vunmap).
- Lots of cleanups, mostly from Borislav.
- Simplify IPI code using on_each_cpu_mask.

Changes from v2:
- Allocate ldt_struct and the LDT entries separately. This should fix Xen.
- Stop using write_ldt_entry, since I'm pretty sure it's unnecessary now that we no longer mutate an in-use LDT. (Xen people, can you check?)

Changes from v1:
- The config option is new.
- The test case is new.
- Fixed a missing allocation failure check.
- Fixed a use-after-free on fork().

Andy Lutomirski (4):
x86/xen: Probe target addresses in set_aliased_prot before the
hypercall
x86/ldt: Make modify_ldt synchronous
selftests/x86, x86/ldt: Add a selftest for modify_ldt x86/ldt: Make modify_ldt optional

 arch/x86/Kconfig                      |  17 +
 arch/x86/include/asm/desc.h           |  15 -
 arch/x86/include/asm/mmu.h            |   5 +-
 arch/x86/include/asm/mmu_context.h    |  68 +++-
 arch/x86/kernel/Makefile              |   3 +-
 arch/x86/kernel/cpu/common.c          |   4 +-
 arch/x86/kernel/cpu/perf_event.c      |  16 +-
 arch/x86/kernel/ldt.c                 | 262 +++++++++-------
 arch/x86/kernel/process_64.c          |   6 +-
 arch/x86/kernel/step.c                |   8 +-
 arch/x86/power/cpu.c                  |   3 +-
 arch/x86/xen/enlighten.c              |  40 +++
 kernel/sys_ni.c                       |   1 +
 tools/testing/selftests/x86/Makefile  |   2 +-
 tools/testing/selftests/x86/ldt_gdt.c | 576 ++++++++++++++++++++++++++++++++++
 15 files changed, 871 insertions(+), 155 deletions(-)
 create mode 100644 tools/testing/selftests/x86/ldt_gdt.c
Signature · 1 line
2.4.3