From 1dce27c5aa6770e9d195f2bb7db1db3d4dde5591 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 16 Feb 2012 17:49:42 +0000 Subject: Wrap accesses to the fd_sets in struct fdtable Wrap accesses to the fd_sets in struct fdtable (for recording open files and close-on-exec flags) so that we can move away from using fd_sets since we abuse the fd_set structs by not allocating the full-sized structure under normal circumstances and by non-core code looking at the internals of the fd_sets. The first abuse means that use of FD_ZERO() on these fd_sets is not permitted, since that cannot be told about their abnormal lengths. This introduces six wrapper functions for setting, clearing and testing close-on-exec flags and fd-is-open flags: void __set_close_on_exec(int fd, struct fdtable *fdt); void __clear_close_on_exec(int fd, struct fdtable *fdt); bool close_on_exec(int fd, const struct fdtable *fdt); void __set_open_fd(int fd, struct fdtable *fdt); void __clear_open_fd(int fd, struct fdtable *fdt); bool fd_is_open(int fd, const struct fdtable *fdt); Note that I've prepended '__' to the names of the set/clear functions because they require the caller to hold a lock to use them. Note also that I haven't added wrappers for looking behind the scenes at the the array. Possibly that should exist too. Signed-off-by: David Howells Link: http://lkml.kernel.org/r/20120216174942.23314.1364.stgit@warthog.procyon.org.uk Signed-off-by: H. Peter Anvin Cc: Al Viro --- drivers/staging/android/binder.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 7491801a661..35dd9c370e5 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -408,11 +408,11 @@ repeat: goto repeat; } - FD_SET(fd, fdt->open_fds); + __set_open_fd(fd, fdt); if (flags & O_CLOEXEC) - FD_SET(fd, fdt->close_on_exec); + __set_close_on_exec(fd, fdt); else - FD_CLR(fd, fdt->close_on_exec); + __clear_close_on_exec(fd, fdt); files->next_fd = fd + 1; #if 1 /* Sanity check */ @@ -453,7 +453,7 @@ static void task_fd_install( static void __put_unused_fd(struct files_struct *files, unsigned int fd) { struct fdtable *fdt = files_fdtable(files); - __FD_CLR(fd, fdt->open_fds); + __clear_open_fd(fd, fdt); if (fd < files->next_fd) files->next_fd = fd; } @@ -479,7 +479,7 @@ static long task_close_fd(struct binder_proc *proc, unsigned int fd) if (!filp) goto out_unlock; rcu_assign_pointer(fdt->fd[fd], NULL); - FD_CLR(fd, fdt->close_on_exec); + __clear_close_on_exec(fd, fdt); __put_unused_fd(files, fd); spin_unlock(&files->file_lock); retval = filp_close(filp, files); -- cgit v1.2.3 From 9dd4ccaaf8cde924b78ba5f5b1a8ce3e7ead687f Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 10 Feb 2012 14:08:52 -0800 Subject: compat: Handle COMPAT_USE_64BIT_TIME in the lp driver Enable the lp driver to be used with a compat ABI with 64-bit time. Signed-off-by: H. Peter Anvin Cc: Arnd Bergmann Cc: Greg Kroah-Hartman --- drivers/char/lp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index f4348560706..a27097173b3 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -706,16 +706,13 @@ static long lp_compat_ioctl(struct file *file, unsigned int cmd, { unsigned int minor; struct timeval par_timeout; - struct compat_timeval __user *tc; int ret; minor = iminor(file->f_path.dentry->d_inode); mutex_lock(&lp_mutex); switch (cmd) { case LPSETTIMEOUT: - tc = compat_ptr(arg); - if (get_user(par_timeout.tv_sec, &tc->tv_sec) || - get_user(par_timeout.tv_usec, &tc->tv_usec)) { + if (compat_get_timeval(&par_timeout, compat_ptr(arg))) { ret = -EFAULT; break; } -- cgit v1.2.3 From f930a7a0f4c87bf3ee731383421ebf3164009ee7 Mon Sep 17 00:00:00 2001 From: "H. J. Lu" Date: Fri, 10 Feb 2012 14:10:52 -0800 Subject: compat: Use COMPAT_USE_64BIT_TIME in the input subsystem Enable the input system to be used with a compat ABI with 64-bit time. Signed-off-by: H. Peter Anvin Cc: Dmitry Torokhov --- drivers/input/input-compat.c | 4 ++-- drivers/input/input-compat.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/input/input-compat.c b/drivers/input/input-compat.c index e46a86776a6..64ca7113ff2 100644 --- a/drivers/input/input-compat.c +++ b/drivers/input/input-compat.c @@ -17,7 +17,7 @@ int input_event_from_user(const char __user *buffer, struct input_event *event) { - if (INPUT_COMPAT_TEST) { + if (INPUT_COMPAT_TEST && !COMPAT_USE_64BIT_TIME) { struct input_event_compat compat_event; if (copy_from_user(&compat_event, buffer, @@ -41,7 +41,7 @@ int input_event_from_user(const char __user *buffer, int input_event_to_user(char __user *buffer, const struct input_event *event) { - if (INPUT_COMPAT_TEST) { + if (INPUT_COMPAT_TEST && !COMPAT_USE_64BIT_TIME) { struct input_event_compat compat_event; compat_event.time.tv_sec = event->time.tv_sec; diff --git a/drivers/input/input-compat.h b/drivers/input/input-compat.h index 22be27b424d..148f66fe320 100644 --- a/drivers/input/input-compat.h +++ b/drivers/input/input-compat.h @@ -67,7 +67,7 @@ struct ff_effect_compat { static inline size_t input_event_size(void) { - return INPUT_COMPAT_TEST ? + return (INPUT_COMPAT_TEST && !COMPAT_USE_64BIT_TIME) ? sizeof(struct input_event_compat) : sizeof(struct input_event); } -- cgit v1.2.3 From 189017c25c8497760c89646c06297c37d6cde072 Mon Sep 17 00:00:00 2001 From: David Howells Date: Fri, 24 Feb 2012 10:57:07 +0000 Subject: fs: Remove missed ->fds_bits from cessation use of fd_set structs internally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stephen Rothwell reported that the following commit broke the linux-next build: 1fd36adcd98c: Replace the fd_sets in struct fdtable with an array of unsigned longs Fix places where ->fds_bits needed to be removed as the core kernel no longer uses fd_set internally for file descriptor table management. There are two places: (1) drivers/staging/android/binder.c (2) arch/mips/kernel/kspd.c Question: Should sp_cleanup() in the MIPS arch be using find_next_bit() or fls()? Reported-by: Stephen Rothwell Signed-off-by: David Howells cc: Ralf Bächle cc: Arve Hjønnevåg Link: http://lkml.kernel.org/r/20120224105707.32170.11550.stgit@warthog.procyon.org.uk Signed-off-by: Ingo Molnar --- drivers/staging/android/binder.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c index 35dd9c370e5..9446f0185f5 100644 --- a/drivers/staging/android/binder.c +++ b/drivers/staging/android/binder.c @@ -379,8 +379,7 @@ int task_get_unused_fd_flags(struct binder_proc *proc, int flags) repeat: fdt = files_fdtable(files); - fd = find_next_zero_bit(fdt->open_fds->fds_bits, fdt->max_fds, - files->next_fd); + fd = find_next_zero_bit(fdt->open_fds, fdt->max_fds, files->next_fd); /* * N.B. For clone tasks sharing a files structure, this test -- cgit v1.2.3