Skip to contentSkip to conversation

add copy_to_user result check

PATCH New Coywolf Qi Hunt 1 participant 1 message Jul 17, 2005 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add copy_to_user result check

hello,

GCC warns me this problem. This patch adds copy_to_user result check in sys_select() and sys_pselect7().

---

fs/select.c +4 -2
diff -pruN 2.6.13-rc3-mm1/fs/select.c 2.6.13-rc3-mm1-cy1/fs/select.c
@@ -401,7 +401,8 @@ asmlinkage long sys_select(int n, fd_set
 			tv.tv_sec++;
 			tv.tv_usec -= 1000000;
 		}
-		copy_to_user(tvp, &tv, sizeof(tv));
+		if (copy_to_user(tvp, &tv, sizeof(tv)))
+			return -EFAULT;
 	}
 
 	return ret;
@@ -459,7 +460,8 @@ asmlinkage long sys_pselect7(int n, fd_s
 			ts.tv_sec++;
 			ts.tv_nsec -= 1000000000;
 		}
-		copy_to_user(tsp, &ts, sizeof(ts));
+		if (copy_to_user(tsp, &ts, sizeof(ts)))
+			return -EFAULT;
 	}
 
 	if (sigmask)