Skip to contentSkip to conversation

i2o: fix overflow of copy_to_user()

PATCH New Kulikov Vasiliy 1 participant 1 message Jul 15, 2010 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 i2o: fix overflow of copy_to_user()

If (len > reslen) we must not call copy_to_user() since kernel buffer is smaller than we want to copy. Similar code in this file is correct, so this bug was a typo.

---
 drivers/message/i2o/i2o_config.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/message/i2o/i2o_config.c +1 -1
index c4b117f..4dd39a0 100644
@@ -115,7 +115,7 @@ static int i2o_cfg_gethrt(unsigned long arg)
 	put_user(len, kcmd.reslen);
 	if (len > reslen)
 		ret = -ENOBUFS;
-	if (copy_to_user(kcmd.resbuf, (void *)hrt, len))
+	else if (copy_to_user(kcmd.resbuf, (void *)hrt, len))
 		ret = -EFAULT;
 
 	return ret;
Signature · 1 line
1.7.0.4