linux/arch/x86/include/asm
Linus Torvalds 9063c61fd5 x86, 64-bit: Clean up user address masking
The discussion about using "access_ok()" in get_user_pages_fast() (see
commit 7f81890687: "x86: don't use
'access_ok()' as a range check in get_user_pages_fast()" for details and
end result), made us notice that x86-64 was really being very sloppy
about virtual address checking.

So be way more careful and straightforward about masking x86-64 virtual
addresses:

 - All the VIRTUAL_MASK* variants now cover half of the address
   space, it's not like we can use the full mask on a signed
   integer, and the larger mask just invites mistakes when
   applying it to either half of the 48-bit address space.

 - /proc/kcore's kc_offset_to_vaddr() becomes a lot more
   obvious when it transforms a file offset into a
   (kernel-half) virtual address.

 - Unify/simplify the 32-bit and 64-bit USER_DS definition to
   be based on TASK_SIZE_MAX.

This cleanup and more careful/obvious user virtual address checking also
uncovered a buglet in the x86-64 implementation of strnlen_user(): it
would do an "access_ok()" check on the whole potential area, even if the
string itself was much shorter, and thus return an error even for valid
strings. Our sloppy checking had hidden this.

So this fixes 'strnlen_user()' to do this properly, the same way we
already handled user strings in 'strncpy_from_user()'.  Namely by just
checking the first byte, and then relying on fault handling for the
rest.  That always works, since we impose a guard page that cannot be
mapped at the end of the user space address space (and even if we
didn't, we'd have the address space hole).

Acked-by: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Nick Piggin <npiggin@suse.de>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-20 15:40:00 -07:00
..
uv x86, UV: Fix macros for multiple coherency domains 2009-06-08 18:57:47 +02:00
visws
xen Xen: Add virt_to_pfn helper function 2009-04-08 11:51:46 -07:00
a.out-core.h x86: add %gs accessors for x86_32 2009-02-10 00:41:58 +01:00
a.out.h
acpi.h x86: use early_ioremap in __acpi_map_table 2009-02-09 13:33:51 +01:00
aes.h crypto: aes - Export x86 AES encrypt/decrypt functions 2009-02-18 16:48:05 +08:00
agp.h
alternative-asm.h
alternative.h x86: clean up alternative.h 2009-04-28 17:42:08 +02:00
amd_iommu_types.h Merge branches 'amd-iommu/fixes', 'amd-iommu/debug', 'amd-iommu/suspend-resume' and 'amd-iommu/extended-allocator' into amd-iommu/2.6.31 2009-05-28 18:23:56 +02:00
amd_iommu.h amd-iommu: disable IOMMU hardware on shutdown 2009-06-15 15:20:40 +02:00
apic.h Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-06-10 16:15:14 -07:00
apicdef.h x86: display extended apic registers with print_local_APIC and cpu_debug code 2009-05-11 14:37:36 +02:00
apicnum.h irq: initialize nr_irqs based on nr_cpu_ids 2009-01-11 19:13:38 +01:00
apm.h x86: move mach-default/*.h files to asm/ 2009-01-29 14:16:51 +01:00
asm.h
atomic_32.h Merge branch 'linus' into x86/urgent 2009-06-17 08:59:10 +02:00
atomic_64.h asm-generic: rename atomic.h to atomic-long.h 2009-06-11 21:02:17 +02:00
atomic.h
auxvec.h
bios_ebda.h
bitops.h x86, generic: mark complex bitops.h inlines as __always_inline 2009-01-13 18:56:30 +01:00
bitsperlong.h asm-generic: introduce asm/bitsperlong.h 2009-06-11 21:02:14 +02:00
boot.h x86, boot: make kernel_alignment adjustable; new bzImage fields 2009-05-11 17:44:39 -07:00
bootparam.h x86: add extension fields for bootloader type and version 2009-05-11 17:45:06 -07:00
bug.h
bugs.h
byteorder.h byteorder: make swab.h include asm/swab.h like a regular header 2009-01-14 19:56:50 -08:00
cache.h
cacheflush.h Merge branch 'tracing/core-v2' into tracing-for-linus 2009-04-02 00:49:02 +02:00
calgary.h
calling.h x86: document 64-bit and 32-bit function call convention ABI 2009-02-03 19:48:18 +01:00
checksum_32.h
checksum_64.h
checksum.h
cmpxchg_32.h
cmpxchg_64.h
cmpxchg.h
compat.h
cpu_debug.h x86: cpu_debug: Remove model information to reduce encoding-decoding 2009-06-07 12:22:56 +02:00
cpu.h x86: generalize boot_cpu_id 2009-01-29 14:17:01 +01:00
cpufeature.h Merge branch 'kvm-updates/2.6.31' of git://git.kernel.org/pub/scm/virt/kvm/kvm 2009-06-11 10:03:30 -07:00
cpumask.h x86: unify cpu_callin_mask/cpu_callout_mask/cpu_initialized_mask/cpu_sibling_setup_mask 2009-03-13 14:49:54 +10:30
cputime.h
current.h x86-64: Move current task from PDA to per-cpu and consolidate with 32-bit. 2009-01-19 00:38:58 +09:00
debugreg.h
delay.h
desc_defs.h
desc.h x86: de-assembler-ize asm/desc.h 2009-06-17 21:35:10 -07:00
device.h x86, ia64: convert to use generic dma_map_ops struct 2009-01-06 14:06:57 +01:00
div64.h
dma-mapping.h dma-mapping: x86: use asm-generic/dma-mapping-common.h 2009-06-18 13:03:58 -07:00
dma.h
dmi.h x86/dmi: fix dmi_alloc() section mismatches 2009-03-23 17:20:50 +01:00
do_timer.h x86: move mach-default/*.h files to asm/ 2009-01-29 14:16:51 +01:00
ds.h x86, ds: support Core i7 2009-04-07 13:36:36 +02:00
dwarf2.h
e820.h x86: e820 fix various signedness issues in setup.c and e820.c 2009-03-23 15:02:05 +05:30
edac.h
efi.h x86: EFI: Back efi_ioremap with init_memory_mapping instead of FIX_MAP 2009-03-04 19:20:16 +01:00
elf.h x86: make lazy %gs optional on x86_32 2009-02-10 00:42:00 +01:00
emergency-restart.h
entry_arch.h Merge branch 'linus' into x86/mce3 2009-06-11 23:31:52 +02:00
errno.h
fb.h
fcntl.h
fixmap.h x86: fix set_fixmap to use phys_addr_t 2009-04-10 20:27:13 +02:00
floppy.h
frame.h
ftrace.h tracing/syscalls: support for syscalls tracing on x86 2009-03-13 16:57:42 +01:00
futex.h
gart.h
genapic.h x86, apic: merge genapic.h into apic.h 2009-02-17 17:52:43 +01:00
geode.h
gpio.h
hardirq.h Merge branch 'linus' into x86/mce3 2009-06-11 23:31:52 +02:00
highmem.h x86: unify kmap_atomic_pfn() and iomap_atomic_prot_pfn() 2009-03-11 15:47:46 +01:00
hpet.h
hugetlb.h
hw_irq.h Merge branch 'linus' into x86/mce3 2009-06-11 23:31:52 +02:00
hypertransport.h
hypervisor.h
i387.h Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-06-10 16:15:14 -07:00
i8253.h
i8259.h x86: move x86_quirk_pre_intr_init() to irqinit_32.c 2009-04-10 14:35:53 +02:00
ia32_unistd.h
ia32.h generic compat_sys_ustat 2009-03-27 14:43:57 -04:00
idle.h
init.h x86: move function and variable declarations to asm/init.h 2009-03-05 14:17:18 +01:00
io_32.h Merge branches 'x86/acpi', 'x86/asm', 'x86/cpudetect', 'x86/crashdump', 'x86/debug', 'x86/defconfig', 'x86/doc', 'x86/header-fixes', 'x86/headers' and 'x86/minor-fixes' into x86/core 2009-02-13 09:46:36 +01:00
io_64.h Merge branches 'x86/acpi', 'x86/asm', 'x86/cpudetect', 'x86/crashdump', 'x86/debug', 'x86/defconfig', 'x86/doc', 'x86/header-fixes', 'x86/headers' and 'x86/minor-fixes' into x86/core 2009-02-13 09:46:36 +01:00
io_apic.h x86, apic: introduce io_apic_irq_attr 2009-05-18 08:38:55 +02:00
io.h x86: fix set_fixmap to use phys_addr_t 2009-04-10 20:27:13 +02:00
ioctl.h
ioctls.h
iomap.h x86: added 'ifndef _ASM_X86_IOMAP_H' to iomap.h 2009-04-30 19:26:11 +02:00
iommu.h x86, ia64: convert to use generic dma_map_ops struct 2009-01-06 14:06:57 +01:00
ipcbuf.h
ipi.h x86, apic: remove duplicate asm/apic.h inclusions 2009-02-17 17:52:44 +01:00
irq_regs.h x86: merge irq_regs.h 2009-01-21 17:26:06 +09:00
irq_remapping.h x86: x2apic, IR: Clean up X86_X2APIC and INTR_REMAP config checks 2009-04-21 09:08:25 +02:00
irq_vectors.h Merge branch 'linus' into x86/mce3 2009-06-11 23:31:52 +02:00
irq.h x86: UV, SGI RTC: add generic system vector 2009-03-04 20:25:37 +01:00
irqflags.h
ist.h
k8.h x86: k8 convert node_to_k8_nb_misc() from a macro to an inline function 2009-04-15 12:12:36 +02:00
Kbuild byteorder: make swab.h include asm/swab.h like a regular header 2009-01-14 19:56:50 -08:00
kdebug.h
kexec.h x86, kexec: x86_64: add kexec jump support for x86_64 2009-03-10 18:13:25 -07:00
kgdb.h
kmap_types.h kmap_types: make most arches use generic header file 2009-06-16 19:47:51 -07:00
kmemcheck.h kmemcheck: add the kmemcheck core 2009-06-13 15:37:30 +02:00
kprobes.h
kvm_host.h KVM: VMX: Rename rmode.active to rmode.vm86_active 2009-06-10 11:49:00 +03:00
kvm_para.h
kvm_x86_emulate.h KVM: Deal with interrupt shadow state for emulated instructions 2009-06-10 11:48:54 +03:00
kvm.h KVM: Enable MSI-X for KVM assigned device 2009-06-10 11:48:23 +03:00
ldt.h
lguest_hcall.h lguest: PAE support 2009-06-12 22:27:08 +09:30
lguest.h lguest: PAE support 2009-06-12 22:27:08 +09:30
linkage.h x86: shrink __ALIGN and __ALIGN_STR definitions 2009-03-11 12:39:28 +01:00
local.h
mach_timer.h x86: move mach-default/*.h files to asm/ 2009-01-29 14:16:51 +01:00
mach_traps.h x86: move mach-default/*.h files to asm/ 2009-01-29 14:16:51 +01:00
math_emu.h x86: fix math_emu register frame access 2009-02-10 00:39:14 +01:00
mc146818rtc.h
mca_dma.h
mca.h
mce.h x86, mce: mce.h cleanup 2009-06-16 16:56:10 -07:00
microcode.h x86: microcode: use smp_call_function_single instead of set_cpus_allowed, cleanup of synchronization logic 2009-05-12 10:36:44 +02:00
mman.h asm-generic: rename termios.h, signal.h and mman.h 2009-06-11 21:01:52 +02:00
mmconfig.h
mmu_context.h x86: make lazy %gs optional on x86_32 2009-02-10 00:42:00 +01:00
mmu.h
mmx.h
mmzone_32.h bootmem, x86: further fixes for arch-specific bootmem wrapping 2009-03-01 16:06:56 +09:00
mmzone_64.h mm: clean up for early_pfn_to_nid() 2009-02-18 15:37:55 -08:00
mmzone.h
module.h
mpspec_def.h x86: rename all fields of mpf_intel mpf_X to X 2009-01-08 15:37:37 +01:00
mpspec.h x86: enable_update_mptable should be a macro 2009-05-28 01:59:05 +02:00
msgbuf.h
msidef.h x86, x2apic: enable fault handling for intr-remapping 2009-03-17 15:38:59 -07:00
msr-index.h Merge branch 'linus' into x86/mce3 2009-06-11 23:31:52 +02:00
msr.h x86: msr.h linux/types.h is only required for __KERNEL__ 2009-06-17 18:56:01 +02:00
mtrr.h headers_check fix: x86, mtrr.h 2009-01-31 00:17:39 +05:30
mutex_32.h
mutex_64.h
mutex.h
nmi.h x86, nmi: Use predefined numbers instead of hardcoded one 2009-06-07 16:22:02 +02:00
nops.h
numa_32.h x86: set_highmem_pages_init() cleanup 2009-03-03 13:13:15 +01:00
numa_64.h x86, mm: Fix node_possible_map logic 2009-05-18 09:21:04 +02:00
numa.h
numaq.h x86, numaq: cleanups 2009-02-05 22:30:14 +01:00
olpc.h
page_32_types.h x86: page_types.h unification of declarations 2009-04-14 11:44:45 +02:00
page_32.h x86 headers: protect page_32.h via __ASSEMBLY__ 2009-02-13 13:36:47 +01:00
page_64_types.h x86, 64-bit: Clean up user address masking 2009-06-20 15:40:00 -07:00
page_64.h x86: create _types.h counterparts for page*.h 2009-02-11 14:54:09 -08:00
page_types.h x86: page_types.h unification of declarations 2009-04-14 11:44:45 +02:00
page.h asm-generic: rename page.h and uaccess.h 2009-06-11 21:02:17 +02:00
param.h
paravirt.h Merge branch 'x86-xen-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-06-10 16:16:27 -07:00
parport.h
pat.h x86, PAT: Remove duplicate memtype reserve in devmem mmap 2009-04-10 13:55:48 +02:00
pci_64.h x86/dma: unify definition of pci_unmap_addr* and pci_unmap_len macros 2009-04-03 13:13:45 +02:00
pci_x86.h
pci-direct.h
pci-functions.h x86: move mach-default/*.h files to asm/ 2009-01-29 14:16:51 +01:00
pci.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-cpumask 2009-04-05 10:33:07 -07:00
percpu.h x86: fix percpu_{to,from}_op() 2009-05-11 08:54:33 -07:00
perf_counter.h perf_counter: Make set_perf_counter_pending() declaration common 2009-06-15 16:12:26 +02:00
pgalloc.h x86, mm: fix pte_free() 2009-01-23 18:42:06 +01:00
pgtable_32_types.h module: merge module_alloc() finally 2009-06-12 21:47:03 +09:30
pgtable_32.h x86: Add NMI types for kmap_atomic, fix 2009-06-15 17:20:03 +02:00
pgtable_64_types.h x86: 46 bit physical address support on 64 bits 2009-05-05 19:10:18 -07:00
pgtable_64.h x86, 64-bit: Clean up user address masking 2009-06-20 15:40:00 -07:00
pgtable_types.h x86: make _PAGE_HIDDEN conditional 2009-06-15 15:49:19 +02:00
pgtable-2level_types.h x86: move more pagetable-related definitions into pgtable*.h 2009-02-13 11:35:01 -08:00
pgtable-2level.h x86: with the last user gone, remove set_pte_present 2009-03-19 14:04:19 +01:00
pgtable-3level_types.h x86: move more pagetable-related definitions into pgtable*.h 2009-02-13 11:35:01 -08:00
pgtable-3level.h x86: with the last user gone, remove set_pte_present 2009-03-19 14:04:19 +01:00
pgtable.h x86: unify pte_hidden 2009-06-15 15:49:20 +02:00
poll.h
posix_types_32.h
posix_types_64.h
posix_types.h
prctl.h headers_check fix: x86, prctl.h 2009-02-02 23:27:09 +05:30
processor-cyrix.h
processor-flags.h
processor.h Merge branch 'tracing-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-06-10 19:53:40 -07:00
proto.h x86/Voyager: remove X86_BIOS_REBOOT Kconfig quirk 2009-01-29 14:17:03 +01:00
ptrace-abi.h x86, ptrace: remove CONFIG guards around declarations 2009-02-24 18:23:35 +01:00
ptrace.h Merge branch 'tracing-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-06-10 19:53:40 -07:00
pvclock-abi.h
pvclock.h
rdc321x_defs.h x86, rdc321x: remove/move leftover files 2009-01-18 19:39:18 +01:00
reboot_fixups.h
reboot.h
required-features.h x86-64: remove PGE from must-have feature list 2009-04-08 11:51:46 -07:00
resource.h
resume-trace.h
rio.h
rtc.h
rwlock.h
rwsem.h
scatterlist.h
seccomp_32.h x86-64: seccomp: fix 32/64 syscall hole 2009-03-02 15:41:30 -08:00
seccomp_64.h x86-64: seccomp: fix 32/64 syscall hole 2009-03-02 15:41:30 -08:00
seccomp.h
sections.h x86: add brk allocation for very, very early allocations 2009-03-14 15:37:14 -07:00
segment.h x86: implement x86_32 stack protector 2009-02-10 00:42:01 +01:00
sembuf.h
serial.h
setup_arch.h x86: move mach-default/*.h files to asm/ 2009-01-29 14:16:51 +01:00
setup.h x86: move x86_quirk_pre_intr_init() to irqinit_32.c 2009-04-10 14:35:53 +02:00
shmbuf.h
shmparam.h
sigcontext32.h headers_check fix: x86, sigcontext32.h 2009-01-31 00:18:58 +05:30
sigcontext.h x86: add linux kernel support for YMM state 2009-04-12 13:08:56 +02:00
sigframe.h
siginfo.h
signal.h asm-generic: rename termios.h, signal.h and mman.h 2009-06-11 21:01:52 +02:00
smp.h x86: read apic ID in the !acpi_lapic case 2009-05-12 12:22:06 +02:00
smpboot_hooks.h x86: move mach-default/*.h files to asm/ 2009-01-29 14:16:51 +01:00
socket.h net: new user space API for time stamping of incoming and outgoing packets 2009-02-15 22:43:33 -08:00
sockios.h
sparsemem.h x86: 46 bit physical address support on 64 bits 2009-05-05 19:10:18 -07:00
spinlock_types.h
spinlock.h x86: Fix performance regression caused by paravirt_ops on native kernels 2009-05-15 20:07:42 +02:00
srat.h
stackprotector.h x86: fix x86_32 stack protector bugs 2009-02-11 11:33:49 +01:00
stacktrace.h
stat.h
statfs.h
string_32.h x86: add hooks for kmemcheck 2009-06-15 12:40:02 +02:00
string_64.h x86: add hooks for kmemcheck 2009-06-15 12:40:02 +02:00
string.h
suspend_32.h pm: cleanup includes 2009-04-01 08:59:16 -07:00
suspend_64.h
suspend.h
svm.h KVM: Fix unneeded instruction skipping during task switching. 2009-06-10 11:48:38 +03:00
swab.h headers_check fix: x86, swab.h 2009-01-31 00:19:32 +05:30
swiotlb.h
sync_bitops.h
sys_ia32.h generic compat_sys_ustat 2009-03-27 14:43:57 -04:00
syscall.h
syscalls.h x86: clean up declarations and variables 2009-04-12 15:20:16 +02:00
system_64.h
system.h x86: add forward decl for tss_struct 2009-03-02 12:07:49 +01:00
tce.h
termbits.h
termios.h x86: fix ktermios-termio conversion 2009-06-11 08:50:59 -07:00
thread_info.h kmemcheck: add hooks for the page allocator 2009-06-15 15:48:33 +02:00
time.h
timer.h sched, x86: Fix cpufreq + sched_clock() TSC scaling 2009-06-17 16:03:54 +02:00
timex.h time: move PIT_TICK_RATE to linux/timex.h 2009-06-16 19:47:27 -07:00
tlb.h
tlbflush.h x86: make zap_low_mapping could be used early 2009-06-12 13:50:24 +03:00
topology.h sched: Don't export sched_mc_power_savings on multi-socket single core system 2009-05-11 23:57:56 +02:00
trampoline.h x86: load pointer to pda into %gs while brining up a CPU 2009-01-16 14:19:26 +01:00
traps.h Merge branch 'x86-xen-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2009-06-10 16:16:27 -07:00
tsc.h
types.h asm-generic: introduce asm/bitsperlong.h 2009-06-11 21:02:14 +02:00
uaccess_32.h x86, mm: dont use non-temporal stores in pagecache accesses 2009-03-02 11:06:49 +01:00
uaccess_64.h x86, mm: dont use non-temporal stores in pagecache accesses 2009-03-02 11:06:49 +01:00
uaccess.h x86, 64-bit: Clean up user address masking 2009-06-20 15:40:00 -07:00
ucontext.h
unaligned.h
unistd_32.h Merge branch 'core/signal' into perfcounters/core 2009-04-30 21:16:49 +02:00
unistd_64.h Merge branch 'core/signal' into perfcounters/core 2009-04-30 21:16:49 +02:00
unistd.h
user32.h
user_32.h
user_64.h
user.h
vdso.h
vga.h
vgtod.h
virtext.h KVM: SVM: Move EFER and MSR constants to generic x86 code 2009-03-24 11:02:46 +02:00
vm86.h
vmi_time.h
vmi.h
vmware.h
vmx.h KVM: Add VT-x machine check support 2009-06-10 12:27:08 +03:00
vsyscall.h
xcr.h
xor_32.h
xor_64.h
xor.h x86: add hooks for kmemcheck 2009-06-15 12:40:02 +02:00
xsave.h x86: add linux kernel support for YMM state 2009-04-12 13:08:56 +02:00