* [patch/rfc] s390: get rid of own uid16 compat system calls
@ 2006-07-10 8:51 Heiko Carstens
2006-07-27 1:03 ` Arnd Bergmann
0 siblings, 1 reply; 11+ messages in thread
From: Heiko Carstens @ 2006-07-10 8:51 UTC (permalink / raw)
To: linux-kernel; +Cc: Martin Schwidefsky
Hi all,
I was about to get rid of the compat uid16 system calls we have in s390
arch code and use the common code uid16 ones (see patch below). Since in 64
bit mode we don't have any of the uid16 system calls, these could be used for
the compat layer where we need them.
"Only" thing is that we unfortunately have different sizes for
__kernel_old_[uid|gid]_t (16 bit on s390, 32 on s390x). I was tempted to
change these just to find out that there are other users as well:
include/linux/ncp_fs.h:
#define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_old_uid_t)
include/linux/smb_fs.h:
#define SMB_IOC_GETMOUNTUID _IOR('u', 1, __kernel_old_uid_t)
So, this is no option. Would anybody know of something to get this work?
Or is this just a stupid idea?
---
arch/s390/kernel/compat_linux.c | 206 --------------------------------------
arch/s390/kernel/compat_wrapper.S | 98 ++++++++----------
arch/s390/kernel/syscalls.S | 38 +++----
init/Kconfig | 2
4 files changed, 65 insertions(+), 279 deletions(-)
Index: linux-2.6/arch/s390/kernel/compat_linux.c
===================================================================
--- linux-2.6.orig/arch/s390/kernel/compat_linux.c
+++ linux-2.6/arch/s390/kernel/compat_linux.c
@@ -15,7 +15,6 @@
*
*/
-
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/fs.h>
@@ -69,211 +68,6 @@
#include "compat_linux.h"
-
-/* For this source file, we want overflow handling. */
-
-#undef high2lowuid
-#undef high2lowgid
-#undef low2highuid
-#undef low2highgid
-#undef SET_UID16
-#undef SET_GID16
-#undef NEW_TO_OLD_UID
-#undef NEW_TO_OLD_GID
-#undef SET_OLDSTAT_UID
-#undef SET_OLDSTAT_GID
-#undef SET_STAT_UID
-#undef SET_STAT_GID
-
-#define high2lowuid(uid) ((uid) > 65535) ? (u16)overflowuid : (u16)(uid)
-#define high2lowgid(gid) ((gid) > 65535) ? (u16)overflowgid : (u16)(gid)
-#define low2highuid(uid) ((uid) == (u16)-1) ? (uid_t)-1 : (uid_t)(uid)
-#define low2highgid(gid) ((gid) == (u16)-1) ? (gid_t)-1 : (gid_t)(gid)
-#define SET_UID16(var, uid) var = high2lowuid(uid)
-#define SET_GID16(var, gid) var = high2lowgid(gid)
-#define NEW_TO_OLD_UID(uid) high2lowuid(uid)
-#define NEW_TO_OLD_GID(gid) high2lowgid(gid)
-#define SET_OLDSTAT_UID(stat, uid) (stat).st_uid = high2lowuid(uid)
-#define SET_OLDSTAT_GID(stat, gid) (stat).st_gid = high2lowgid(gid)
-#define SET_STAT_UID(stat, uid) (stat).st_uid = high2lowuid(uid)
-#define SET_STAT_GID(stat, gid) (stat).st_gid = high2lowgid(gid)
-
-asmlinkage long sys32_chown16(const char __user * filename, u16 user, u16 group)
-{
- return sys_chown(filename, low2highuid(user), low2highgid(group));
-}
-
-asmlinkage long sys32_lchown16(const char __user * filename, u16 user, u16 group)
-{
- return sys_lchown(filename, low2highuid(user), low2highgid(group));
-}
-
-asmlinkage long sys32_fchown16(unsigned int fd, u16 user, u16 group)
-{
- return sys_fchown(fd, low2highuid(user), low2highgid(group));
-}
-
-asmlinkage long sys32_setregid16(u16 rgid, u16 egid)
-{
- return sys_setregid(low2highgid(rgid), low2highgid(egid));
-}
-
-asmlinkage long sys32_setgid16(u16 gid)
-{
- return sys_setgid((gid_t)gid);
-}
-
-asmlinkage long sys32_setreuid16(u16 ruid, u16 euid)
-{
- return sys_setreuid(low2highuid(ruid), low2highuid(euid));
-}
-
-asmlinkage long sys32_setuid16(u16 uid)
-{
- return sys_setuid((uid_t)uid);
-}
-
-asmlinkage long sys32_setresuid16(u16 ruid, u16 euid, u16 suid)
-{
- return sys_setresuid(low2highuid(ruid), low2highuid(euid),
- low2highuid(suid));
-}
-
-asmlinkage long sys32_getresuid16(u16 __user *ruid, u16 __user *euid, u16 __user *suid)
-{
- int retval;
-
- if (!(retval = put_user(high2lowuid(current->uid), ruid)) &&
- !(retval = put_user(high2lowuid(current->euid), euid)))
- retval = put_user(high2lowuid(current->suid), suid);
-
- return retval;
-}
-
-asmlinkage long sys32_setresgid16(u16 rgid, u16 egid, u16 sgid)
-{
- return sys_setresgid(low2highgid(rgid), low2highgid(egid),
- low2highgid(sgid));
-}
-
-asmlinkage long sys32_getresgid16(u16 __user *rgid, u16 __user *egid, u16 __user *sgid)
-{
- int retval;
-
- if (!(retval = put_user(high2lowgid(current->gid), rgid)) &&
- !(retval = put_user(high2lowgid(current->egid), egid)))
- retval = put_user(high2lowgid(current->sgid), sgid);
-
- return retval;
-}
-
-asmlinkage long sys32_setfsuid16(u16 uid)
-{
- return sys_setfsuid((uid_t)uid);
-}
-
-asmlinkage long sys32_setfsgid16(u16 gid)
-{
- return sys_setfsgid((gid_t)gid);
-}
-
-static int groups16_to_user(u16 __user *grouplist, struct group_info *group_info)
-{
- int i;
- u16 group;
-
- for (i = 0; i < group_info->ngroups; i++) {
- group = (u16)GROUP_AT(group_info, i);
- if (put_user(group, grouplist+i))
- return -EFAULT;
- }
-
- return 0;
-}
-
-static int groups16_from_user(struct group_info *group_info, u16 __user *grouplist)
-{
- int i;
- u16 group;
-
- for (i = 0; i < group_info->ngroups; i++) {
- if (get_user(group, grouplist+i))
- return -EFAULT;
- GROUP_AT(group_info, i) = (gid_t)group;
- }
-
- return 0;
-}
-
-asmlinkage long sys32_getgroups16(int gidsetsize, u16 __user *grouplist)
-{
- int i;
-
- if (gidsetsize < 0)
- return -EINVAL;
-
- get_group_info(current->group_info);
- i = current->group_info->ngroups;
- if (gidsetsize) {
- if (i > gidsetsize) {
- i = -EINVAL;
- goto out;
- }
- if (groups16_to_user(grouplist, current->group_info)) {
- i = -EFAULT;
- goto out;
- }
- }
-out:
- put_group_info(current->group_info);
- return i;
-}
-
-asmlinkage long sys32_setgroups16(int gidsetsize, u16 __user *grouplist)
-{
- struct group_info *group_info;
- int retval;
-
- if (!capable(CAP_SETGID))
- return -EPERM;
- if ((unsigned)gidsetsize > NGROUPS_MAX)
- return -EINVAL;
-
- group_info = groups_alloc(gidsetsize);
- if (!group_info)
- return -ENOMEM;
- retval = groups16_from_user(group_info, grouplist);
- if (retval) {
- put_group_info(group_info);
- return retval;
- }
-
- retval = set_current_groups(group_info);
- put_group_info(group_info);
-
- return retval;
-}
-
-asmlinkage long sys32_getuid16(void)
-{
- return high2lowuid(current->uid);
-}
-
-asmlinkage long sys32_geteuid16(void)
-{
- return high2lowuid(current->euid);
-}
-
-asmlinkage long sys32_getgid16(void)
-{
- return high2lowgid(current->gid);
-}
-
-asmlinkage long sys32_getegid16(void)
-{
- return high2lowgid(current->egid);
-}
-
/* 32-bit timeval and related flotsam. */
static inline long get_tv32(struct timeval *o, struct compat_timeval __user *i)
Index: linux-2.6/init/Kconfig
===================================================================
--- linux-2.6.orig/init/Kconfig
+++ linux-2.6/init/Kconfig
@@ -239,7 +239,7 @@ source "usr/Kconfig"
config UID16
bool "Enable 16-bit UID system calls" if EMBEDDED
- depends on ARM || CRIS || FRV || H8300 || X86_32 || M68K || (S390 && !64BIT) || SUPERH || SPARC32 || (SPARC64 && SPARC32_COMPAT) || UML || (X86_64 && IA32_EMULATION)
+ depends on ARM || CRIS || FRV || H8300 || X86_32 || M68K || (S390 && (!64BIT || COMPAT)) || SUPERH || SPARC32 || (SPARC64 && SPARC32_COMPAT) || UML || (X86_64 && IA32_EMULATION)
default y
help
This enables the legacy 16-bit UID syscall wrappers.
Index: linux-2.6/arch/s390/kernel/compat_wrapper.S
===================================================================
--- linux-2.6.orig/arch/s390/kernel/compat_wrapper.S
+++ linux-2.6/arch/s390/kernel/compat_wrapper.S
@@ -78,12 +78,12 @@ sys32_chmod_wrapper:
llgfr %r3,%r3 # mode_t
jg sys_chmod # branch to system call
- .globl sys32_lchown16_wrapper
-sys32_lchown16_wrapper:
+ .globl sys_lchown16_wrapper
+sys_lchown16_wrapper:
llgtr %r2,%r2 # const char *
llgfr %r3,%r3 # __kernel_old_uid_emu31_t
llgfr %r4,%r4 # __kernel_old_uid_emu31_t
- jg sys32_lchown16 # branch to system call
+ jg sys_lchown16 # branch to system call
.globl sys32_lseek_wrapper
sys32_lseek_wrapper:
@@ -108,12 +108,10 @@ sys32_oldumount_wrapper:
llgtr %r2,%r2 # char *
jg sys_oldumount # branch to system call
- .globl sys32_setuid16_wrapper
-sys32_setuid16_wrapper:
+ .globl sys_setuid16_wrapper
+sys_setuid16_wrapper:
llgfr %r2,%r2 # __kernel_old_uid_emu31_t
- jg sys32_setuid16 # branch to system call
-
-#sys32_getuid16_wrapper # void
+ jg sys_setuid16 # branch to system call
.globl sys32_ptrace_wrapper
sys32_ptrace_wrapper:
@@ -192,12 +190,10 @@ sys32_brk_wrapper:
llgtr %r2,%r2 # unsigned long
jg sys_brk # branch to system call
- .globl sys32_setgid16_wrapper
-sys32_setgid16_wrapper:
+ .globl sys_setgid16_wrapper
+sys_setgid16_wrapper:
llgfr %r2,%r2 # __kernel_old_gid_emu31_t
- jg sys32_setgid16 # branch to system call
-
-#sys32_getgid16_wrapper # void
+ jg sys_setgid16 # branch to system call
.globl sys32_signal_wrapper
sys32_signal_wrapper:
@@ -205,10 +201,6 @@ sys32_signal_wrapper:
llgtr %r3,%r3 # __sighandler_t
jg sys_signal
-#sys32_geteuid16_wrapper # void
-
-#sys32_getegid16_wrapper # void
-
.globl sys32_acct_wrapper
sys32_acct_wrapper:
llgtr %r2,%r2 # char *
@@ -275,17 +267,17 @@ sys32_sigaction_wrapper:
llgtr %r4,%r4 # struct old_sigaction32 *
jg sys32_sigaction # branch to system call
- .globl sys32_setreuid16_wrapper
-sys32_setreuid16_wrapper:
+ .globl sys_setreuid16_wrapper
+sys_setreuid16_wrapper:
llgfr %r2,%r2 # __kernel_old_uid_emu31_t
llgfr %r3,%r3 # __kernel_old_uid_emu31_t
- jg sys32_setreuid16 # branch to system call
+ jg sys_setreuid16 # branch to system call
- .globl sys32_setregid16_wrapper
-sys32_setregid16_wrapper:
+ .globl sys_setregid16_wrapper
+sys_setregid16_wrapper:
llgfr %r2,%r2 # __kernel_old_gid_emu31_t
llgfr %r3,%r3 # __kernel_old_gid_emu31_t
- jg sys32_setregid16 # branch to system call
+ jg sys_setregid16 # branch to system call
.globl sys_sigsuspend_wrapper
sys_sigsuspend_wrapper:
@@ -346,17 +338,17 @@ sys32_settimeofday_wrapper:
llgtr %r3,%r3 # struct timezone *
jg sys32_settimeofday # branch to system call
- .globl sys32_getgroups16_wrapper
-sys32_getgroups16_wrapper:
+ .globl sys_getgroups16_wrapper
+sys_getgroups16_wrapper:
lgfr %r2,%r2 # int
llgtr %r3,%r3 # __kernel_old_gid_emu31_t *
- jg sys32_getgroups16 # branch to system call
+ jg sys_getgroups16 # branch to system call
- .globl sys32_setgroups16_wrapper
-sys32_setgroups16_wrapper:
+ .globl sys_setgroups16_wrapper
+sys_setgroups16_wrapper:
lgfr %r2,%r2 # int
llgtr %r3,%r3 # __kernel_old_gid_emu31_t *
- jg sys32_setgroups16 # branch to system call
+ jg sys_setgroups16 # branch to system call
.globl sys32_symlink_wrapper
sys32_symlink_wrapper:
@@ -426,12 +418,12 @@ sys32_fchmod_wrapper:
llgfr %r3,%r3 # mode_t
jg sys_fchmod # branch to system call
- .globl sys32_fchown16_wrapper
-sys32_fchown16_wrapper:
+ .globl sys_fchown16_wrapper
+sys_fchown16_wrapper:
llgfr %r2,%r2 # unsigned int
llgfr %r3,%r3 # compat_uid_t
llgfr %r4,%r4 # compat_uid_t
- jg sys32_fchown16 # branch to system call
+ jg sys_fchown16 # branch to system call
.globl sys32_getpriority_wrapper
sys32_getpriority_wrapper:
@@ -619,15 +611,15 @@ sys32_personality_wrapper:
llgfr %r2,%r2 # unsigned long
jg s390x_personality # branch to system call
- .globl sys32_setfsuid16_wrapper
-sys32_setfsuid16_wrapper:
+ .globl sys_setfsuid16_wrapper
+sys_setfsuid16_wrapper:
llgfr %r2,%r2 # __kernel_old_uid_emu31_t
- jg sys32_setfsuid16 # branch to system call
+ jg sys_setfsuid16 # branch to system call
- .globl sys32_setfsgid16_wrapper
-sys32_setfsgid16_wrapper:
+ .globl sys_setfsgid16_wrapper
+sys_setfsgid16_wrapper:
llgfr %r2,%r2 # __kernel_old_gid_emu31_t
- jg sys32_setfsgid16 # branch to system call
+ jg sys_setfsgid16 # branch to system call
.globl sys32_llseek_wrapper
sys32_llseek_wrapper:
@@ -769,19 +761,19 @@ sys32_mremap_wrapper:
llgfr %r6,%r6 # unsigned long
jg sys_mremap # branch to system call
- .globl sys32_setresuid16_wrapper
-sys32_setresuid16_wrapper:
+ .globl sys_setresuid16_wrapper
+sys_setresuid16_wrapper:
llgfr %r2,%r2 # __kernel_old_uid_emu31_t
llgfr %r3,%r3 # __kernel_old_uid_emu31_t
llgfr %r4,%r4 # __kernel_old_uid_emu31_t
- jg sys32_setresuid16 # branch to system call
+ jg sys_setresuid16 # branch to system call
- .globl sys32_getresuid16_wrapper
-sys32_getresuid16_wrapper:
+ .globl sys_getresuid16_wrapper
+sys_getresuid16_wrapper:
llgtr %r2,%r2 # __kernel_old_uid_emu31_t *
llgtr %r3,%r3 # __kernel_old_uid_emu31_t *
llgtr %r4,%r4 # __kernel_old_uid_emu31_t *
- jg sys32_getresuid16 # branch to system call
+ jg sys_getresuid16 # branch to system call
.globl sys32_poll_wrapper
sys32_poll_wrapper:
@@ -797,19 +789,19 @@ compat_sys_nfsservctl_wrapper:
llgtr %r4,%r4 # union compat_nfsctl_res*
jg compat_sys_nfsservctl # branch to system call
- .globl sys32_setresgid16_wrapper
-sys32_setresgid16_wrapper:
+ .globl sys_setresgid16_wrapper
+sys_setresgid16_wrapper:
llgfr %r2,%r2 # __kernel_old_gid_emu31_t
llgfr %r3,%r3 # __kernel_old_gid_emu31_t
llgfr %r4,%r4 # __kernel_old_gid_emu31_t
- jg sys32_setresgid16 # branch to system call
+ jg sys_setresgid16 # branch to system call
- .globl sys32_getresgid16_wrapper
-sys32_getresgid16_wrapper:
+ .globl sys_getresgid16_wrapper
+sys_getresgid16_wrapper:
llgtr %r2,%r2 # __kernel_old_gid_emu31_t *
llgtr %r3,%r3 # __kernel_old_gid_emu31_t *
llgtr %r4,%r4 # __kernel_old_gid_emu31_t *
- jg sys32_getresgid16 # branch to system call
+ jg sys_getresgid16 # branch to system call
.globl sys32_prctl_wrapper
sys32_prctl_wrapper:
@@ -883,12 +875,12 @@ sys32_pwrite64_wrapper:
llgfr %r6,%r6 # u32
jg sys32_pwrite64 # branch to system call
- .globl sys32_chown16_wrapper
-sys32_chown16_wrapper:
+ .globl sys_chown16_wrapper
+sys_chown16_wrapper:
llgtr %r2,%r2 # const char *
llgfr %r3,%r3 # __kernel_old_uid_emu31_t
llgfr %r4,%r4 # __kernel_old_gid_emu31_t
- jg sys32_chown16 # branch to system call
+ jg sys_chown16 # branch to system call
.globl sys32_getcwd_wrapper
sys32_getcwd_wrapper:
Index: linux-2.6/arch/s390/kernel/syscalls.S
===================================================================
--- linux-2.6.orig/arch/s390/kernel/syscalls.S
+++ linux-2.6/arch/s390/kernel/syscalls.S
@@ -24,15 +24,15 @@ SYSCALL(sys_chdir,sys_chdir,sys32_chdir_
SYSCALL(sys_time,sys_ni_syscall,sys32_time_wrapper) /* old time syscall */
SYSCALL(sys_mknod,sys_mknod,sys32_mknod_wrapper)
SYSCALL(sys_chmod,sys_chmod,sys32_chmod_wrapper) /* 15 */
-SYSCALL(sys_lchown16,sys_ni_syscall,sys32_lchown16_wrapper) /* old lchown16 syscall*/
+SYSCALL(sys_lchown16,sys_ni_syscall,sys_lchown16_wrapper) /* old lchown16 syscall*/
NI_SYSCALL /* old break syscall holder */
NI_SYSCALL /* old stat syscall holder */
SYSCALL(sys_lseek,sys_lseek,sys32_lseek_wrapper)
SYSCALL(sys_getpid,sys_getpid,sys_getpid) /* 20 */
SYSCALL(sys_mount,sys_mount,sys32_mount_wrapper)
SYSCALL(sys_oldumount,sys_oldumount,sys32_oldumount_wrapper)
-SYSCALL(sys_setuid16,sys_ni_syscall,sys32_setuid16_wrapper) /* old setuid16 syscall*/
-SYSCALL(sys_getuid16,sys_ni_syscall,sys32_getuid16) /* old getuid16 syscall*/
+SYSCALL(sys_setuid16,sys_ni_syscall,sys_setuid16_wrapper) /* old setuid16 syscall*/
+SYSCALL(sys_getuid16,sys_ni_syscall,sys_getuid16) /* old getuid16 syscall*/
SYSCALL(sys_stime,sys_ni_syscall,sys32_stime_wrapper) /* 25 old stime syscall */
SYSCALL(sys_ptrace,sys_ptrace,sys32_ptrace_wrapper)
SYSCALL(sys_alarm,sys_alarm,sys32_alarm_wrapper)
@@ -54,11 +54,11 @@ SYSCALL(sys_pipe,sys_pipe,sys32_pipe_wra
SYSCALL(sys_times,sys_times,compat_sys_times_wrapper)
NI_SYSCALL /* old prof syscall */
SYSCALL(sys_brk,sys_brk,sys32_brk_wrapper) /* 45 */
-SYSCALL(sys_setgid16,sys_ni_syscall,sys32_setgid16_wrapper) /* old setgid16 syscall*/
-SYSCALL(sys_getgid16,sys_ni_syscall,sys32_getgid16) /* old getgid16 syscall*/
+SYSCALL(sys_setgid16,sys_ni_syscall,sys_setgid16_wrapper) /* old setgid16 syscall*/
+SYSCALL(sys_getgid16,sys_ni_syscall,sys_getgid16) /* old getgid16 syscall*/
SYSCALL(sys_signal,sys_signal,sys32_signal_wrapper)
-SYSCALL(sys_geteuid16,sys_ni_syscall,sys32_geteuid16) /* old geteuid16 syscall */
-SYSCALL(sys_getegid16,sys_ni_syscall,sys32_getegid16) /* 50 old getegid16 syscall */
+SYSCALL(sys_geteuid16,sys_ni_syscall,sys_geteuid16) /* old geteuid16 syscall */
+SYSCALL(sys_getegid16,sys_ni_syscall,sys_getegid16) /* 50 old getegid16 syscall */
SYSCALL(sys_acct,sys_acct,sys32_acct_wrapper)
SYSCALL(sys_umount,sys_umount,sys32_umount_wrapper)
NI_SYSCALL /* old lock syscall */
@@ -78,8 +78,8 @@ SYSCALL(sys_setsid,sys_setsid,sys_setsid
SYSCALL(sys_sigaction,sys_sigaction,sys32_sigaction_wrapper)
NI_SYSCALL /* old sgetmask syscall*/
NI_SYSCALL /* old ssetmask syscall*/
-SYSCALL(sys_setreuid16,sys_ni_syscall,sys32_setreuid16_wrapper) /* old setreuid16 syscall */
-SYSCALL(sys_setregid16,sys_ni_syscall,sys32_setregid16_wrapper) /* old setregid16 syscall */
+SYSCALL(sys_setreuid16,sys_ni_syscall,sys_setreuid16_wrapper) /* old setreuid16 syscall */
+SYSCALL(sys_setregid16,sys_ni_syscall,sys_setregid16_wrapper) /* old setregid16 syscall */
SYSCALL(sys_sigsuspend,sys_sigsuspend,sys_sigsuspend_wrapper)
SYSCALL(sys_sigpending,sys_sigpending,compat_sys_sigpending_wrapper)
SYSCALL(sys_sethostname,sys_sethostname,sys32_sethostname_wrapper)
@@ -88,8 +88,8 @@ SYSCALL(sys_old_getrlimit,sys_getrlimit,
SYSCALL(sys_getrusage,sys_getrusage,compat_sys_getrusage_wrapper)
SYSCALL(sys_gettimeofday,sys_gettimeofday,sys32_gettimeofday_wrapper)
SYSCALL(sys_settimeofday,sys_settimeofday,sys32_settimeofday_wrapper)
-SYSCALL(sys_getgroups16,sys_ni_syscall,sys32_getgroups16_wrapper) /* 80 old getgroups16 syscall */
-SYSCALL(sys_setgroups16,sys_ni_syscall,sys32_setgroups16_wrapper) /* old setgroups16 syscall */
+SYSCALL(sys_getgroups16,sys_ni_syscall,sys_getgroups16_wrapper) /* 80 old getgroups16 syscall */
+SYSCALL(sys_setgroups16,sys_ni_syscall,sys_setgroups16_wrapper) /* old setgroups16 syscall */
NI_SYSCALL /* old select syscall */
SYSCALL(sys_symlink,sys_symlink,sys32_symlink_wrapper)
NI_SYSCALL /* old lstat syscall */
@@ -103,7 +103,7 @@ SYSCALL(sys_munmap,sys_munmap,sys32_munm
SYSCALL(sys_truncate,sys_truncate,sys32_truncate_wrapper)
SYSCALL(sys_ftruncate,sys_ftruncate,sys32_ftruncate_wrapper)
SYSCALL(sys_fchmod,sys_fchmod,sys32_fchmod_wrapper)
-SYSCALL(sys_fchown16,sys_ni_syscall,sys32_fchown16_wrapper) /* 95 old fchown16 syscall*/
+SYSCALL(sys_fchown16,sys_ni_syscall,sys_fchown16_wrapper) /* 95 old fchown16 syscall*/
SYSCALL(sys_getpriority,sys_getpriority,sys32_getpriority_wrapper)
SYSCALL(sys_setpriority,sys_setpriority,sys32_setpriority_wrapper)
NI_SYSCALL /* old profil syscall */
@@ -146,8 +146,8 @@ SYSCALL(sys_bdflush,sys_bdflush,sys32_bd
SYSCALL(sys_sysfs,sys_sysfs,sys32_sysfs_wrapper) /* 135 */
SYSCALL(sys_personality,s390x_personality,sys32_personality_wrapper)
NI_SYSCALL /* for afs_syscall */
-SYSCALL(sys_setfsuid16,sys_ni_syscall,sys32_setfsuid16_wrapper) /* old setfsuid16 syscall */
-SYSCALL(sys_setfsgid16,sys_ni_syscall,sys32_setfsgid16_wrapper) /* old setfsgid16 syscall */
+SYSCALL(sys_setfsuid16,sys_ni_syscall,sys_setfsuid16_wrapper) /* old setfsuid16 syscall */
+SYSCALL(sys_setfsgid16,sys_ni_syscall,sys_setfsgid16_wrapper) /* old setfsgid16 syscall */
SYSCALL(sys_llseek,sys_llseek,sys32_llseek_wrapper) /* 140 */
SYSCALL(sys_getdents,sys_getdents,sys32_getdents_wrapper)
SYSCALL(sys_select,sys_select,compat_sys_select_wrapper)
@@ -172,14 +172,14 @@ SYSCALL(sys_sched_get_priority_min,sys_s
SYSCALL(sys_sched_rr_get_interval,sys_sched_rr_get_interval,sys32_sched_rr_get_interval_wrapper)
SYSCALL(sys_nanosleep,sys_nanosleep,compat_sys_nanosleep_wrapper)
SYSCALL(sys_mremap,sys_mremap,sys32_mremap_wrapper)
-SYSCALL(sys_setresuid16,sys_ni_syscall,sys32_setresuid16_wrapper) /* old setresuid16 syscall */
-SYSCALL(sys_getresuid16,sys_ni_syscall,sys32_getresuid16_wrapper) /* 165 old getresuid16 syscall */
+SYSCALL(sys_setresuid16,sys_ni_syscall,sys_setresuid16_wrapper) /* old setresuid16 syscall */
+SYSCALL(sys_getresuid16,sys_ni_syscall,sys_getresuid16_wrapper) /* 165 old getresuid16 syscall */
NI_SYSCALL /* for vm86 */
NI_SYSCALL /* old sys_query_module */
SYSCALL(sys_poll,sys_poll,sys32_poll_wrapper)
SYSCALL(sys_nfsservctl,sys_nfsservctl,compat_sys_nfsservctl_wrapper)
-SYSCALL(sys_setresgid16,sys_ni_syscall,sys32_setresgid16_wrapper) /* 170 old setresgid16 syscall */
-SYSCALL(sys_getresgid16,sys_ni_syscall,sys32_getresgid16_wrapper) /* old getresgid16 syscall */
+SYSCALL(sys_setresgid16,sys_ni_syscall,sys_setresgid16_wrapper) /* 170 old setresgid16 syscall */
+SYSCALL(sys_getresgid16,sys_ni_syscall,sys_getresgid16_wrapper) /* old getresgid16 syscall */
SYSCALL(sys_prctl,sys_prctl,sys32_prctl_wrapper)
SYSCALL(sys_rt_sigreturn_glue,sys_rt_sigreturn_glue,sys32_rt_sigreturn_glue)
SYSCALL(sys_rt_sigaction,sys_rt_sigaction,sys32_rt_sigaction_wrapper)
@@ -190,7 +190,7 @@ SYSCALL(sys_rt_sigqueueinfo,sys_rt_sigqu
SYSCALL(sys_rt_sigsuspend,sys_rt_sigsuspend,compat_sys_rt_sigsuspend_wrapper)
SYSCALL(sys_pread64,sys_pread64,sys32_pread64_wrapper) /* 180 */
SYSCALL(sys_pwrite64,sys_pwrite64,sys32_pwrite64_wrapper)
-SYSCALL(sys_chown16,sys_ni_syscall,sys32_chown16_wrapper) /* old chown16 syscall */
+SYSCALL(sys_chown16,sys_ni_syscall,sys_chown16_wrapper) /* old chown16 syscall */
SYSCALL(sys_getcwd,sys_getcwd,sys32_getcwd_wrapper)
SYSCALL(sys_capget,sys_capget,sys32_capget_wrapper)
SYSCALL(sys_capset,sys_capset,sys32_capset_wrapper) /* 185 */
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch/rfc] s390: get rid of own uid16 compat system calls
2006-07-10 8:51 [patch/rfc] s390: get rid of own uid16 compat system calls Heiko Carstens
@ 2006-07-27 1:03 ` Arnd Bergmann
2006-07-27 1:08 ` reference: ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c Arnd Bergmann
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Arnd Bergmann @ 2006-07-27 1:03 UTC (permalink / raw)
To: Heiko Carstens; +Cc: linux-kernel, Martin Schwidefsky
On Monday 10 July 2006 10:51, Heiko Carstens wrote:
> "Only" thing is that we unfortunately have different sizes for
> __kernel_old_[uid|gid]_t (16 bit on s390, 32 on s390x). I was tempted to
> change these just to find out that there are other users as well:
>
> include/linux/ncp_fs.h:
> #define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_old_uid_t)
> include/linux/smb_fs.h:
> #define SMB_IOC_GETMOUNTUID _IOR('u', 1, __kernel_old_uid_t)
>
> So, this is no option. Would anybody know of something to get this work?
> Or is this just a stupid idea?
Ok, I don't know exactly what you're talking about, but I have in the
past tried to hack that area as well. It's probably a good idea to
pick up my old patch and work from there, by making these two file systems
understand all possible ways:
#ifdef __KERNEL__
/* anything the user may be passing to us */
#define NCP_IOC_GETMOUNTUID16 _IOW('n', 2, u16)
#define NCP_IOC_GETMOUNTUID32 _IOW('n', 2, u32)
#define NCP_IOC_GETMOUNTUID64 _IOW('n', 2, u64)
#else
/* what the user is _supposed_ to pass */
#define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_old_uid_t) /* 16/32 bit */
#define NCP_IOC_GETMOUNTUID2 _IOW('n', 2, unsigned long) /* 32 or 64 bit */
#endif
int ncp_ioctl(struct inode *inode, struct file *filp, ...)
{
...
switch (arg) {
...
case NCP_IOC_GETMOUNTUID16:
case NCP_IOC_GETMOUNTUID32:
case NCP_IOC_GETMOUNTUID64:
{
unsigned long tmp = server->m.mounted_uid;
if ((file_permission(filp, MAY_READ) != 0)
&& (current->uid != server->m.mounted_uid)) {
return -EACCES;
}
switch (arg) {
#ifdef CONFIG_UID16
case NCP_IOC_GETMOUNTUID16:
SET_UID(tmp, server->m.mounted_uid);
if (put_user(tmp, (u16 __user *)argp))
return -EFAULT;
#endif
case NCP_IOC_GETMOUNTUID32:
if (put_user(tmp, (u32 __user *)argp))
return -EFAULT;
#ifdef CONFIG_64BIT
case NCP_IOC_GETMOUNTUID64:
if (put_user(tmp, (u64 __user *)argp))
return -EFAULT;
}
#endif
return 0;
}
}
...
}
I'm also posting the two patches I made a long time ago as a reference.
Arnd <><
^ permalink raw reply [flat|nested] 11+ messages in thread
* reference: ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c
2006-07-27 1:03 ` Arnd Bergmann
@ 2006-07-27 1:08 ` Arnd Bergmann
2006-07-27 2:53 ` Arnd Bergmann
2006-07-27 1:09 ` reference: smbfs: simplify compat_ioctl handling Arnd Bergmann
2006-07-27 6:06 ` [patch/rfc] s390: get rid of own uid16 compat system calls Heiko Carstens
2 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2006-07-27 1:08 UTC (permalink / raw)
To: Heiko Carstens; +Cc: linux-kernel, Martin Schwidefsky
On Thursday 27 July 2006 03:03, Arnd Bergmann wrote:
>
> I'm also posting the two patches I made a long time ago as a reference.
>
Ok, I just realized that this was not using a merged
->compat_ioctl/->unlocked_ioctl function yet, but wth, here
it is anyway.
Subject: ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c
The ncp specific compat ioctls are clearly local to one
file system, so the code can better live there.
This could be further improved by getting rid of get_fs/set_fs
in the future.
CC: vandrove@vc.cvut.cz
CC: linware@sh.cvut.cz
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/fs/compat_ioctl.c
===================================================================
--- linux-cg.orig/fs/compat_ioctl.c 2005-11-05 14:22:34.000000000 +0100
+++ linux-cg/fs/compat_ioctl.c 2005-11-05 15:47:28.000000000 +0100
@@ -718,193 +718,6 @@
return sys_ioctl(fd, cmd, (unsigned long)tdata);
}
-#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
-struct ncp_ioctl_request_32 {
- u32 function;
- u32 size;
- compat_caddr_t data;
-};
-
-struct ncp_fs_info_v2_32 {
- s32 version;
- u32 mounted_uid;
- u32 connection;
- u32 buffer_size;
-
- u32 volume_number;
- u32 directory_id;
-
- u32 dummy1;
- u32 dummy2;
- u32 dummy3;
-};
-
-struct ncp_objectname_ioctl_32
-{
- s32 auth_type;
- u32 object_name_len;
- compat_caddr_t object_name; /* an userspace data, in most cases user name */
-};
-
-struct ncp_privatedata_ioctl_32
-{
- u32 len;
- compat_caddr_t data; /* ~1000 for NDS */
-};
-
-#define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
-#define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
-#define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
-#define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
-#define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
-#define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
-#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
-
-static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_ioctl_request_32 n32;
- struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
-
- if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
- put_user(n32.function, &p->function) ||
- put_user(n32.size, &p->size) ||
- put_user(compat_ptr(n32.data), &p->data))
- return -EFAULT;
-
- return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p);
-}
-
-static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- mm_segment_t old_fs = get_fs();
- __kernel_uid_t kuid;
- int err;
-
- cmd = NCP_IOC_GETMOUNTUID2;
-
- set_fs(KERNEL_DS);
- err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
- set_fs(old_fs);
-
- if (!err)
- err = put_user(kuid,
- (unsigned int __user *) compat_ptr(arg));
-
- return err;
-}
-
-static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- mm_segment_t old_fs = get_fs();
- struct ncp_fs_info_v2_32 n32;
- struct ncp_fs_info_v2 n;
- int err;
-
- if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
- return -EFAULT;
- if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
- return -EINVAL;
- n.version = NCP_GET_FS_INFO_VERSION_V2;
-
- set_fs(KERNEL_DS);
- err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
- set_fs(old_fs);
-
- if (!err) {
- n32.version = n.version;
- n32.mounted_uid = n.mounted_uid;
- n32.connection = n.connection;
- n32.buffer_size = n.buffer_size;
- n32.volume_number = n.volume_number;
- n32.directory_id = n.directory_id;
- n32.dummy1 = n.dummy1;
- n32.dummy2 = n.dummy2;
- n32.dummy3 = n.dummy3;
- err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
- }
- return err;
-}
-
-static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
- struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
- s32 auth_type;
- u32 name_len;
- int err;
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.object_name_len, &p->object_name_len) ||
- put_user(compat_ptr(n32.object_name), &p->object_name))
- return -EFAULT;
-
- err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
- if (err)
- return err;
-
- if (get_user(auth_type, &p->auth_type) ||
- put_user(auth_type, &p32->auth_type) ||
- get_user(name_len, &p->object_name_len) ||
- put_user(name_len, &p32->object_name_len))
- return -EFAULT;
-
- return 0;
-}
-
-static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
- struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.auth_type, &p->auth_type) ||
- put_user(n32.object_name_len, &p->object_name_len) ||
- put_user(compat_ptr(n32.object_name), &p->object_name))
- return -EFAULT;
-
- return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
-}
-
-static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
- struct ncp_privatedata_ioctl __user *p =
- compat_alloc_user_space(sizeof(*p));
- u32 len;
- int err;
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.len, &p->len) ||
- put_user(compat_ptr(n32.data), &p->data))
- return -EFAULT;
-
- err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
- if (err)
- return err;
-
- if (get_user(len, &p->len) ||
- put_user(len, &p32->len))
- return -EFAULT;
-
- return 0;
-}
-
-static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_privatedata_ioctl_32 n32;
- struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
- struct ncp_privatedata_ioctl __user *p =
- compat_alloc_user_space(sizeof(*p));
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.len, &p->len) ||
- put_user(compat_ptr(n32.data), &p->data))
- return -EFAULT;
-
- return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
-}
-#endif
-
#undef CODE
#endif
@@ -937,15 +750,5 @@
HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl)
HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl)
-#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
-HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
-HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
-HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
-HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
-HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
-HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
-HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
-#endif
-
#undef DECLARES
#endif
Index: linux-cg/fs/ncpfs/dir.c
===================================================================
--- linux-cg.orig/fs/ncpfs/dir.c 2005-11-05 14:19:13.000000000 +0100
+++ linux-cg/fs/ncpfs/dir.c 2005-11-05 14:22:34.000000000 +0100
@@ -54,6 +54,9 @@
.read = generic_read_dir,
.readdir = ncp_readdir,
.ioctl = ncp_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = ncp_compat_ioctl,
+#endif
};
struct inode_operations ncp_dir_inode_operations =
Index: linux-cg/fs/ncpfs/file.c
===================================================================
--- linux-cg.orig/fs/ncpfs/file.c 2005-11-05 14:19:13.000000000 +0100
+++ linux-cg/fs/ncpfs/file.c 2005-11-05 14:22:34.000000000 +0100
@@ -9,6 +9,7 @@
#include <asm/uaccess.h>
#include <asm/system.h>
+#include <linux/config.h>
#include <linux/time.h>
#include <linux/kernel.h>
#include <linux/errno.h>
@@ -289,6 +290,9 @@
.read = ncp_file_read,
.write = ncp_file_write,
.ioctl = ncp_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = ncp_compat_ioctl,
+#endif
.mmap = ncp_mmap,
.release = ncp_release,
.fsync = ncp_fsync,
Index: linux-cg/fs/ncpfs/ioctl.c
===================================================================
--- linux-cg.orig/fs/ncpfs/ioctl.c 2005-11-05 14:19:13.000000000 +0100
+++ linux-cg/fs/ncpfs/ioctl.c 2005-11-05 15:44:12.000000000 +0100
@@ -8,8 +8,7 @@
*/
#include <linux/config.h>
-
-#include <asm/uaccess.h>
+#include <linux/compat.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/ioctl.h>
@@ -20,6 +19,8 @@
#include <linux/ncp_fs.h>
+#include <asm/uaccess.h>
+
#include "ncplib_kernel.h"
/* maximum limit for ncp_objectname_ioctl */
@@ -647,3 +648,239 @@
/* #endif */
return -EINVAL;
}
+
+#ifdef CONFIG_COMPAT
+struct ncp_ioctl_request_32 {
+ u32 function;
+ u32 size;
+ compat_caddr_t data;
+};
+
+struct ncp_fs_info_v2_32 {
+ s32 version;
+ u32 mounted_uid;
+ u32 connection;
+ u32 buffer_size;
+
+ u32 volume_number;
+ u32 directory_id;
+
+ u32 dummy1;
+ u32 dummy2;
+ u32 dummy3;
+};
+
+struct ncp_objectname_ioctl_32
+{
+ s32 auth_type;
+ u32 object_name_len;
+ compat_caddr_t object_name; /* an userspace data, in most cases user name */
+};
+
+struct ncp_privatedata_ioctl_32
+{
+ u32 len;
+ compat_caddr_t data; /* ~1000 for NDS */
+};
+
+#define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
+#define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
+#define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
+#define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
+#define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
+#define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
+#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
+
+static int do_ncp_ncprequest(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct ncp_ioctl_request_32 n32;
+ struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
+
+ if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
+ put_user(n32.function, &p->function) ||
+ put_user(n32.size, &p->size) ||
+ put_user(compat_ptr(n32.data), &p->data))
+ return -EFAULT;
+
+ return ncp_ioctl(inode, file, NCP_IOC_NCPREQUEST, (unsigned long)p);
+}
+
+static int do_ncp_getmountuid2(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ mm_segment_t old_fs = get_fs();
+ __kernel_uid_t kuid;
+ int err;
+
+ cmd = NCP_IOC_GETMOUNTUID2;
+
+ set_fs(KERNEL_DS);
+ err = ncp_ioctl(inode, file, cmd, (unsigned long)&kuid);
+ set_fs(old_fs);
+
+ if (!err)
+ err = put_user(kuid,
+ (unsigned int __user *) compat_ptr(arg));
+
+ return err;
+}
+
+static int do_ncp_getfsinfo2(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ mm_segment_t old_fs = get_fs();
+ struct ncp_fs_info_v2_32 n32;
+ struct ncp_fs_info_v2 n;
+ int err;
+
+ if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
+ return -EFAULT;
+ if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
+ return -EINVAL;
+ n.version = NCP_GET_FS_INFO_VERSION_V2;
+
+ set_fs(KERNEL_DS);
+ err = ncp_ioctl(inode, file, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
+ set_fs(old_fs);
+
+ if (!err) {
+ n32.version = n.version;
+ n32.mounted_uid = n.mounted_uid;
+ n32.connection = n.connection;
+ n32.buffer_size = n.buffer_size;
+ n32.volume_number = n.volume_number;
+ n32.directory_id = n.directory_id;
+ n32.dummy1 = n.dummy1;
+ n32.dummy2 = n.dummy2;
+ n32.dummy3 = n.dummy3;
+ err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
+ }
+ return err;
+}
+
+static int do_ncp_getobjectname(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
+ struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
+ s32 auth_type;
+ u32 name_len;
+ int err;
+
+ if (copy_from_user(&n32, p32, sizeof(n32)) ||
+ put_user(n32.object_name_len, &p->object_name_len) ||
+ put_user(compat_ptr(n32.object_name), &p->object_name))
+ return -EFAULT;
+
+ err = ncp_ioctl(inode, file, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
+ if (err)
+ return err;
+
+ if (get_user(auth_type, &p->auth_type) ||
+ put_user(auth_type, &p32->auth_type) ||
+ get_user(name_len, &p->object_name_len) ||
+ put_user(name_len, &p32->object_name_len))
+ return -EFAULT;
+
+ return 0;
+}
+
+static int do_ncp_setobjectname(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
+ struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
+
+ if (copy_from_user(&n32, p32, sizeof(n32)) ||
+ put_user(n32.auth_type, &p->auth_type) ||
+ put_user(n32.object_name_len, &p->object_name_len) ||
+ put_user(compat_ptr(n32.object_name), &p->object_name))
+ return -EFAULT;
+
+ return ncp_ioctl(inode, file, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
+}
+
+static int do_ncp_getprivatedata(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
+ struct ncp_privatedata_ioctl __user *p =
+ compat_alloc_user_space(sizeof(*p));
+ u32 len;
+ int err;
+
+ if (copy_from_user(&n32, p32, sizeof(n32)) ||
+ put_user(n32.len, &p->len) ||
+ put_user(compat_ptr(n32.data), &p->data))
+ return -EFAULT;
+
+ err = ncp_ioctl(inode, file, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
+ if (err)
+ return err;
+
+ if (get_user(len, &p->len) ||
+ put_user(len, &p32->len))
+ return -EFAULT;
+
+ return 0;
+}
+
+static int do_ncp_setprivatedata(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct ncp_privatedata_ioctl_32 n32;
+ struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
+ struct ncp_privatedata_ioctl __user *p =
+ compat_alloc_user_space(sizeof(*p));
+
+ if (copy_from_user(&n32, p32, sizeof(n32)) ||
+ put_user(n32.len, &p->len) ||
+ put_user(compat_ptr(n32.data), &p->data))
+ return -EFAULT;
+
+ return ncp_ioctl(inode, file, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
+}
+
+long ncp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct inode *inode = file->f_dentry->d_inode;
+ int ret;
+
+ ret = -ENOIOCTLCMD;
+ lock_kernel();
+ switch (cmd) {
+ case NCP_IOC_NCPREQUEST_32:
+ ret = do_ncp_ncprequest(inode, file, cmd, arg);
+ break;
+ case NCP_IOC_GETMOUNTUID2_32:
+ ret = do_ncp_getmountuid2(inode, file, cmd, arg);
+ break;
+ case NCP_IOC_GET_FS_INFO_V2_32:
+ ret = do_ncp_getfsinfo2(inode, file, cmd, arg);
+ break;
+ case NCP_IOC_GETOBJECTNAME_32:
+ ret = do_ncp_getobjectname(inode, file, cmd, arg);
+ break;
+ case NCP_IOC_SETOBJECTNAME_32:
+ ret = do_ncp_setobjectname(inode, file, cmd, arg);
+ break;
+ case NCP_IOC_GETPRIVATEDATA_32:
+ ret = do_ncp_getprivatedata(inode, file, cmd, arg);
+ break;
+ case NCP_IOC_SETPRIVATEDATA_32:
+ ret = do_ncp_setprivatedata(inode, file, cmd, arg);
+ break;
+ /* NCP ioctls which do not need any translations */
+ case NCP_IOC_CONN_LOGGED_IN:
+ case NCP_IOC_SIGN_INIT:
+ case NCP_IOC_SIGN_WANTED:
+ case NCP_IOC_SET_SIGN_WANTED:
+ case NCP_IOC_LOCKUNLOCK:
+ case NCP_IOC_GETROOT:
+ case NCP_IOC_SETROOT:
+ case NCP_IOC_GETCHARSETS:
+ case NCP_IOC_SETCHARSETS:
+ case NCP_IOC_GETDENTRYTTL:
+ case NCP_IOC_SETDENTRYTTL:
+ arg = (unsigned long) compat_ptr(arg);
+ ret = ncp_ioctl(inode, file, cmd, arg);
+ break;
+ }
+ unlock_kernel();
+ return ret;
+}
+#endif
Index: linux-cg/include/linux/compat_ioctl.h
===================================================================
--- linux-cg.orig/include/linux/compat_ioctl.h 2005-11-05 14:22:34.000000000 +0100
+++ linux-cg/include/linux/compat_ioctl.h 2005-11-05 15:47:28.000000000 +0100
@@ -368,18 +368,6 @@
/* Raw devices */
COMPATIBLE_IOCTL(RAW_SETBIND)
COMPATIBLE_IOCTL(RAW_GETBIND)
-/* NCP ioctls which do not need any translations */
-COMPATIBLE_IOCTL(NCP_IOC_CONN_LOGGED_IN)
-COMPATIBLE_IOCTL(NCP_IOC_SIGN_INIT)
-COMPATIBLE_IOCTL(NCP_IOC_SIGN_WANTED)
-COMPATIBLE_IOCTL(NCP_IOC_SET_SIGN_WANTED)
-COMPATIBLE_IOCTL(NCP_IOC_LOCKUNLOCK)
-COMPATIBLE_IOCTL(NCP_IOC_GETROOT)
-COMPATIBLE_IOCTL(NCP_IOC_SETROOT)
-COMPATIBLE_IOCTL(NCP_IOC_GETCHARSETS)
-COMPATIBLE_IOCTL(NCP_IOC_SETCHARSETS)
-COMPATIBLE_IOCTL(NCP_IOC_GETDENTRYTTL)
-COMPATIBLE_IOCTL(NCP_IOC_SETDENTRYTTL)
/* Little a */
COMPATIBLE_IOCTL(ATMSIGD_CTRL)
COMPATIBLE_IOCTL(ATMARPD_CTRL)
Index: linux-cg/include/linux/ncp_fs.h
===================================================================
--- linux-cg.orig/include/linux/ncp_fs.h 2005-11-05 14:19:13.000000000 +0100
+++ linux-cg/include/linux/ncp_fs.h 2005-11-05 14:22:34.000000000 +0100
@@ -244,6 +244,7 @@
/* linux/fs/ncpfs/ioctl.c */
int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
+long ncp_compat_ioctl(struct file *, unsigned int, unsigned long);
/* linux/fs/ncpfs/sock.c */
int ncp_request2(struct ncp_server *server, int function,
^ permalink raw reply [flat|nested] 11+ messages in thread
* reference: smbfs: simplify compat_ioctl handling
2006-07-27 1:03 ` Arnd Bergmann
2006-07-27 1:08 ` reference: ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c Arnd Bergmann
@ 2006-07-27 1:09 ` Arnd Bergmann
2006-07-27 2:56 ` [PATCH] ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c Arnd Bergmann
2006-07-27 6:06 ` [patch/rfc] s390: get rid of own uid16 compat system calls Heiko Carstens
2 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2006-07-27 1:09 UTC (permalink / raw)
To: Heiko Carstens; +Cc: linux-kernel, Martin Schwidefsky
On Thursday 27 July 2006 03:03, Arnd Bergmann wrote:
> I'm also posting the two patches I made a long time ago as a reference.
>
This one is a how the ncpfs patch is supposed to work as well.
still needs the UID16/32/64 stuff, I guess....
Arnd <><
Subject: smbfs: simplify compat_ioctl handling
smbfs already handles SMB_IOC_GETMOUNTUID with both 16
and 32 bit arguments, so the compatibility wrapper is
not needed any more. The only other ioctl used in smbfs
is SMB_IOC_NEWCONN, which is compatible as well.
This simply introduces a new compat_ioctl function that
calls the regular smb_ioctl function.
CC: urban@teststation.com
CC: samba@samba.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-2.6.14-rc/fs/compat_ioctl.c
===================================================================
--- linux-2.6.14-rc.orig/fs/compat_ioctl.c 2005-11-05 02:41:39.000000000 +0100
+++ linux-2.6.14-rc/fs/compat_ioctl.c 2005-11-05 02:41:40.000000000 +0100
@@ -331,24 +331,6 @@
return err;
}
-static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- mm_segment_t old_fs = get_fs();
- __kernel_uid_t kuid;
- int err;
-
- cmd = SMB_IOC_GETMOUNTUID;
-
- set_fs(KERNEL_DS);
- err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
- set_fs(old_fs);
-
- if (err >= 0)
- err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg));
-
- return err;
-}
-
static __attribute_used__ int
ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg)
{
@@ -938,9 +920,6 @@
HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans)
#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
-/* One SMB ioctl needs translations. */
-#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
-HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)
/* vfat */
HANDLE_IOCTL(VFAT_IOCTL_READDIR_BOTH32, vfat_ioctl32)
HANDLE_IOCTL(VFAT_IOCTL_READDIR_SHORT32, vfat_ioctl32)
Index: linux-2.6.14-rc/fs/smbfs/ioctl.c
===================================================================
--- linux-2.6.14-rc.orig/fs/smbfs/ioctl.c 2005-11-05 02:38:13.000000000 +0100
+++ linux-2.6.14-rc/fs/smbfs/ioctl.c 2005-11-05 02:41:40.000000000 +0100
@@ -7,6 +7,8 @@
* Please add a note about your changes to smbfs in the ChangeLog file.
*/
+#include <linux/config.h>
+#include <linux/compat.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/ioctl.h>
@@ -65,3 +67,17 @@
return result;
}
+
+#ifdef CONFIG_COMPAT
+/* All three ioctl numbers above are compatible */
+long
+smb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ int result;
+ lock_kernel();
+ arg = (unsigned long) compat_ptr(arg);
+ result = smb_ioctl(file->f_dentry->d_inode, file, cmd, arg);
+ unlock_kernel();
+ return result;
+}
+#endif
Index: linux-2.6.14-rc/include/linux/compat_ioctl.h
===================================================================
--- linux-2.6.14-rc.orig/include/linux/compat_ioctl.h 2005-11-05 02:41:39.000000000 +0100
+++ linux-2.6.14-rc/include/linux/compat_ioctl.h 2005-11-05 02:41:40.000000000 +0100
@@ -379,8 +379,6 @@
/* Raw devices */
COMPATIBLE_IOCTL(RAW_SETBIND)
COMPATIBLE_IOCTL(RAW_GETBIND)
-/* SMB ioctls which do not need any translations */
-COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
/* NCP ioctls which do not need any translations */
COMPATIBLE_IOCTL(NCP_IOC_CONN_LOGGED_IN)
COMPATIBLE_IOCTL(NCP_IOC_SIGN_INIT)
Index: linux-2.6.14-rc/fs/smbfs/file.c
===================================================================
--- linux-2.6.14-rc.orig/fs/smbfs/file.c 2005-11-05 02:38:13.000000000 +0100
+++ linux-2.6.14-rc/fs/smbfs/file.c 2005-11-05 02:41:40.000000000 +0100
@@ -7,6 +7,7 @@
* Please add a note about your changes to smbfs in the ChangeLog file.
*/
+#include <linux/config.h>
#include <linux/time.h>
#include <linux/kernel.h>
#include <linux/errno.h>
@@ -408,6 +409,9 @@
.read = smb_file_read,
.write = smb_file_write,
.ioctl = smb_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = smb_compat_ioctl,
+#endif
.mmap = smb_file_mmap,
.open = smb_file_open,
.release = smb_file_release,
Index: linux-2.6.14-rc/fs/smbfs/proto.h
===================================================================
--- linux-2.6.14-rc.orig/fs/smbfs/proto.h 2005-11-05 02:38:13.000000000 +0100
+++ linux-2.6.14-rc/fs/smbfs/proto.h 2005-11-05 02:41:40.000000000 +0100
@@ -68,6 +68,7 @@
extern struct inode_operations smb_file_inode_operations;
/* ioctl.c */
extern int smb_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
+extern long smb_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
/* smbiod.c */
extern void smbiod_wake_up(void);
extern int smbiod_register_server(struct smb_sb_info *server);
Index: linux-2.6.14-rc/fs/smbfs/dir.c
===================================================================
--- linux-2.6.14-rc.orig/fs/smbfs/dir.c 2005-11-05 02:38:13.000000000 +0100
+++ linux-2.6.14-rc/fs/smbfs/dir.c 2005-11-05 02:41:40.000000000 +0100
@@ -7,6 +7,7 @@
* Please add a note about your changes to smbfs in the ChangeLog file.
*/
+#include <linux/config.h>
#include <linux/time.h>
#include <linux/errno.h>
#include <linux/kernel.h>
@@ -39,6 +40,9 @@
.read = generic_read_dir,
.readdir = smb_readdir,
.ioctl = smb_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = smb_compat_ioctl,
+#endif
.open = smb_dir_open,
};
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: reference: ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c
2006-07-27 1:08 ` reference: ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c Arnd Bergmann
@ 2006-07-27 2:53 ` Arnd Bergmann
0 siblings, 0 replies; 11+ messages in thread
From: Arnd Bergmann @ 2006-07-27 2:53 UTC (permalink / raw)
To: Heiko Carstens, vandrove, linware; +Cc: linux-kernel, Martin Schwidefsky
On Thursday 27 July 2006 03:08, Arnd Bergmann wrote:
> Ok, I just realized that this was not using a merged
> ->compat_ioctl/->unlocked_ioctl function yet, but wth, here
> it is anyway.
>
Oh well, couldn't resist doing the complete patch now...
Petr, you can find the thread at http://lkml.org/lkml/2006/7/10/49
Arnd <><
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c
2006-07-27 1:09 ` reference: smbfs: simplify compat_ioctl handling Arnd Bergmann
@ 2006-07-27 2:56 ` Arnd Bergmann
2006-07-27 3:35 ` Petr Vandrovec
0 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2006-07-27 2:56 UTC (permalink / raw)
To: Heiko Carstens, vandrove, linware; +Cc: linux-kernel, Martin Schwidefsky
The ncp specific compat ioctls are clearly local to one
file system, so the code can better live there.
This version of the patch moves everything into the
generic ioctl handler and uses it for both 32 and 64
bit calls.
Petr, can you test this patch on a 64 bit system?
CC: vandrove@vc.cvut.cz
CC: linware@sh.cvut.cz
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/fs/compat_ioctl.c
===================================================================
--- linux-cg.orig/fs/compat_ioctl.c 2006-07-15 03:45:21.000000000 +0200
+++ linux-cg/fs/compat_ioctl.c 2006-07-27 03:12:25.000000000 +0200
@@ -2507,193 +2507,6 @@
}
}
-#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
-struct ncp_ioctl_request_32 {
- u32 function;
- u32 size;
- compat_caddr_t data;
-};
-
-struct ncp_fs_info_v2_32 {
- s32 version;
- u32 mounted_uid;
- u32 connection;
- u32 buffer_size;
-
- u32 volume_number;
- u32 directory_id;
-
- u32 dummy1;
- u32 dummy2;
- u32 dummy3;
-};
-
-struct ncp_objectname_ioctl_32
-{
- s32 auth_type;
- u32 object_name_len;
- compat_caddr_t object_name; /* an userspace data, in most cases user name */
-};
-
-struct ncp_privatedata_ioctl_32
-{
- u32 len;
- compat_caddr_t data; /* ~1000 for NDS */
-};
-
-#define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
-#define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
-#define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
-#define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
-#define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
-#define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
-#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
-
-static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_ioctl_request_32 n32;
- struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
-
- if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
- put_user(n32.function, &p->function) ||
- put_user(n32.size, &p->size) ||
- put_user(compat_ptr(n32.data), &p->data))
- return -EFAULT;
-
- return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p);
-}
-
-static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- mm_segment_t old_fs = get_fs();
- __kernel_uid_t kuid;
- int err;
-
- cmd = NCP_IOC_GETMOUNTUID2;
-
- set_fs(KERNEL_DS);
- err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
- set_fs(old_fs);
-
- if (!err)
- err = put_user(kuid,
- (unsigned int __user *) compat_ptr(arg));
-
- return err;
-}
-
-static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- mm_segment_t old_fs = get_fs();
- struct ncp_fs_info_v2_32 n32;
- struct ncp_fs_info_v2 n;
- int err;
-
- if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
- return -EFAULT;
- if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
- return -EINVAL;
- n.version = NCP_GET_FS_INFO_VERSION_V2;
-
- set_fs(KERNEL_DS);
- err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
- set_fs(old_fs);
-
- if (!err) {
- n32.version = n.version;
- n32.mounted_uid = n.mounted_uid;
- n32.connection = n.connection;
- n32.buffer_size = n.buffer_size;
- n32.volume_number = n.volume_number;
- n32.directory_id = n.directory_id;
- n32.dummy1 = n.dummy1;
- n32.dummy2 = n.dummy2;
- n32.dummy3 = n.dummy3;
- err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
- }
- return err;
-}
-
-static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
- struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
- s32 auth_type;
- u32 name_len;
- int err;
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.object_name_len, &p->object_name_len) ||
- put_user(compat_ptr(n32.object_name), &p->object_name))
- return -EFAULT;
-
- err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
- if (err)
- return err;
-
- if (get_user(auth_type, &p->auth_type) ||
- put_user(auth_type, &p32->auth_type) ||
- get_user(name_len, &p->object_name_len) ||
- put_user(name_len, &p32->object_name_len))
- return -EFAULT;
-
- return 0;
-}
-
-static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
- struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.auth_type, &p->auth_type) ||
- put_user(n32.object_name_len, &p->object_name_len) ||
- put_user(compat_ptr(n32.object_name), &p->object_name))
- return -EFAULT;
-
- return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
-}
-
-static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
- struct ncp_privatedata_ioctl __user *p =
- compat_alloc_user_space(sizeof(*p));
- u32 len;
- int err;
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.len, &p->len) ||
- put_user(compat_ptr(n32.data), &p->data))
- return -EFAULT;
-
- err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
- if (err)
- return err;
-
- if (get_user(len, &p->len) ||
- put_user(len, &p32->len))
- return -EFAULT;
-
- return 0;
-}
-
-static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_privatedata_ioctl_32 n32;
- struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
- struct ncp_privatedata_ioctl __user *p =
- compat_alloc_user_space(sizeof(*p));
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.len, &p->len) ||
- put_user(compat_ptr(n32.data), &p->data))
- return -EFAULT;
-
- return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
-}
-#endif
-
static int
lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
{
@@ -2920,16 +2733,6 @@
HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
-#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
-HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
-HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
-HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
-HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
-HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
-HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
-HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
-#endif
-
/* dvb */
HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
Index: linux-cg/fs/ncpfs/dir.c
===================================================================
--- linux-cg.orig/fs/ncpfs/dir.c 2006-07-15 03:45:21.000000000 +0200
+++ linux-cg/fs/ncpfs/dir.c 2006-07-27 03:10:46.000000000 +0200
@@ -53,6 +53,9 @@
.read = generic_read_dir,
.readdir = ncp_readdir,
.ioctl = ncp_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = ncp_compat_ioctl,
+#endif
};
struct inode_operations ncp_dir_inode_operations =
Index: linux-cg/fs/ncpfs/file.c
===================================================================
--- linux-cg.orig/fs/ncpfs/file.c 2006-04-02 23:17:08.000000000 +0200
+++ linux-cg/fs/ncpfs/file.c 2006-07-27 03:10:46.000000000 +0200
@@ -9,6 +9,7 @@
#include <asm/uaccess.h>
#include <asm/system.h>
+#include <linux/config.h>
#include <linux/time.h>
#include <linux/kernel.h>
#include <linux/errno.h>
@@ -289,6 +290,9 @@
.read = ncp_file_read,
.write = ncp_file_write,
.ioctl = ncp_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = ncp_compat_ioctl,
+#endif
.mmap = ncp_mmap,
.release = ncp_release,
.fsync = ncp_fsync,
Index: linux-cg/fs/ncpfs/ioctl.c
===================================================================
--- linux-cg.orig/fs/ncpfs/ioctl.c 2006-07-15 03:45:21.000000000 +0200
+++ linux-cg/fs/ncpfs/ioctl.c 2006-07-27 04:38:18.000000000 +0200
@@ -7,19 +7,21 @@
*
*/
-
-#include <asm/uaccess.h>
#include <linux/capability.h>
+#include <linux/compat.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/ioctl.h>
#include <linux/time.h>
#include <linux/mm.h>
#include <linux/highuid.h>
+#include <linux/smp_lock.h>
#include <linux/vmalloc.h>
#include <linux/ncp_fs.h>
+#include <asm/uaccess.h>
+
#include "ncplib_kernel.h"
/* maximum limit for ncp_objectname_ioctl */
@@ -89,6 +91,82 @@
return 0;
}
+#ifdef CONFIG_COMPAT
+struct compat_ncp_objectname_ioctl
+{
+ s32 auth_type;
+ u32 object_name_len;
+ compat_caddr_t object_name; /* an userspace data, in most cases user name */
+};
+
+struct compat_ncp_fs_info_v2 {
+ s32 version;
+ u32 mounted_uid;
+ u32 connection;
+ u32 buffer_size;
+
+ u32 volume_number;
+ u32 directory_id;
+
+ u32 dummy1;
+ u32 dummy2;
+ u32 dummy3;
+};
+
+struct compat_ncp_ioctl_request {
+ u32 function;
+ u32 size;
+ compat_caddr_t data;
+};
+
+struct compat_ncp_privatedata_ioctl
+{
+ u32 len;
+ compat_caddr_t data; /* ~1000 for NDS */
+};
+
+#define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct compat_ncp_fs_info_v2)
+#define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct compat_ncp_ioctl_request)
+#define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct compat_ncp_objectname_ioctl)
+#define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct compat_ncp_objectname_ioctl)
+#define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct compat_ncp_privatedata_ioctl)
+#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl)
+
+static int
+ncp_get_compat_fs_info_v2(struct ncp_server * server, struct file *file,
+ struct compat_ncp_fs_info_v2 __user * arg)
+{
+ struct inode *inode = file->f_dentry->d_inode;
+ struct compat_ncp_fs_info_v2 info2;
+
+ if ((file_permission(file, MAY_WRITE) != 0)
+ && (current->uid != server->m.mounted_uid)) {
+ return -EACCES;
+ }
+ if (copy_from_user(&info2, arg, sizeof(info2)))
+ return -EFAULT;
+
+ if (info2.version != NCP_GET_FS_INFO_VERSION_V2) {
+ DPRINTK("info.version invalid: %d\n", info2.version);
+ return -EINVAL;
+ }
+ info2.mounted_uid = server->m.mounted_uid;
+ info2.connection = server->connection;
+ info2.buffer_size = server->buffer_size;
+ info2.volume_number = NCP_FINFO(inode)->volNumber;
+ info2.directory_id = NCP_FINFO(inode)->DosDirNum;
+ info2.dummy1 = info2.dummy2 = info2.dummy3 = 0;
+
+ if (copy_to_user(arg, &info2, sizeof(info2)))
+ return -EFAULT;
+ return 0;
+}
+#endif
+
+#define NCP_IOC_GETMOUNTUID16 _IOW('n', 2, u16)
+#define NCP_IOC_GETMOUNTUID32 _IOW('n', 2, u32)
+#define NCP_IOC_GETMOUNTUID64 _IOW('n', 2, u64)
+
#ifdef CONFIG_NCPFS_NLS
/* Here we are select the iocharset and the codepage for NLS.
* Thanks Petr Vandrovec for idea and many hints.
@@ -192,14 +270,27 @@
void __user *argp = (void __user *)arg;
switch (cmd) {
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_NCPREQUEST_32:
+#endif
case NCP_IOC_NCPREQUEST:
-
if ((file_permission(filp, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid)) {
return -EACCES;
}
- if (copy_from_user(&request, argp, sizeof(request)))
- return -EFAULT;
+ if (cmd == NCP_IOC_NCPREQUEST) {
+ if (copy_from_user(&request, argp, sizeof(request)))
+ return -EFAULT;
+ } else {
+#ifdef CONFIG_COMPAT
+ struct compat_ncp_ioctl_request request32;
+ if (copy_from_user(&request32, argp, sizeof(request32)))
+ return -EFAULT;
+ request.function = request32.function;
+ request.size = request32.size;
+ request.data = compat_ptr(request32.data);
+#endif
+ }
if ((request.function > 255)
|| (request.size >
@@ -254,19 +345,35 @@
case NCP_IOC_GET_FS_INFO_V2:
return ncp_get_fs_info_v2(server, filp, argp);
- case NCP_IOC_GETMOUNTUID2:
- {
- unsigned long tmp = server->m.mounted_uid;
-
- if ((file_permission(filp, MAY_READ) != 0)
- && (current->uid != server->m.mounted_uid))
- {
- return -EACCES;
- }
- if (put_user(tmp, (unsigned long __user *)argp))
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_GET_FS_INFO_V2_32:
+ return ncp_get_compat_fs_info_v2(server, filp, argp);
+#endif
+ /* we have too many combinations of CONFIG_COMPAT,
+ * CONFIG_64BIT and CONFIG_UID16, so just handle
+ * any of the possible ioctls */
+ case NCP_IOC_GETMOUNTUID16:
+ case NCP_IOC_GETMOUNTUID32:
+ case NCP_IOC_GETMOUNTUID64:
+ if ((file_permission(filp, MAY_READ) != 0)
+ && (current->uid != server->m.mounted_uid)) {
+ return -EACCES;
+ }
+ if (cmd == NCP_IOC_GETMOUNTUID16) {
+ u16 uid;
+ SET_UID(uid, server->m.mounted_uid);
+ if (put_user(uid, (u16 __user *)argp))
+ return -EFAULT;
+ } else if (cmd == NCP_IOC_GETMOUNTUID32) {
+ if (put_user(server->m.mounted_uid,
+ (u32 __user *)argp))
+ return -EFAULT;
+ } else {
+ if (put_user(server->m.mounted_uid,
+ (u64 __user *)argp))
return -EFAULT;
- return 0;
}
+ return 0;
case NCP_IOC_GETROOT:
{
@@ -476,6 +583,32 @@
}
#endif /* CONFIG_NCPFS_IOCTL_LOCKING */
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_GETOBJECTNAME_32:
+ if (current->uid != server->m.mounted_uid) {
+ return -EACCES;
+ }
+ {
+ struct compat_ncp_objectname_ioctl user;
+ size_t outl;
+
+ if (copy_from_user(&user, argp, sizeof(user)))
+ return -EFAULT;
+ user.auth_type = server->auth.auth_type;
+ outl = user.object_name_len;
+ user.object_name_len = server->auth.object_name_len;
+ if (outl > user.object_name_len)
+ outl = user.object_name_len;
+ if (outl) {
+ if (copy_to_user(compat_ptr(user.object_name),
+ server->auth.object_name,
+ outl)) return -EFAULT;
+ }
+ if (copy_to_user(argp, &user, sizeof(user)))
+ return -EFAULT;
+ return 0;
+ }
+#endif
case NCP_IOC_GETOBJECTNAME:
if (current->uid != server->m.mounted_uid) {
return -EACCES;
@@ -500,6 +633,9 @@
return -EFAULT;
return 0;
}
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_SETOBJECTNAME_32:
+#endif
case NCP_IOC_SETOBJECTNAME:
if (current->uid != server->m.mounted_uid) {
return -EACCES;
@@ -512,8 +648,19 @@
void* oldprivate;
size_t oldprivatelen;
- if (copy_from_user(&user, argp, sizeof(user)))
- return -EFAULT;
+ if (cmd == NCP_IOC_SETOBJECTNAME) {
+ if (copy_from_user(&user, argp, sizeof(user)))
+ return -EFAULT;
+ } else {
+#ifdef CONFIG_COMPAT
+ struct compat_ncp_objectname_ioctl user32;
+ if (copy_from_user(&user32, argp, sizeof(user32)))
+ return -EFAULT;
+ user.auth_type = user32.auth_type;
+ user.object_name_len = user32.object_name_len;
+ user.object_name = compat_ptr(user32.object_name);
+#endif
+ }
if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
return -ENOMEM;
if (user.object_name_len) {
@@ -544,6 +691,9 @@
kfree(oldname);
return 0;
}
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_GETPRIVATEDATA_32:
+#endif
case NCP_IOC_GETPRIVATEDATA:
if (current->uid != server->m.mounted_uid) {
return -EACCES;
@@ -552,8 +702,18 @@
struct ncp_privatedata_ioctl user;
size_t outl;
- if (copy_from_user(&user, argp, sizeof(user)))
- return -EFAULT;
+ if (cmd == NCP_IOC_GETPRIVATEDATA) {
+ if (copy_from_user(&user, argp, sizeof(user)))
+ return -EFAULT;
+ } else {
+#ifdef CONFIG_COMPAT
+ struct compat_ncp_privatedata_ioctl user32;
+ if (copy_from_user(&user32, argp, sizeof(user32)))
+ return -EFAULT;
+ user.len = user32.len;
+ user.data = compat_ptr(user32.data);
+#endif
+ }
outl = user.len;
user.len = server->priv.len;
if (outl > user.len) outl = user.len;
@@ -562,10 +722,23 @@
server->priv.data,
outl)) return -EFAULT;
}
- if (copy_to_user(argp, &user, sizeof(user)))
- return -EFAULT;
+ if (cmd == NCP_IOC_GETPRIVATEDATA) {
+ if (copy_to_user(argp, &user, sizeof(user)))
+ return -EFAULT;
+ } else {
+#ifdef CONFIG_COMPAT
+ struct compat_ncp_privatedata_ioctl user32;
+ user32.len = user.len;
+ user32.data = (unsigned long) user.data;
+ if (copy_to_user(&user32, argp, sizeof(user32)))
+ return -EFAULT;
+#endif
+ }
return 0;
}
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_SETPRIVATEDATA_32:
+#endif
case NCP_IOC_SETPRIVATEDATA:
if (current->uid != server->m.mounted_uid) {
return -EACCES;
@@ -576,8 +749,18 @@
void* old;
size_t oldlen;
- if (copy_from_user(&user, argp, sizeof(user)))
- return -EFAULT;
+ if (cmd == NCP_IOC_SETPRIVATEDATA) {
+ if (copy_from_user(&user, argp, sizeof(user)))
+ return -EFAULT;
+ } else {
+#ifdef CONFIG_COMPAT
+ struct compat_ncp_privatedata_ioctl user32;
+ if (copy_from_user(&user32, argp, sizeof(user32)))
+ return -EFAULT;
+ user.len = user32.len;
+ user.data = compat_ptr(user32.data);
+#endif
+ }
if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
return -ENOMEM;
if (user.len) {
@@ -636,20 +819,19 @@
}
}
-/* #ifdef CONFIG_UID16 */
- /* NCP_IOC_GETMOUNTUID may be same as NCP_IOC_GETMOUNTUID2,
- so we have this out of switch */
- if (cmd == NCP_IOC_GETMOUNTUID) {
- __kernel_uid_t uid = 0;
- if ((file_permission(filp, MAY_READ) != 0)
- && (current->uid != server->m.mounted_uid)) {
- return -EACCES;
- }
- SET_UID(uid, server->m.mounted_uid);
- if (put_user(uid, (__kernel_uid_t __user *)argp))
- return -EFAULT;
- return 0;
- }
-/* #endif */
return -EINVAL;
}
+
+#ifdef CONFIG_COMPAT
+long ncp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct inode *inode = file->f_dentry->d_inode;
+ int ret;
+
+ lock_kernel();
+ arg = (unsigned long) compat_ptr(arg);
+ ret = ncp_ioctl(inode, file, cmd, arg);
+ unlock_kernel();
+ return ret;
+}
+#endif
Index: linux-cg/include/linux/ncp_fs.h
===================================================================
--- linux-cg.orig/include/linux/ncp_fs.h 2006-06-21 01:19:20.000000000 +0200
+++ linux-cg/include/linux/ncp_fs.h 2006-07-27 03:10:46.000000000 +0200
@@ -215,6 +215,7 @@
/* linux/fs/ncpfs/ioctl.c */
int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
+long ncp_compat_ioctl(struct file *, unsigned int, unsigned long);
/* linux/fs/ncpfs/sock.c */
int ncp_request2(struct ncp_server *server, int function,
Index: linux-cg/include/linux/compat_ioctl.h
===================================================================
--- linux-cg.orig/include/linux/compat_ioctl.h 2006-07-15 03:45:22.000000000 +0200
+++ linux-cg/include/linux/compat_ioctl.h 2006-07-27 03:15:19.000000000 +0200
@@ -572,18 +572,6 @@
COMPATIBLE_IOCTL(RAW_GETBIND)
/* SMB ioctls which do not need any translations */
COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
-/* NCP ioctls which do not need any translations */
-COMPATIBLE_IOCTL(NCP_IOC_CONN_LOGGED_IN)
-COMPATIBLE_IOCTL(NCP_IOC_SIGN_INIT)
-COMPATIBLE_IOCTL(NCP_IOC_SIGN_WANTED)
-COMPATIBLE_IOCTL(NCP_IOC_SET_SIGN_WANTED)
-COMPATIBLE_IOCTL(NCP_IOC_LOCKUNLOCK)
-COMPATIBLE_IOCTL(NCP_IOC_GETROOT)
-COMPATIBLE_IOCTL(NCP_IOC_SETROOT)
-COMPATIBLE_IOCTL(NCP_IOC_GETCHARSETS)
-COMPATIBLE_IOCTL(NCP_IOC_SETCHARSETS)
-COMPATIBLE_IOCTL(NCP_IOC_GETDENTRYTTL)
-COMPATIBLE_IOCTL(NCP_IOC_SETDENTRYTTL)
/* Little a */
COMPATIBLE_IOCTL(ATMSIGD_CTRL)
COMPATIBLE_IOCTL(ATMARPD_CTRL)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c
2006-07-27 2:56 ` [PATCH] ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c Arnd Bergmann
@ 2006-07-27 3:35 ` Petr Vandrovec
2006-07-27 5:45 ` Arnd Bergmann
0 siblings, 1 reply; 11+ messages in thread
From: Petr Vandrovec @ 2006-07-27 3:35 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Heiko Carstens, linux-kernel, Martin Schwidefsky
[removed linware@sh.cvut.cz - I believe it is dead...]
Arnd Bergmann wrote:
> The ncp specific compat ioctls are clearly local to one
> file system, so the code can better live there.
>
> This version of the patch moves everything into the
> generic ioctl handler and uses it for both 32 and 64
> bit calls.
>
> Petr, can you test this patch on a 64 bit system?
Yes, tomorrow (on amd64).
> @@ -544,6 +691,9 @@
> kfree(oldname);
> return 0;
> }
> +#ifdef CONFIG_COMPAT
> + case NCP_IOC_GETPRIVATEDATA_32:
> +#endif
> case NCP_IOC_GETPRIVATEDATA:
> if (current->uid != server->m.mounted_uid) {
> return -EACCES;
...
> @@ -562,10 +722,23 @@
> server->priv.data,
> outl)) return -EFAULT;
> }
> - if (copy_to_user(argp, &user, sizeof(user)))
> - return -EFAULT;
> + if (cmd == NCP_IOC_GETPRIVATEDATA) {
> + if (copy_to_user(argp, &user, sizeof(user)))
> + return -EFAULT;
> + } else {
> +#ifdef CONFIG_COMPAT
> + struct compat_ncp_privatedata_ioctl user32;
> + user32.len = user.len;
> + user32.data = (unsigned long) user.data;
> + if (copy_to_user(&user32, argp, sizeof(user32)))
> + return -EFAULT;
> +#endif
> + }
> return 0;
> }
Although I understand that this code is correct, what about removing this second
#ifdef ? gcc should realize it anyway that without CONFIG_COMPAT defined cmd
must be equal to NCP_IOC_GETPRIVATEDATA, and having empty "else" variant is IMHO
just asking for troubles. Or what about
#ifdef CONFIG_COMPAT
if (cmd == NCP_IOC_GETPRIVATEDATA_32) {
struct ...
} else
#endif
if (copy_to_user(argp, &user, sizeof(user)))
return -EFAULT;
Thanks,
Petr
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c
2006-07-27 3:35 ` Petr Vandrovec
@ 2006-07-27 5:45 ` Arnd Bergmann
2006-07-28 2:15 ` Petr Vandrovec
0 siblings, 1 reply; 11+ messages in thread
From: Arnd Bergmann @ 2006-07-27 5:45 UTC (permalink / raw)
To: Petr Vandrovec; +Cc: Heiko Carstens, linux-kernel, Martin Schwidefsky
On Thursday 27 July 2006 05:35, Petr Vandrovec wrote:
> Yes, tomorrow (on amd64).
No need to hurry, I was sitting on my patch for more than a year now ;-)
> Although I understand that this code is correct, what about removing this second
> #ifdef ? gcc should realize it anyway that without CONFIG_COMPAT defined cmd
> must be equal to NCP_IOC_GETPRIVATEDATA, and having empty "else" variant is IMHO
> just asking for troubles.
That was what I did first, but unfortunately we don't define compat_caddr_t when
CONFIG_COMPAT is disabled, so it would reference an invalid data structure.
> Or what about
>
> #ifdef CONFIG_COMPAT
> if (cmd == NCP_IOC_GETPRIVATEDATA_32) {
> struct ...
> } else
> #endif
> if (copy_to_user(argp, &user, sizeof(user)))
> return -EFAULT;
Yes, that should be clearer than my approach.
Arnd <><
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [patch/rfc] s390: get rid of own uid16 compat system calls
2006-07-27 1:03 ` Arnd Bergmann
2006-07-27 1:08 ` reference: ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c Arnd Bergmann
2006-07-27 1:09 ` reference: smbfs: simplify compat_ioctl handling Arnd Bergmann
@ 2006-07-27 6:06 ` Heiko Carstens
2 siblings, 0 replies; 11+ messages in thread
From: Heiko Carstens @ 2006-07-27 6:06 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: linux-kernel, Martin Schwidefsky
On Thu, Jul 27, 2006 at 03:03:42AM +0200, Arnd Bergmann wrote:
> On Monday 10 July 2006 10:51, Heiko Carstens wrote:
> > "Only" thing is that we unfortunately have different sizes for
> > __kernel_old_[uid|gid]_t (16 bit on s390, 32 on s390x). I was tempted to
> > change these just to find out that there are other users as well:
> >
> > include/linux/ncp_fs.h:
> > ?#define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_old_uid_t)
> > include/linux/smb_fs.h:
> > ?#define SMB_IOC_GETMOUNTUID _IOR('u', 1, __kernel_old_uid_t)
> >
> > So, this is no option. Would anybody know of something to get this work?
> > Or is this just a stupid idea?
>
> Ok, I don't know exactly what you're talking about, but I have in the
> past tried to hack that area as well. It's probably a good idea to
> pick up my old patch and work from there, by making these two file systems
> understand all possible ways:
I dropped my initial patch and gave up on this. The idea of using
kernel/uid16.c for compat code seems to be... not very good :)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c
2006-07-27 5:45 ` Arnd Bergmann
@ 2006-07-28 2:15 ` Petr Vandrovec
2006-07-28 3:38 ` Arnd Bergmann
0 siblings, 1 reply; 11+ messages in thread
From: Petr Vandrovec @ 2006-07-28 2:15 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Heiko Carstens, linux-kernel, Martin Schwidefsky
On Thu, Jul 27, 2006 at 07:45:41AM +0200, Arnd Bergmann wrote:
> On Thursday 27 July 2006 05:35, Petr Vandrovec wrote:
> > Yes, tomorrow (on amd64).
>
> No need to hurry, I was sitting on my patch for more than a year now ;-)
Seems to work, both natively 64bit and also through compat layer.
> > Or what about
> >
> > #ifdef CONFIG_COMPAT
> > if (cmd == NCP_IOC_GETPRIVATEDATA_32) {
> > struct ...
> > } else
> > #endif
> > if (copy_to_user(argp, &user, sizeof(user)))
> > return -EFAULT;
>
> Yes, that should be clearer than my approach.
I've updated your diff as outlined above, and I've removed ncp_fs.h include from
compat_ioctl, as it is not needed anymore. I've also removed one
#include <linux/config.h> you introduced...
Thanks,
Petr
>From Arnd Bergmann <arnd@arndb.de>
The ncp specific compat ioctls are clearly local to one
file system, so the code can better live there.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Petr Vandrovec <petr@vandrovec.name>
diff -uprdN -X .exclude vger/fs/compat_ioctl.c linux/fs/compat_ioctl.c
--- linux/fs/compat_ioctl.c 2006-07-26 18:38:16.000000000 +0200
+++ linux/fs/compat_ioctl.c 2006-07-28 03:54:17.000000000 +0200
@@ -65,7 +65,6 @@
#include <linux/ctype.h>
#include <linux/ioctl32.h>
#include <linux/syscalls.h>
-#include <linux/ncp_fs.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
#include <linux/wireless.h>
@@ -2507,193 +2506,6 @@ static int rtc_ioctl(unsigned fd, unsign
}
}
-#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
-struct ncp_ioctl_request_32 {
- u32 function;
- u32 size;
- compat_caddr_t data;
-};
-
-struct ncp_fs_info_v2_32 {
- s32 version;
- u32 mounted_uid;
- u32 connection;
- u32 buffer_size;
-
- u32 volume_number;
- u32 directory_id;
-
- u32 dummy1;
- u32 dummy2;
- u32 dummy3;
-};
-
-struct ncp_objectname_ioctl_32
-{
- s32 auth_type;
- u32 object_name_len;
- compat_caddr_t object_name; /* an userspace data, in most cases user name */
-};
-
-struct ncp_privatedata_ioctl_32
-{
- u32 len;
- compat_caddr_t data; /* ~1000 for NDS */
-};
-
-#define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct ncp_ioctl_request_32)
-#define NCP_IOC_GETMOUNTUID2_32 _IOW('n', 2, u32)
-#define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct ncp_fs_info_v2_32)
-#define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct ncp_objectname_ioctl_32)
-#define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct ncp_objectname_ioctl_32)
-#define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct ncp_privatedata_ioctl_32)
-#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct ncp_privatedata_ioctl_32)
-
-static int do_ncp_ncprequest(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_ioctl_request_32 n32;
- struct ncp_ioctl_request __user *p = compat_alloc_user_space(sizeof(*p));
-
- if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)) ||
- put_user(n32.function, &p->function) ||
- put_user(n32.size, &p->size) ||
- put_user(compat_ptr(n32.data), &p->data))
- return -EFAULT;
-
- return sys_ioctl(fd, NCP_IOC_NCPREQUEST, (unsigned long)p);
-}
-
-static int do_ncp_getmountuid2(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- mm_segment_t old_fs = get_fs();
- __kernel_uid_t kuid;
- int err;
-
- cmd = NCP_IOC_GETMOUNTUID2;
-
- set_fs(KERNEL_DS);
- err = sys_ioctl(fd, cmd, (unsigned long)&kuid);
- set_fs(old_fs);
-
- if (!err)
- err = put_user(kuid,
- (unsigned int __user *) compat_ptr(arg));
-
- return err;
-}
-
-static int do_ncp_getfsinfo2(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- mm_segment_t old_fs = get_fs();
- struct ncp_fs_info_v2_32 n32;
- struct ncp_fs_info_v2 n;
- int err;
-
- if (copy_from_user(&n32, compat_ptr(arg), sizeof(n32)))
- return -EFAULT;
- if (n32.version != NCP_GET_FS_INFO_VERSION_V2)
- return -EINVAL;
- n.version = NCP_GET_FS_INFO_VERSION_V2;
-
- set_fs(KERNEL_DS);
- err = sys_ioctl(fd, NCP_IOC_GET_FS_INFO_V2, (unsigned long)&n);
- set_fs(old_fs);
-
- if (!err) {
- n32.version = n.version;
- n32.mounted_uid = n.mounted_uid;
- n32.connection = n.connection;
- n32.buffer_size = n.buffer_size;
- n32.volume_number = n.volume_number;
- n32.directory_id = n.directory_id;
- n32.dummy1 = n.dummy1;
- n32.dummy2 = n.dummy2;
- n32.dummy3 = n.dummy3;
- err = copy_to_user(compat_ptr(arg), &n32, sizeof(n32)) ? -EFAULT : 0;
- }
- return err;
-}
-
-static int do_ncp_getobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
- struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
- s32 auth_type;
- u32 name_len;
- int err;
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.object_name_len, &p->object_name_len) ||
- put_user(compat_ptr(n32.object_name), &p->object_name))
- return -EFAULT;
-
- err = sys_ioctl(fd, NCP_IOC_GETOBJECTNAME, (unsigned long)p);
- if (err)
- return err;
-
- if (get_user(auth_type, &p->auth_type) ||
- put_user(auth_type, &p32->auth_type) ||
- get_user(name_len, &p->object_name_len) ||
- put_user(name_len, &p32->object_name_len))
- return -EFAULT;
-
- return 0;
-}
-
-static int do_ncp_setobjectname(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_objectname_ioctl_32 n32, __user *p32 = compat_ptr(arg);
- struct ncp_objectname_ioctl __user *p = compat_alloc_user_space(sizeof(*p));
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.auth_type, &p->auth_type) ||
- put_user(n32.object_name_len, &p->object_name_len) ||
- put_user(compat_ptr(n32.object_name), &p->object_name))
- return -EFAULT;
-
- return sys_ioctl(fd, NCP_IOC_SETOBJECTNAME, (unsigned long)p);
-}
-
-static int do_ncp_getprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_privatedata_ioctl_32 n32, __user *p32 = compat_ptr(arg);
- struct ncp_privatedata_ioctl __user *p =
- compat_alloc_user_space(sizeof(*p));
- u32 len;
- int err;
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.len, &p->len) ||
- put_user(compat_ptr(n32.data), &p->data))
- return -EFAULT;
-
- err = sys_ioctl(fd, NCP_IOC_GETPRIVATEDATA, (unsigned long)p);
- if (err)
- return err;
-
- if (get_user(len, &p->len) ||
- put_user(len, &p32->len))
- return -EFAULT;
-
- return 0;
-}
-
-static int do_ncp_setprivatedata(unsigned int fd, unsigned int cmd, unsigned long arg)
-{
- struct ncp_privatedata_ioctl_32 n32;
- struct ncp_privatedata_ioctl_32 __user *p32 = compat_ptr(arg);
- struct ncp_privatedata_ioctl __user *p =
- compat_alloc_user_space(sizeof(*p));
-
- if (copy_from_user(&n32, p32, sizeof(n32)) ||
- put_user(n32.len, &p->len) ||
- put_user(compat_ptr(n32.data), &p->data))
- return -EFAULT;
-
- return sys_ioctl(fd, NCP_IOC_SETPRIVATEDATA, (unsigned long)p);
-}
-#endif
-
static int
lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
{
@@ -2920,16 +2732,6 @@ HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl)
HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl)
HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl)
-#if defined(CONFIG_NCP_FS) || defined(CONFIG_NCP_FS_MODULE)
-HANDLE_IOCTL(NCP_IOC_NCPREQUEST_32, do_ncp_ncprequest)
-HANDLE_IOCTL(NCP_IOC_GETMOUNTUID2_32, do_ncp_getmountuid2)
-HANDLE_IOCTL(NCP_IOC_GET_FS_INFO_V2_32, do_ncp_getfsinfo2)
-HANDLE_IOCTL(NCP_IOC_GETOBJECTNAME_32, do_ncp_getobjectname)
-HANDLE_IOCTL(NCP_IOC_SETOBJECTNAME_32, do_ncp_setobjectname)
-HANDLE_IOCTL(NCP_IOC_GETPRIVATEDATA_32, do_ncp_getprivatedata)
-HANDLE_IOCTL(NCP_IOC_SETPRIVATEDATA_32, do_ncp_setprivatedata)
-#endif
-
/* dvb */
HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event)
HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture)
diff -uprdN -X .exclude vger/fs/ncpfs/dir.c linux/fs/ncpfs/dir.c
--- linux/fs/ncpfs/dir.c 2006-07-26 18:38:17.000000000 +0200
+++ linux/fs/ncpfs/dir.c 2006-07-27 05:43:07.000000000 +0200
@@ -53,6 +53,9 @@ const struct file_operations ncp_dir_ope
.read = generic_read_dir,
.readdir = ncp_readdir,
.ioctl = ncp_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = ncp_compat_ioctl,
+#endif
};
struct inode_operations ncp_dir_inode_operations =
diff -uprdN -X .exclude vger/fs/ncpfs/file.c linux/fs/ncpfs/file.c
--- linux/fs/ncpfs/file.c 2006-07-26 18:38:17.000000000 +0200
+++ linux/fs/ncpfs/file.c 2006-07-27 05:43:07.000000000 +0200
@@ -289,6 +289,9 @@ const struct file_operations ncp_file_op
.read = ncp_file_read,
.write = ncp_file_write,
.ioctl = ncp_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = ncp_compat_ioctl,
+#endif
.mmap = ncp_mmap,
.release = ncp_release,
.fsync = ncp_fsync,
diff -uprdN -X .exclude vger/fs/ncpfs/ioctl.c linux/fs/ncpfs/ioctl.c
--- linux/fs/ncpfs/ioctl.c 2006-07-26 18:38:18.000000000 +0200
+++ linux/fs/ncpfs/ioctl.c 2006-07-28 03:17:26.000000000 +0200
@@ -7,19 +7,21 @@
*
*/
-
-#include <asm/uaccess.h>
#include <linux/capability.h>
+#include <linux/compat.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/ioctl.h>
#include <linux/time.h>
#include <linux/mm.h>
#include <linux/highuid.h>
+#include <linux/smp_lock.h>
#include <linux/vmalloc.h>
#include <linux/ncp_fs.h>
+#include <asm/uaccess.h>
+
#include "ncplib_kernel.h"
/* maximum limit for ncp_objectname_ioctl */
@@ -89,6 +91,82 @@ ncp_get_fs_info_v2(struct ncp_server * s
return 0;
}
+#ifdef CONFIG_COMPAT
+struct compat_ncp_objectname_ioctl
+{
+ s32 auth_type;
+ u32 object_name_len;
+ compat_caddr_t object_name; /* an userspace data, in most cases user name */
+};
+
+struct compat_ncp_fs_info_v2 {
+ s32 version;
+ u32 mounted_uid;
+ u32 connection;
+ u32 buffer_size;
+
+ u32 volume_number;
+ u32 directory_id;
+
+ u32 dummy1;
+ u32 dummy2;
+ u32 dummy3;
+};
+
+struct compat_ncp_ioctl_request {
+ u32 function;
+ u32 size;
+ compat_caddr_t data;
+};
+
+struct compat_ncp_privatedata_ioctl
+{
+ u32 len;
+ compat_caddr_t data; /* ~1000 for NDS */
+};
+
+#define NCP_IOC_GET_FS_INFO_V2_32 _IOWR('n', 4, struct compat_ncp_fs_info_v2)
+#define NCP_IOC_NCPREQUEST_32 _IOR('n', 1, struct compat_ncp_ioctl_request)
+#define NCP_IOC_GETOBJECTNAME_32 _IOWR('n', 9, struct compat_ncp_objectname_ioctl)
+#define NCP_IOC_SETOBJECTNAME_32 _IOR('n', 9, struct compat_ncp_objectname_ioctl)
+#define NCP_IOC_GETPRIVATEDATA_32 _IOWR('n', 10, struct compat_ncp_privatedata_ioctl)
+#define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl)
+
+static int
+ncp_get_compat_fs_info_v2(struct ncp_server * server, struct file *file,
+ struct compat_ncp_fs_info_v2 __user * arg)
+{
+ struct inode *inode = file->f_dentry->d_inode;
+ struct compat_ncp_fs_info_v2 info2;
+
+ if ((file_permission(file, MAY_WRITE) != 0)
+ && (current->uid != server->m.mounted_uid)) {
+ return -EACCES;
+ }
+ if (copy_from_user(&info2, arg, sizeof(info2)))
+ return -EFAULT;
+
+ if (info2.version != NCP_GET_FS_INFO_VERSION_V2) {
+ DPRINTK("info.version invalid: %d\n", info2.version);
+ return -EINVAL;
+ }
+ info2.mounted_uid = server->m.mounted_uid;
+ info2.connection = server->connection;
+ info2.buffer_size = server->buffer_size;
+ info2.volume_number = NCP_FINFO(inode)->volNumber;
+ info2.directory_id = NCP_FINFO(inode)->DosDirNum;
+ info2.dummy1 = info2.dummy2 = info2.dummy3 = 0;
+
+ if (copy_to_user(arg, &info2, sizeof(info2)))
+ return -EFAULT;
+ return 0;
+}
+#endif
+
+#define NCP_IOC_GETMOUNTUID16 _IOW('n', 2, u16)
+#define NCP_IOC_GETMOUNTUID32 _IOW('n', 2, u32)
+#define NCP_IOC_GETMOUNTUID64 _IOW('n', 2, u64)
+
#ifdef CONFIG_NCPFS_NLS
/* Here we are select the iocharset and the codepage for NLS.
* Thanks Petr Vandrovec for idea and many hints.
@@ -192,12 +270,24 @@ int ncp_ioctl(struct inode *inode, struc
void __user *argp = (void __user *)arg;
switch (cmd) {
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_NCPREQUEST_32:
+#endif
case NCP_IOC_NCPREQUEST:
-
if ((file_permission(filp, MAY_WRITE) != 0)
&& (current->uid != server->m.mounted_uid)) {
return -EACCES;
}
+#ifdef CONFIG_COMPAT
+ if (cmd == NCP_IOC_NCPREQUEST_32) {
+ struct compat_ncp_ioctl_request request32;
+ if (copy_from_user(&request32, argp, sizeof(request32)))
+ return -EFAULT;
+ request.function = request32.function;
+ request.size = request32.size;
+ request.data = compat_ptr(request32.data);
+ } else
+#endif
if (copy_from_user(&request, argp, sizeof(request)))
return -EFAULT;
@@ -254,19 +344,35 @@ int ncp_ioctl(struct inode *inode, struc
case NCP_IOC_GET_FS_INFO_V2:
return ncp_get_fs_info_v2(server, filp, argp);
- case NCP_IOC_GETMOUNTUID2:
- {
- unsigned long tmp = server->m.mounted_uid;
-
- if ((file_permission(filp, MAY_READ) != 0)
- && (current->uid != server->m.mounted_uid))
- {
- return -EACCES;
- }
- if (put_user(tmp, (unsigned long __user *)argp))
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_GET_FS_INFO_V2_32:
+ return ncp_get_compat_fs_info_v2(server, filp, argp);
+#endif
+ /* we have too many combinations of CONFIG_COMPAT,
+ * CONFIG_64BIT and CONFIG_UID16, so just handle
+ * any of the possible ioctls */
+ case NCP_IOC_GETMOUNTUID16:
+ case NCP_IOC_GETMOUNTUID32:
+ case NCP_IOC_GETMOUNTUID64:
+ if ((file_permission(filp, MAY_READ) != 0)
+ && (current->uid != server->m.mounted_uid)) {
+ return -EACCES;
+ }
+ if (cmd == NCP_IOC_GETMOUNTUID16) {
+ u16 uid;
+ SET_UID(uid, server->m.mounted_uid);
+ if (put_user(uid, (u16 __user *)argp))
+ return -EFAULT;
+ } else if (cmd == NCP_IOC_GETMOUNTUID32) {
+ if (put_user(server->m.mounted_uid,
+ (u32 __user *)argp))
+ return -EFAULT;
+ } else {
+ if (put_user(server->m.mounted_uid,
+ (u64 __user *)argp))
return -EFAULT;
- return 0;
}
+ return 0;
case NCP_IOC_GETROOT:
{
@@ -476,6 +582,32 @@ outrel:
}
#endif /* CONFIG_NCPFS_IOCTL_LOCKING */
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_GETOBJECTNAME_32:
+ if (current->uid != server->m.mounted_uid) {
+ return -EACCES;
+ }
+ {
+ struct compat_ncp_objectname_ioctl user;
+ size_t outl;
+
+ if (copy_from_user(&user, argp, sizeof(user)))
+ return -EFAULT;
+ user.auth_type = server->auth.auth_type;
+ outl = user.object_name_len;
+ user.object_name_len = server->auth.object_name_len;
+ if (outl > user.object_name_len)
+ outl = user.object_name_len;
+ if (outl) {
+ if (copy_to_user(compat_ptr(user.object_name),
+ server->auth.object_name,
+ outl)) return -EFAULT;
+ }
+ if (copy_to_user(argp, &user, sizeof(user)))
+ return -EFAULT;
+ return 0;
+ }
+#endif
case NCP_IOC_GETOBJECTNAME:
if (current->uid != server->m.mounted_uid) {
return -EACCES;
@@ -500,6 +632,9 @@ outrel:
return -EFAULT;
return 0;
}
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_SETOBJECTNAME_32:
+#endif
case NCP_IOC_SETOBJECTNAME:
if (current->uid != server->m.mounted_uid) {
return -EACCES;
@@ -512,8 +647,19 @@ outrel:
void* oldprivate;
size_t oldprivatelen;
+#ifdef CONFIG_COMPAT
+ if (cmd == NCP_IOC_SETOBJECTNAME_32) {
+ struct compat_ncp_objectname_ioctl user32;
+ if (copy_from_user(&user32, argp, sizeof(user32)))
+ return -EFAULT;
+ user.auth_type = user32.auth_type;
+ user.object_name_len = user32.object_name_len;
+ user.object_name = compat_ptr(user32.object_name);
+ } else
+#endif
if (copy_from_user(&user, argp, sizeof(user)))
return -EFAULT;
+
if (user.object_name_len > NCP_OBJECT_NAME_MAX_LEN)
return -ENOMEM;
if (user.object_name_len) {
@@ -544,6 +690,9 @@ outrel:
kfree(oldname);
return 0;
}
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_GETPRIVATEDATA_32:
+#endif
case NCP_IOC_GETPRIVATEDATA:
if (current->uid != server->m.mounted_uid) {
return -EACCES;
@@ -552,8 +701,18 @@ outrel:
struct ncp_privatedata_ioctl user;
size_t outl;
+#ifdef CONFIG_COMPAT
+ if (cmd == NCP_IOC_GETPRIVATEDATA_32) {
+ struct compat_ncp_privatedata_ioctl user32;
+ if (copy_from_user(&user32, argp, sizeof(user32)))
+ return -EFAULT;
+ user.len = user32.len;
+ user.data = compat_ptr(user32.data);
+ } else
+#endif
if (copy_from_user(&user, argp, sizeof(user)))
return -EFAULT;
+
outl = user.len;
user.len = server->priv.len;
if (outl > user.len) outl = user.len;
@@ -562,10 +721,23 @@ outrel:
server->priv.data,
outl)) return -EFAULT;
}
+#ifdef CONFIG_COMPAT
+ if (cmd == NCP_IOC_GETPRIVATEDATA_32) {
+ struct compat_ncp_privatedata_ioctl user32;
+ user32.len = user.len;
+ user32.data = (unsigned long) user.data;
+ if (copy_to_user(&user32, argp, sizeof(user32)))
+ return -EFAULT;
+ } else
+#endif
if (copy_to_user(argp, &user, sizeof(user)))
return -EFAULT;
+
return 0;
}
+#ifdef CONFIG_COMPAT
+ case NCP_IOC_SETPRIVATEDATA_32:
+#endif
case NCP_IOC_SETPRIVATEDATA:
if (current->uid != server->m.mounted_uid) {
return -EACCES;
@@ -576,8 +748,18 @@ outrel:
void* old;
size_t oldlen;
+#ifdef CONFIG_COMPAT
+ if (cmd == NCP_IOC_SETPRIVATEDATA_32) {
+ struct compat_ncp_privatedata_ioctl user32;
+ if (copy_from_user(&user32, argp, sizeof(user32)))
+ return -EFAULT;
+ user.len = user32.len;
+ user.data = compat_ptr(user32.data);
+ } else
+#endif
if (copy_from_user(&user, argp, sizeof(user)))
return -EFAULT;
+
if (user.len > NCP_PRIVATE_DATA_MAX_LEN)
return -ENOMEM;
if (user.len) {
@@ -636,20 +818,19 @@ outrel:
}
}
-/* #ifdef CONFIG_UID16 */
- /* NCP_IOC_GETMOUNTUID may be same as NCP_IOC_GETMOUNTUID2,
- so we have this out of switch */
- if (cmd == NCP_IOC_GETMOUNTUID) {
- __kernel_uid_t uid = 0;
- if ((file_permission(filp, MAY_READ) != 0)
- && (current->uid != server->m.mounted_uid)) {
- return -EACCES;
- }
- SET_UID(uid, server->m.mounted_uid);
- if (put_user(uid, (__kernel_uid_t __user *)argp))
- return -EFAULT;
- return 0;
- }
-/* #endif */
return -EINVAL;
}
+
+#ifdef CONFIG_COMPAT
+long ncp_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+ struct inode *inode = file->f_dentry->d_inode;
+ int ret;
+
+ lock_kernel();
+ arg = (unsigned long) compat_ptr(arg);
+ ret = ncp_ioctl(inode, file, cmd, arg);
+ unlock_kernel();
+ return ret;
+}
+#endif
diff -uprdN -X .exclude vger/include/linux/compat_ioctl.h linux/include/linux/compat_ioctl.h
--- linux/include/linux/compat_ioctl.h 2006-07-26 18:38:30.000000000 +0200
+++ linux/include/linux/compat_ioctl.h 2006-07-27 05:43:07.000000000 +0200
@@ -572,18 +572,6 @@ COMPATIBLE_IOCTL(RAW_SETBIND)
COMPATIBLE_IOCTL(RAW_GETBIND)
/* SMB ioctls which do not need any translations */
COMPATIBLE_IOCTL(SMB_IOC_NEWCONN)
-/* NCP ioctls which do not need any translations */
-COMPATIBLE_IOCTL(NCP_IOC_CONN_LOGGED_IN)
-COMPATIBLE_IOCTL(NCP_IOC_SIGN_INIT)
-COMPATIBLE_IOCTL(NCP_IOC_SIGN_WANTED)
-COMPATIBLE_IOCTL(NCP_IOC_SET_SIGN_WANTED)
-COMPATIBLE_IOCTL(NCP_IOC_LOCKUNLOCK)
-COMPATIBLE_IOCTL(NCP_IOC_GETROOT)
-COMPATIBLE_IOCTL(NCP_IOC_SETROOT)
-COMPATIBLE_IOCTL(NCP_IOC_GETCHARSETS)
-COMPATIBLE_IOCTL(NCP_IOC_SETCHARSETS)
-COMPATIBLE_IOCTL(NCP_IOC_GETDENTRYTTL)
-COMPATIBLE_IOCTL(NCP_IOC_SETDENTRYTTL)
/* Little a */
COMPATIBLE_IOCTL(ATMSIGD_CTRL)
COMPATIBLE_IOCTL(ATMARPD_CTRL)
diff -uprdN -X .exclude vger/include/linux/ncp_fs.h linux/include/linux/ncp_fs.h
--- linux/include/linux/ncp_fs.h 2006-07-26 18:38:30.000000000 +0200
+++ linux/include/linux/ncp_fs.h 2006-07-27 05:43:07.000000000 +0200
@@ -215,6 +215,7 @@ void ncp_date_unix2dos(int unix_date, __
/* linux/fs/ncpfs/ioctl.c */
int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
+long ncp_compat_ioctl(struct file *, unsigned int, unsigned long);
/* linux/fs/ncpfs/sock.c */
int ncp_request2(struct ncp_server *server, int function,
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c
2006-07-28 2:15 ` Petr Vandrovec
@ 2006-07-28 3:38 ` Arnd Bergmann
0 siblings, 0 replies; 11+ messages in thread
From: Arnd Bergmann @ 2006-07-28 3:38 UTC (permalink / raw)
To: Petr Vandrovec; +Cc: Heiko Carstens, linux-kernel, Martin Schwidefsky
On Friday 28 July 2006 04:15, Petr Vandrovec wrote:
> I've updated your diff as outlined above, and I've removed ncp_fs.h include from
> compat_ioctl, as it is not needed anymore. I've also removed one
> #include <linux/config.h> you introduced...
Ok, great! Are you pushing this for 2.6.19?
Arnd <><
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2006-07-28 3:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-10 8:51 [patch/rfc] s390: get rid of own uid16 compat system calls Heiko Carstens
2006-07-27 1:03 ` Arnd Bergmann
2006-07-27 1:08 ` reference: ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c Arnd Bergmann
2006-07-27 2:53 ` Arnd Bergmann
2006-07-27 1:09 ` reference: smbfs: simplify compat_ioctl handling Arnd Bergmann
2006-07-27 2:56 ` [PATCH] ncpfs: move ioctl32 code to fs/ncpfs/ioctl.c Arnd Bergmann
2006-07-27 3:35 ` Petr Vandrovec
2006-07-27 5:45 ` Arnd Bergmann
2006-07-28 2:15 ` Petr Vandrovec
2006-07-28 3:38 ` Arnd Bergmann
2006-07-27 6:06 ` [patch/rfc] s390: get rid of own uid16 compat system calls Heiko Carstens
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.