All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix page_check_range() wrap-around check when len=0.
@ 2010-03-28  0:53 takasi-y
  0 siblings, 0 replies; only message in thread
From: takasi-y @ 2010-03-28  0:53 UTC (permalink / raw
  To: qemu-devel; +Cc: Richard Henderson

Fix page_check_range() wrap-around check when len=0.

write(1,"",0) on linux-user emulation should be OK, but fails.
This is a regression brought by 376a7909.

This patch fixes it at the last of the calling path shown below,
  do_syscall:write -> access_ok() -> page_check_range(),
as linux-kernel does. For example, x86 does it at follows,
  sys_write() -> access_ok() -> __range_not_ok().
This implies calling page_check_range() with len=0 is valid.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
---
 exec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/exec.c b/exec.c
index 14767b7..26cd8b9 100644
--- a/exec.c
+++ b/exec.c
@@ -2410,7 +2410,7 @@ int page_check_range(target_ulong start, target_ulong len, int flags)
     assert(start < ((abi_ulong)1 << L1_MAP_ADDR_SPACE_BITS));
 #endif
 
-    if (start + len - 1 < start) {
+    if (len > 0 && start + len -1 < start) {
         /* We've wrapped around.  */
         return -1;
     }
-- 
1.6.5

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-03-28  0:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-28  0:53 [Qemu-devel] [PATCH] Fix page_check_range() wrap-around check when len=0 takasi-y

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.