Hugh Dickins 5fcf7bb73f [PATCH] read_zero_pagealigned() locking fix
Ramiro Voicu hits the BUG_ON(!pte_none(*pte)) in zeromap_pte_range: kernel
bugzilla 7645.  Right: read_zero_pagealigned uses down_read of mmap_sem,
but another thread's racing read of /dev/zero, or a normal fault, can
easily set that pte again, in between zap_page_range and zeromap_page_range
getting there.  It's been wrong ever since 2.4.3.

The simple fix is to use down_write instead, but that would serialize reads
of /dev/zero more than at present: perhaps some app would be badly
affected.  So instead let zeromap_page_range return the error instead of
BUG_ON, and read_zero_pagealigned break to the slower clear_user loop in
that case - there's no need to optimize for it.

Use -EEXIST for when a pte is found: BUG_ON in mmap_zero (the other user of
zeromap_page_range), though it really isn't interesting there.  And since
mmap_zero wants -EAGAIN for out-of-memory, the zeromaps better return that
than -ENOMEM.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
Cc: Ramiro Voicu: <Ramiro.Voicu@cern.ch>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-10 09:55:39 -08:00
..
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:46 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-12-07 08:39:41 -08:00
2006-12-08 08:28:57 -08:00
2006-10-04 07:55:13 -07:00
2006-12-08 08:28:57 -08:00
2006-11-22 14:57:56 +00:00
2006-12-04 02:00:36 -05:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2005-10-29 19:30:42 +01:00
2006-12-08 08:28:44 -08:00
2005-05-04 07:33:13 -07:00
2006-12-08 08:28:57 -08:00
2006-11-13 07:40:42 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-03-28 09:16:08 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-01-12 09:09:00 -08:00
2006-09-29 09:18:12 -07:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:59 -08:00
2006-12-08 08:28:59 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-12-08 08:28:57 -08:00
2006-12-07 08:39:32 -08:00
2006-12-08 08:28:57 -08:00