Skip to contentSkip to conversation

nilfs2: avoid overflowing segment numbers in nilfs_ioctl_clean_segments()

PATCH In review Xi Wang 3 participants 3 messages Feb 3, 2012 – Feb 4, 2012 NILFS2 filesystem

lore
Share & tools
lore

Xi Wang

author
#0 lore raw

PATCH 1/1 nilfs2: avoid overflowing segment numbers in nilfs_ioctl_clean_segments()

nsegs is read from userspace. Limit its value and avoid overflowing nsegs * sizeof(__u64) in the subsequent call to memdup_user().

This patch complements 481fe17e973fb97aa3edf17c69557afe88d8334f.

Cc Haogang Chen <[email protected]>
Cc Andrew Morton <akpm-de/[email protected]>
---
 fs/nilfs2/ioctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/nilfs2/ioctl.c +2 -0
index 8866496..2a70fce 100644
@@ -603,6 +603,8 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
 	nsegs = argv[4].v_nmembs;
 	if (argv[4].v_size != argsz[4])
 		goto out;
+	if (nsegs > UINT_MAX / sizeof(__u64))
+		goto out;
 
 	/*
 	 * argv[4] points to segment numbers this ioctl cleans.  We
Signature · 6 lines
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Xi Wang

nsegs is read from userspace. Limit its value and avoid overflowing nsegs * sizeof(__u64) in the subsequent call to memdup_user().

This patch complements 481fe17e973fb97aa3edf17c69557afe88d8334f.

Cc Haogang Chen <[email protected]>
Cc Andrew Morton <akpm-de/[email protected]>
---
 fs/nilfs2/ioctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Thank you for posting this fix.

Andrew, could you send this uptream in this cycle ?

Ryusuke Konishi

Quoted 21 lines
fs/nilfs2/ioctl.c +2 -0
index 8866496..2a70fce 100644
@@ -603,6 +603,8 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,
 	nsegs = argv[4].v_nmembs;
 	if (argv[4].v_size != argsz[4])
 		goto out;
+	if (nsegs > UINT_MAX / sizeof(__u64))
+		goto out;
 
 	/*
 	 * argv[4] points to segment numbers this ioctl cleans.  We
Signature · 7 lines
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 13 lines · On Sat, 04 Feb 2012 12:13:02 +0900 (JST) Ryusuke Konishi…
Quoted 11 lines · Xi Wang

nsegs is read from userspace. Limit its value and avoid overflowing nsegs * sizeof(__u64) in the subsequent call to memdup_user().

This patch complements 481fe17e973fb97aa3edf17c69557afe88d8334f.

Cc Haogang Chen <[email protected]>
Cc Andrew Morton <[email protected]>
---
 fs/nilfs2/ioctl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 6 lines

Thank you for posting this fix.

Andrew, could you send this uptream in this cycle ?

I sure can.