Missing overflow check in mmap
Calling mmap with len = -1 was silently accepted.
Andreas.
arch/ia64/kernel/sys_ia64.c renamed from arch/ia64/kernel/sys_ia64.c.~1~ +7 -1
@@ -201,10 +201,16 @@ do_mmap2 (unsigned long addr, unsigned l* A zero mmap always succeeds in Linux, independent of whether or not the * remaining arguments are valid. */ - len =PAGE_ALIGN (len);if (len =0 ) goto out; +/* Careful about overflows.. */ + len =PAGE_ALIGN (len); +if (!len || len >TASK_SIZE ) { + addr = -EINVAL ; + goto out; + } +/* * Don't permit mappings into unmapped space, the virtual page table of a region, * or across a region boundary. Note: RGN_MAP_LIMIT is equal to 2^n-PAGE_SIZE
Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected] SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Andreas Schwab
Andreas> Calling mmap with len = -1 was silently accepted.
Looks like the generic code was fixed last July, but the fix never made it into the ia64-specific check.
Thanks for the patch,
--david