aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/tty_audit.c54
-rw-r--r--drivers/char/tty_io.c5
-rw-r--r--include/linux/tty.h5
3 files changed, 5 insertions, 59 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;
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 430624504ca0..265831ccaa88 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -300,7 +300,6 @@ extern void tty_hangup(struct tty_struct * tty);
300extern void tty_vhangup(struct tty_struct * tty); 300extern void tty_vhangup(struct tty_struct * tty);
301extern void tty_unhangup(struct file *filp); 301extern void tty_unhangup(struct file *filp);
302extern int tty_hung_up_p(struct file * filp); 302extern int tty_hung_up_p(struct file * filp);
303extern int is_tty(struct file *filp);
304extern void do_SAK(struct tty_struct *tty); 303extern void do_SAK(struct tty_struct *tty);
305extern void __do_SAK(struct tty_struct *tty); 304extern void __do_SAK(struct tty_struct *tty);
306extern void disassociate_ctty(int priv); 305extern void disassociate_ctty(int priv);
@@ -352,7 +351,6 @@ extern void tty_audit_exit(void);
352extern void tty_audit_fork(struct signal_struct *sig); 351extern void tty_audit_fork(struct signal_struct *sig);
353extern void tty_audit_push(struct tty_struct *tty); 352extern void tty_audit_push(struct tty_struct *tty);
354extern void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid); 353extern void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid);
355extern void tty_audit_opening(void);
356#else 354#else
357static inline void tty_audit_add_data(struct tty_struct *tty, 355static inline void tty_audit_add_data(struct tty_struct *tty,
358 unsigned char *data, size_t size) 356 unsigned char *data, size_t size)
@@ -370,9 +368,6 @@ static inline void tty_audit_push(struct tty_struct *tty)
370static inline void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid) 368static inline void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid)
371{ 369{
372} 370}
373static inline void tty_audit_opening(void)
374{
375}
376#endif 371#endif
377 372
378/* tty_ioctl.c */ 373/* tty_ioctl.c */