Skip to content

x86/ldt: Use a VMA based read only mapping

Thomas Gleixner linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest16 patches 50 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16arch: Allow arch_dup_mmap() to failarch/powerpc/include/asm/mmu_context.h arch/um/include/asm/mmu_context.h arch/unicore32/include/asm/mmu_context.h +3 more+14 -110 replies
2/16x86/ldt: Rework lockingarch/x86/include/asm/mmu.h arch/x86/include/asm/mmu_context.h arch/x86/kernel/ldt.c+26 -130 replies
3/16x86/ldt: Prevent ldt inheritance on execarch/x86/include/asm/mmu_context.h arch/x86/kernel/ldt.c tools/testing/selftests/x86/ldt_gdt.c+22 -260 replies
4/16mm/softdirty: Move VM_SOFTDIRTY into high bitsarch/powerpc/platforms/Kconfig.cputype arch/s390/Kconfig include/linux/mm.h+13 -60 replies
5/16mm: Allow special mappings with user access clearedarch/x86/include/uapi/asm/mman.h include/linux/mm.h include/linux/mman.h +1 more+20 -225 replies
6/16mm: Provide vm_special_mapping::closeinclude/linux/mm_types.h mm/mmap.c+7 -00 replies
7/16selftest/x86: Implement additional LDT selfteststools/testing/selftests/x86/ldt_gdt.c+70 -10 replies
8/16selftests/x86/ldt_gdt: Prepare for access bit forcedtools/testing/selftests/x86/ldt_gdt.c+1 -20 replies
9/16mm: Make populate_vma_page_range() availableinclude/linux/mm.h mm/internal.h+2 -20 replies
10/16x86/ldt: Do not install LDT for kernel threadsarch/x86/include/asm/mmu_context.h+1 -21 reply
11/16x86/ldt: Force access bit for CS/SSarch/x86/entry/common.c arch/x86/include/asm/desc.h arch/x86/include/asm/mmu_context.h +5 more+78 -2710 replies
12/16x86/ldt: Reshuffle codearch/x86/include/asm/mmu_context.h arch/x86/kernel/ldt.c+59 -630 replies
13/16x86/ldt: Introduce LDT write fault handlerarch/x86/include/asm/mmu_context.h arch/x86/kernel/ldt.c arch/x86/mm/fault.c+56 -013 replies
14/16x86/ldt: Prepare for VMA mappingarch/x86/include/asm/mmu.h arch/x86/include/asm/mmu_context.h arch/x86/kernel/ldt.c+116 -30 replies
15/16x86/ldt: Add VMA management codearch/x86/kernel/ldt.c+102 -10 replies
16/16x86/ldt: Make it read only VMA mappedarch/x86/kernel/ldt.c+165 -1170 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [patch 00/16] x86/ldt: Use a VMA based read only mapping

Peter and myself spent quite some time to figure out how to make CPUs cope with a RO mapped LDT.

While the initial trick of writing the ACCESS bit in a special fault handler covers most cases, the tricky problem of CS/SS in return to user space (IRET ...) was giving us quite some headache.

Peter finally found a way to do so. Touching the CS/SS selectors with LAR on the way out to user space makes it work w/o trouble.

Contrary to the approach Andy was taking with storing the LDT in a special map area, the following series uses a special mapping which is mapped without the user bit and read only. This just ties the LDT to the process which is the most natural way to do it, removes the requirement for special pagetable code and works independent of pagetable isolation.

This was tested on quite a range of Intel and AMD machines, but the test coverage on 32bit is quite meager. I'll resurrect a few dust bricks tomorrow.

The patch series also includes an updated version of the: do not inherit LDT on exec changes.

There are some extensions to the VMA code, which need scrunity of the mm folks.

Thanks,

tglx

---
 arch/powerpc/include/asm/mmu_context.h     |    5 
 arch/powerpc/platforms/Kconfig.cputype     |    1 
 arch/s390/Kconfig                          |    1 
 arch/x86/entry/common.c                    |    8 
 arch/x86/include/asm/desc.h                |    2 
 arch/x86/include/asm/mmu.h                 |    7 
 arch/x86/include/asm/thread_info.h         |    4 
 arch/x86/include/uapi/asm/mman.h           |    4 
 arch/x86/kernel/cpu/common.c               |    4 
 arch/x86/kernel/ldt.c                      |  573 ++++++++++++++++++++++-------
 arch/x86/mm/fault.c                        |   19 
 arch/x86/mm/tlb.c                          |    2 
 arch/x86/power/cpu.c                       |    2 
 b/arch/um/include/asm/mmu_context.h        |    3 
 b/arch/unicore32/include/asm/mmu_context.h |    5 
 b/arch/x86/include/asm/mmu_context.h       |   93 +++-
 b/include/linux/mman.h                     |    4 
 include/asm-generic/mm_hooks.h             |    5 
 include/linux/mm.h                         |   21 -
 include/linux/mm_types.h                   |    3 
 kernel/fork.c                              |    3 
 mm/internal.h                              |    2 
 mm/mmap.c                                  |   16 
 tools/testing/selftests/x86/ldt_gdt.c      |   83 +++-
 24 files changed, 673 insertions(+), 197 deletions(-)

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