ChangeSet 1.2231.1.138, 2005/03/28 19:54:54-08:00, [EMAIL PROTECTED]

        [PATCH] fix mprotect() with len=(size_t)(-1) to return -ENOMEM
        
        This patch fixes a corner case in sys_mprotect():
        
        Case: len is so large that will overflow to 0 after page alignment.  
E.g.
        len=(size_t)(-1), i.e.  0xff...ff.
        
        Expected result: POSIX spec says it should return -ENOMEM.
        
        Current result: len is aligned to 0, then treated the same as len=0 and
        return success.
        
        Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
        Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>



 mprotect.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)


diff -Nru a/mm/mprotect.c b/mm/mprotect.c
--- a/mm/mprotect.c     2005-03-28 21:36:53 -08:00
+++ b/mm/mprotect.c     2005-03-28 21:36:53 -08:00
@@ -189,14 +189,14 @@
 
        if (start & ~PAGE_MASK)
                return -EINVAL;
+       if (!len)
+               return 0;
        len = PAGE_ALIGN(len);
        end = start + len;
-       if (end < start)
+       if (end <= start)
                return -ENOMEM;
        if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM))
                return -EINVAL;
-       if (end == start)
-               return 0;
 
        reqprot = prot;
        /*
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to