]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/n_tty.c
[IPV4] sctp: Use ipv4_is_<type>
[linux-2.6-omap-h63xx.git] / drivers / char / n_tty.c
index 154f42203b0569c4f53c306376c6720e73cfa33d..596c7173997b577d1216d479604435053da4f92f 100644 (file)
@@ -45,6 +45,8 @@
 #include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/bitops.h>
+#include <linux/audit.h>
+#include <linux/file.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -78,6 +80,13 @@ static inline void free_buf(unsigned char *buf)
                free_page((unsigned long) buf);
 }
 
+static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
+                              unsigned char __user *ptr)
+{
+       tty_audit_add_data(tty, &x, 1);
+       return put_user(x, ptr);
+}
+
 /**
  *     n_tty_set__room -       receive space
  *     @tty: terminal
@@ -428,7 +437,7 @@ static inline void finish_erasing(struct tty_struct *tty)
  *     @c: character input
  *     @tty: terminal device
  *
- *     Perform erase and neccessary output when an erase character is
+ *     Perform erase and necessary output when an erase character is
  *     present in the stream from the driver layer. Handles the complexities
  *     of UTF-8 multibyte symbols.
  */
@@ -648,7 +657,7 @@ static inline void n_tty_receive_overrun(struct tty_struct *tty)
  *     @c: character
  *
  *     Process a parity error and queue the right data to indicate
- *     the error case if neccessary. Locking as per n_tty_receive_buf.
+ *     the error case if necessary. Locking as per n_tty_receive_buf.
  */
 static inline void n_tty_receive_parity_error(struct tty_struct *tty,
                                              unsigned char c)
@@ -1153,6 +1162,7 @@ static int copy_from_read_buf(struct tty_struct *tty,
        if (n) {
                retval = copy_to_user(*b, &tty->read_buf[tty->read_tail], n);
                n -= retval;
+               tty_audit_add_data(tty, &tty->read_buf[tty->read_tail], n);
                spin_lock_irqsave(&tty->read_lock, flags);
                tty->read_tail = (tty->read_tail + n) & (N_TTY_BUF_SIZE-1);
                tty->read_cnt -= n;
@@ -1279,7 +1289,7 @@ do_it_again:
                                break;
                        cs = tty->link->ctrl_status;
                        tty->link->ctrl_status = 0;
-                       if (put_user(cs, b++)) {
+                       if (tty_put_user(tty, cs, b++)) {
                                retval = -EFAULT;
                                b--;
                                break;
@@ -1321,7 +1331,7 @@ do_it_again:
 
                /* Deal with packet mode. */
                if (tty->packet && b == buf) {
-                       if (put_user(TIOCPKT_DATA, b++)) {
+                       if (tty_put_user(tty, TIOCPKT_DATA, b++)) {
                                retval = -EFAULT;
                                b--;
                                break;
@@ -1352,15 +1362,17 @@ do_it_again:
                                spin_unlock_irqrestore(&tty->read_lock, flags);
 
                                if (!eol || (c != __DISABLED_CHAR)) {
-                                       if (put_user(c, b++)) {
+                                       if (tty_put_user(tty, c, b++)) {
                                                retval = -EFAULT;
                                                b--;
                                                break;
                                        }
                                        nr--;
                                }
-                               if (eol)
+                               if (eol) {
+                                       tty_audit_push(tty);
                                        break;
+                               }
                        }
                        if (retval)
                                break;
@@ -1538,7 +1550,8 @@ static unsigned int normal_poll(struct tty_struct * tty, struct file * file, pol
                else
                        tty->minimum_to_wake = 1;
        }
-       if (tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS &&
+       if (!tty_is_writelocked(tty) &&
+                       tty->driver->chars_in_buffer(tty) < WAKEUP_CHARS &&
                        tty->driver->write_room(tty) > 0)
                mask |= POLLOUT | POLLWRNORM;
        return mask;