linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fadvise: avoid signed integer overflow calculating offset
       [not found] <1417493050-13594-1-git-send-email-sasha.levin@oracle.com>
@ 2014-12-02  4:04 ` Sasha Levin
  0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2014-12-02  4:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: Sasha Levin, open list:MEMORY MANAGEMENT

Both offset and len are signed integers who's overflow isn't defined. Use
unsigned addition to avoid the issue.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 mm/fadvise.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/fadvise.c b/mm/fadvise.c
index 3bcfd81d..762cb63 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -67,7 +67,7 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice)
 	}
 
 	/* Careful about overflows. Len == 0 means "as much as possible" */
-	endbyte = offset + len;
+	endbyte = offset + (u64)len;
 	if (!len || endbyte < len)
 		endbyte = -1;
 	else
-- 
1.7.10.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

only message in thread, other threads:[~2014-12-02  4:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1417493050-13594-1-git-send-email-sasha.levin@oracle.com>
2014-12-02  4:04 ` [PATCH] mm: fadvise: avoid signed integer overflow calculating offset Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox