aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 23:25:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 23:25:04 -0400
commitaab174f0df5d72d31caccf281af5f614fa254578 (patch)
tree2a172c5009c4ac8755e858593154c258ce7709a0 /drivers/tty
parentca41cc96b2813221b05af57d0355157924de5a07 (diff)
parent2bd2c1941f141ad780135ccc1cd08ca71a24f10a (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs update from Al Viro: - big one - consolidation of descriptor-related logics; almost all of that is moved to fs/file.c (BTW, I'm seriously tempted to rename the result to fd.c. As it is, we have a situation when file_table.c is about handling of struct file and file.c is about handling of descriptor tables; the reasons are historical - file_table.c used to be about a static array of struct file we used to have way back). A lot of stray ends got cleaned up and converted to saner primitives, disgusting mess in android/binder.c is still disgusting, but at least doesn't poke so much in descriptor table guts anymore. A bunch of relatively minor races got fixed in process, plus an ext4 struct file leak. - related thing - fget_light() partially unuglified; see fdget() in there (and yes, it generates the code as good as we used to have). - also related - bits of Cyrill's procfs stuff that got entangled into that work; _not_ all of it, just the initial move to fs/proc/fd.c and switch of fdinfo to seq_file. - Alex's fs/coredump.c spiltoff - the same story, had been easier to take that commit than mess with conflicts. The rest is a separate pile, this was just a mechanical code movement. - a few misc patches all over the place. Not all for this cycle, there'll be more (and quite a few currently sit in akpm's tree)." Fix up trivial conflicts in the android binder driver, and some fairly simple conflicts due to two different changes to the sock_alloc_file() interface ("take descriptor handling from sock_alloc_file() to callers" vs "net: Providing protocol type via system.sockprotoname xattr of /proc/PID/fd entries" adding a dentry name to the socket) * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (72 commits) MAX_LFS_FILESIZE should be a loff_t compat: fs: Generic compat_sys_sendfile implementation fs: push rcu_barrier() from deactivate_locked_super() to filesystems btrfs: reada_extent doesn't need kref for refcount coredump: move core dump functionality into its own file coredump: prevent double-free on an error path in core dumper usb/gadget: fix misannotations fcntl: fix misannotations ceph: don't abuse d_delete() on failure exits hypfs: ->d_parent is never NULL or negative vfs: delete surplus inode NULL check switch simple cases of fget_light to fdget new helpers: fdget()/fdput() switch o2hb_region_dev_write() to fget_light() proc_map_files_readdir(): don't bother with grabbing files make get_file() return its argument vhost_set_vring(): turn pollstart/pollstop into bool switch prctl_set_mm_exe_file() to fget_light() switch xfs_find_handle() to fget_light() switch xfs_swapext() to fget_light() ...
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/tty_io.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 8a5a8b064616..2ea176b2280e 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -1166,10 +1166,8 @@ ssize_t redirected_tty_write(struct file *file, const char __user *buf,
1166 struct file *p = NULL; 1166 struct file *p = NULL;
1167 1167
1168 spin_lock(&redirect_lock); 1168 spin_lock(&redirect_lock);
1169 if (redirect) { 1169 if (redirect)
1170 get_file(redirect); 1170 p = get_file(redirect);
1171 p = redirect;
1172 }
1173 spin_unlock(&redirect_lock); 1171 spin_unlock(&redirect_lock);
1174 1172
1175 if (p) { 1173 if (p) {
@@ -2264,8 +2262,7 @@ static int tioccons(struct file *file)
2264 spin_unlock(&redirect_lock); 2262 spin_unlock(&redirect_lock);
2265 return -EBUSY; 2263 return -EBUSY;
2266 } 2264 }
2267 get_file(file); 2265 redirect = get_file(file);
2268 redirect = file;
2269 spin_unlock(&redirect_lock); 2266 spin_unlock(&redirect_lock);
2270 return 0; 2267 return 0;
2271} 2268}
@@ -2809,6 +2806,13 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,
2809} 2806}
2810#endif 2807#endif
2811 2808
2809static int this_tty(const void *t, struct file *file, unsigned fd)
2810{
2811 if (likely(file->f_op->read != tty_read))
2812 return 0;
2813 return file_tty(file) != t ? 0 : fd + 1;
2814}
2815
2812/* 2816/*
2813 * This implements the "Secure Attention Key" --- the idea is to 2817 * This implements the "Secure Attention Key" --- the idea is to
2814 * prevent trojan horses by killing all processes associated with this 2818 * prevent trojan horses by killing all processes associated with this
@@ -2836,8 +2840,6 @@ void __do_SAK(struct tty_struct *tty)
2836 struct task_struct *g, *p; 2840 struct task_struct *g, *p;
2837 struct pid *session; 2841 struct pid *session;
2838 int i; 2842 int i;
2839 struct file *filp;
2840 struct fdtable *fdt;
2841 2843
2842 if (!tty) 2844 if (!tty)
2843 return; 2845 return;
@@ -2867,27 +2869,12 @@ void __do_SAK(struct tty_struct *tty)
2867 continue; 2869 continue;
2868 } 2870 }
2869 task_lock(p); 2871 task_lock(p);
2870 if (p->files) { 2872 i = iterate_fd(p->files, 0, this_tty, tty);
2871 /* 2873 if (i != 0) {
2872 * We don't take a ref to the file, so we must 2874 printk(KERN_NOTICE "SAK: killed process %d"
2873 * hold ->file_lock instead. 2875 " (%s): fd#%d opened to the tty\n",
2874 */ 2876 task_pid_nr(p), p->comm, i - 1);
2875 spin_lock(&p->files->file_lock); 2877 force_sig(SIGKILL, p);
2876 fdt = files_fdtable(p->files);
2877 for (i = 0; i < fdt->max_fds; i++) {
2878 filp = fcheck_files(p->files, i);
2879 if (!filp)
2880 continue;
2881 if (filp->f_op->read == tty_read &&
2882 file_tty(filp) == tty) {
2883 printk(KERN_NOTICE "SAK: killed process %d"
2884 " (%s): fd#%d opened to the tty\n",
2885 task_pid_nr(p), p->comm, i);
2886 force_sig(SIGKILL, p);
2887 break;
2888 }
2889 }
2890 spin_unlock(&p->files->file_lock);
2891 } 2878 }
2892 task_unlock(p); 2879 task_unlock(p);
2893 } while_each_thread(g, p); 2880 } while_each_thread(g, p);