Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

compat: move FS_IOC_RESVSP_32 handling to fs/ioctl.c

... and lose the ridiculous games with compat_alloc_user_space()
there.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Al Viro and committed by
Arnd Bergmann
011da44b 34d3d0e6

+49 -35
-35
fs/compat_ioctl.c
··· 467 467 return -ENOIOCTLCMD; 468 468 } 469 469 470 - /* on ia32 l_start is on a 32-bit boundary */ 471 - #if defined(CONFIG_X86_64) 472 - struct space_resv_32 { 473 - __s16 l_type; 474 - __s16 l_whence; 475 - __s64 l_start __attribute__((packed)); 476 - /* len == 0 means until end of file */ 477 - __s64 l_len __attribute__((packed)); 478 - __s32 l_sysid; 479 - __u32 l_pid; 480 - __s32 l_pad[4]; /* reserve area */ 481 - }; 482 - 483 - #define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32) 484 - #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32) 485 - 486 - /* just account for different alignment */ 487 - static int compat_ioctl_preallocate(struct file *file, 488 - struct space_resv_32 __user *p32) 489 - { 490 - struct space_resv __user *p = compat_alloc_user_space(sizeof(*p)); 491 - 492 - if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) || 493 - copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) || 494 - copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) || 495 - copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) || 496 - copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) || 497 - copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) || 498 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32))) 499 - return -EFAULT; 500 - 501 - return ioctl_preallocate(file, p); 502 - } 503 - #endif 504 - 505 470 /* 506 471 * simple reversible transform to make our table more evenly 507 472 * distributed after sorting.
+29
fs/ioctl.c
··· 491 491 return vfs_fallocate(filp, FALLOC_FL_KEEP_SIZE, sr.l_start, sr.l_len); 492 492 } 493 493 494 + /* on ia32 l_start is on a 32-bit boundary */ 495 + #if defined CONFIG_COMPAT && defined(CONFIG_X86_64) 496 + /* just account for different alignment */ 497 + int compat_ioctl_preallocate(struct file *file, 498 + struct space_resv_32 __user *argp) 499 + { 500 + struct inode *inode = file_inode(file); 501 + struct space_resv_32 sr; 502 + 503 + if (copy_from_user(&sr, argp, sizeof(sr))) 504 + return -EFAULT; 505 + 506 + switch (sr.l_whence) { 507 + case SEEK_SET: 508 + break; 509 + case SEEK_CUR: 510 + sr.l_start += file->f_pos; 511 + break; 512 + case SEEK_END: 513 + sr.l_start += i_size_read(inode); 514 + break; 515 + default: 516 + return -EINVAL; 517 + } 518 + 519 + return vfs_fallocate(file, FALLOC_FL_KEEP_SIZE, sr.l_start, sr.l_len); 520 + } 521 + #endif 522 + 494 523 static int file_ioctl(struct file *filp, unsigned int cmd, 495 524 unsigned long arg) 496 525 {
+20
include/linux/falloc.h
··· 29 29 FALLOC_FL_INSERT_RANGE | \ 30 30 FALLOC_FL_UNSHARE_RANGE) 31 31 32 + /* on ia32 l_start is on a 32-bit boundary */ 33 + #if defined(CONFIG_X86_64) 34 + struct space_resv_32 { 35 + __s16 l_type; 36 + __s16 l_whence; 37 + __s64 l_start __attribute__((packed)); 38 + /* len == 0 means until end of file */ 39 + __s64 l_len __attribute__((packed)); 40 + __s32 l_sysid; 41 + __u32 l_pid; 42 + __s32 l_pad[4]; /* reserve area */ 43 + }; 44 + 45 + #define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32) 46 + #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32) 47 + 48 + int compat_ioctl_preallocate(struct file *, struct space_resv_32 __user *); 49 + 50 + #endif 51 + 32 52 #endif /* _FALLOC_H_ */