[PATCH] fs: sync_file_range: avoid overflowing signed calculation
From: Sasha Levin
Date: Mon Dec 01 2014 - 23:04:40 EST
When calculating the end byte for the sync we preform an addition which might
result in an overflow, which is undefined. Avoid it by doing unsigned
addition.
Signed-off-by: Sasha Levin <sasha.levin@xxxxxxxxxx>
---
fs/sync.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/sync.c b/fs/sync.c
index 6ccfc38..f9cb38f 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -286,7 +286,7 @@ SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes,
if (flags & ~VALID_FLAGS)
goto out;
- endbyte = offset + nbytes;
+ endbyte = offset + (u64)nbytes;
if ((s64)offset < 0)
goto out;
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/