aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2006-01-17 10:26:28 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-01-17 10:26:28 -0500
commit0825788ff27c7145e9d558cb2a26f3837d1f9be5 (patch)
treef6bdb892cec8ca0df69c08a3477c89f1542999e5 /fs/compat.c
parent02f693c7118f6be9e677070eb630c1f3a654cdd3 (diff)
parent1bc4ccfff8675adc3d96f91245eb7e2dc0043ca9 (diff)
Merge branch 'upstream'
Diffstat (limited to 'fs/compat.c')
-rw-r--r--fs/compat.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/fs/compat.c b/fs/compat.c
index 818634120b69..2468ac1df2f0 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -494,9 +494,21 @@ asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
494 ret = sys_fcntl(fd, cmd, (unsigned long)&f); 494 ret = sys_fcntl(fd, cmd, (unsigned long)&f);
495 set_fs(old_fs); 495 set_fs(old_fs);
496 if (cmd == F_GETLK && ret == 0) { 496 if (cmd == F_GETLK && ret == 0) {
497 if ((f.l_start >= COMPAT_OFF_T_MAX) || 497 /* GETLK was successfule and we need to return the data...
498 ((f.l_start + f.l_len) > COMPAT_OFF_T_MAX)) 498 * but it needs to fit in the compat structure.
499 * l_start shouldn't be too big, unless the original
500 * start + end is greater than COMPAT_OFF_T_MAX, in which
501 * case the app was asking for trouble, so we return
502 * -EOVERFLOW in that case.
503 * l_len could be too big, in which case we just truncate it,
504 * and only allow the app to see that part of the conflicting
505 * lock that might make sense to it anyway
506 */
507
508 if (f.l_start > COMPAT_OFF_T_MAX)
499 ret = -EOVERFLOW; 509 ret = -EOVERFLOW;
510 if (f.l_len > COMPAT_OFF_T_MAX)
511 f.l_len = COMPAT_OFF_T_MAX;
500 if (ret == 0) 512 if (ret == 0)
501 ret = put_compat_flock(&f, compat_ptr(arg)); 513 ret = put_compat_flock(&f, compat_ptr(arg));
502 } 514 }
@@ -515,9 +527,11 @@ asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
515 (unsigned long)&f); 527 (unsigned long)&f);
516 set_fs(old_fs); 528 set_fs(old_fs);
517 if (cmd == F_GETLK64 && ret == 0) { 529 if (cmd == F_GETLK64 && ret == 0) {
518 if ((f.l_start >= COMPAT_LOFF_T_MAX) || 530 /* need to return lock information - see above for commentary */
519 ((f.l_start + f.l_len) > COMPAT_LOFF_T_MAX)) 531 if (f.l_start > COMPAT_LOFF_T_MAX)
520 ret = -EOVERFLOW; 532 ret = -EOVERFLOW;
533 if (f.l_len > COMPAT_LOFF_T_MAX)
534 f.l_len = COMPAT_LOFF_T_MAX;
521 if (ret == 0) 535 if (ret == 0)
522 ret = put_compat_flock64(&f, compat_ptr(arg)); 536 ret = put_compat_flock64(&f, compat_ptr(arg));
523 } 537 }
@@ -1170,7 +1184,7 @@ static ssize_t compat_do_readv_writev(int type, struct file *file,
1170 } 1184 }
1171 1185
1172 ret = rw_verify_area(type, file, pos, tot_len); 1186 ret = rw_verify_area(type, file, pos, tot_len);
1173 if (ret) 1187 if (ret < 0)
1174 goto out; 1188 goto out;
1175 1189
1176 fnv = NULL; 1190 fnv = NULL;
@@ -1523,7 +1537,7 @@ out_ret:
1523 * Ooo, nasty. We need here to frob 32-bit unsigned longs to 1537 * Ooo, nasty. We need here to frob 32-bit unsigned longs to
1524 * 64-bit unsigned longs. 1538 * 64-bit unsigned longs.
1525 */ 1539 */
1526static inline 1540static
1527int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, 1541int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1528 unsigned long *fdset) 1542 unsigned long *fdset)
1529{ 1543{
@@ -1556,7 +1570,7 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1556 return 0; 1570 return 0;
1557} 1571}
1558 1572
1559static inline 1573static
1560void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, 1574void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1561 unsigned long *fdset) 1575 unsigned long *fdset)
1562{ 1576{