The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] fs/nilfs2: Integer overflow in nilfs_ioctl_wrap_copy()
@ 2013-12-28  2:28 Wenliang Fan
  2013-12-30  6:40 ` Vyacheslav Dubeyko
  0 siblings, 1 reply; 4+ messages in thread
From: Wenliang Fan @ 2013-12-28  2:28 UTC (permalink / raw)
  To: slava, konishi.ryusuke; +Cc: linux-nilfs, linux-kernel, Wenliang Fan

The local variable 'pos' comes from userspace. If a large number was
passed, there would be an integer overflow in the following line:
        pos += n;

Signed-off-by: Wenliang Fan <fanwlexca@gmail.com>
---
 fs/nilfs2/ioctl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index b44bdb2..a260a98 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -65,6 +65,8 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
 	ret = 0;
 	total = 0;
 	pos = argv->v_index;
+	if (pos > ULONG_MAX - argv->v_nmembs)
+		return -EINVAL;
 	for (i = 0; i < argv->v_nmembs; i += n) {
 		n = (argv->v_nmembs - i < maxmembs) ?
 			argv->v_nmembs - i : maxmembs;
-- 
1.8.5.rc1.28.g7061504


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] fs/nilfs2: Integer overflow in nilfs_ioctl_wrap_copy()
@ 2013-12-20  7:46 Wenliang Fan
  2013-12-20  8:23 ` Vyacheslav Dubeyko
  0 siblings, 1 reply; 4+ messages in thread
From: Wenliang Fan @ 2013-12-20  7:46 UTC (permalink / raw)
  To: konishi.ryusuke; +Cc: linux-nilfs, linux-kernel, Wenliang Fan

The local variable 'pos' comes from userspace. If a large number was
passed, there would be an integer overflow in the following line:
	pos += n;

Signed-off-by: Wenliang Fan <fanwlexca@gmail.com>
---
 fs/nilfs2/ioctl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index b44bdb2..b2bac9a 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -90,8 +90,13 @@ static int nilfs_ioctl_wrap_copy(struct the_nilfs *nilfs,
 		total += nr;
 		if ((size_t)nr < n)
 			break;
-		if (pos == ppos)
+		if (pos == ppos) {
+			if (pos > ULONG_MAX - n) {
+				ret = -EINVAL;
+				break;
+			}
 			pos += n;
+		}
 	}
 	argv->v_nmembs = total;
 
-- 
1.8.5.rc1.28.g7061504


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-30  6:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-28  2:28 [PATCH] fs/nilfs2: Integer overflow in nilfs_ioctl_wrap_copy() Wenliang Fan
2013-12-30  6:40 ` Vyacheslav Dubeyko
  -- strict thread matches above, loose matches on Subject: below --
2013-12-20  7:46 Wenliang Fan
2013-12-20  8:23 ` Vyacheslav Dubeyko

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