aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/tty_audit.c54
-rw-r--r--drivers/char/tty_io.c5
2 files changed, 5 insertions, 54 deletions
diff --git a/drivers/char/tty_audit.c b/drivers/char/tty_audit.c
index caeedd12d494..6342b0534f4d 100644
--- a/drivers/char/tty_audit.c
+++ b/drivers/char/tty_audit.c
@@ -233,6 +233,10 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
233 if (unlikely(size == 0)) 233 if (unlikely(size == 0))
234 return; 234 return;
235 235
236 if (tty->driver->type == TTY_DRIVER_TYPE_PTY
237 && tty->driver->subtype == PTY_TYPE_MASTER)
238 return;
239
236 buf = tty_audit_buf_get(tty); 240 buf = tty_audit_buf_get(tty);
237 if (!buf) 241 if (!buf)
238 return; 242 return;
@@ -295,53 +299,3 @@ void tty_audit_push(struct tty_struct *tty)
295 tty_audit_buf_put(buf); 299 tty_audit_buf_put(buf);
296 } 300 }
297} 301}
298
299/**
300 * tty_audit_opening - A TTY is being opened.
301 *
302 * As a special hack, tasks that close all their TTYs and open new ones
303 * are assumed to be system daemons (e.g. getty) and auditing is
304 * automatically disabled for them.
305 */
306void tty_audit_opening(void)
307{
308 int disable;
309
310 disable = 1;
311 spin_lock_irq(&current->sighand->siglock);
312 if (current->signal->audit_tty == 0)
313 disable = 0;
314 spin_unlock_irq(&current->sighand->siglock);
315 if (!disable)
316 return;
317
318 task_lock(current);
319 if (current->files) {
320 struct fdtable *fdt;
321 unsigned i;
322
323 /*
324 * We don't take a ref to the file, so we must hold ->file_lock
325 * instead.
326 */
327 spin_lock(&current->files->file_lock);
328 fdt = files_fdtable(current->files);
329 for (i = 0; i < fdt->max_fds; i++) {
330 struct file *filp;
331
332 filp = fcheck_files(current->files, i);
333 if (filp && is_tty(filp)) {
334 disable = 0;
335 break;
336 }
337 }
338 spin_unlock(&current->files->file_lock);
339 }
340 task_unlock(current);
341 if (!disable)
342 return;
343
344 spin_lock_irq(&current->sighand->siglock);
345 current->signal->audit_tty = 0;
346 spin_unlock_irq(&current->sighand->siglock);
347}
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 4d3c7018f0c3..afddccf1bb3d 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2755,7 +2755,6 @@ got_driver:
2755 __proc_set_tty(current, tty); 2755 __proc_set_tty(current, tty);
2756 spin_unlock_irq(&current->sighand->siglock); 2756 spin_unlock_irq(&current->sighand->siglock);
2757 mutex_unlock(&tty_mutex); 2757 mutex_unlock(&tty_mutex);
2758 tty_audit_opening();
2759 return 0; 2758 return 0;
2760} 2759}
2761 2760
@@ -2818,10 +2817,8 @@ static int ptmx_open(struct inode *inode, struct file *filp)
2818 2817
2819 check_tty_count(tty, "tty_open"); 2818 check_tty_count(tty, "tty_open");
2820 retval = ptm_driver->open(tty, filp); 2819 retval = ptm_driver->open(tty, filp);
2821 if (!retval) { 2820 if (!retval)
2822 tty_audit_opening();
2823 return 0; 2821 return 0;
2824 }
2825out1: 2822out1:
2826 release_dev(filp); 2823 release_dev(filp);
2827 return retval; 2824 return retval;