Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Creating audit events from TTY input. |
| 3 | * |
| 4 | * Copyright (C) 2007 Red Hat, Inc. All rights reserved. This copyrighted |
| 5 | * material is made available to anyone wishing to use, modify, copy, or |
| 6 | * redistribute it subject to the terms and conditions of the GNU General |
| 7 | * Public License v.2. |
| 8 | * |
| 9 | * Authors: Miloslav Trmac <mitr@redhat.com> |
| 10 | */ |
| 11 | |
| 12 | #include <linux/audit.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 14 | #include <linux/tty.h> |
| 15 | |
| 16 | struct tty_audit_buf { |
| 17 | atomic_t count; |
| 18 | struct mutex mutex; /* Protects all data below */ |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 19 | dev_t dev; /* The TTY which the data is from */ |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 20 | unsigned icanon:1; |
| 21 | size_t valid; |
| 22 | unsigned char *data; /* Allocated size N_TTY_BUF_SIZE */ |
| 23 | }; |
| 24 | |
Peter Hurley | a75c9b0 | 2016-01-09 22:55:28 -0800 | [diff] [blame] | 25 | static struct tty_audit_buf *tty_audit_buf_alloc(void) |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 26 | { |
| 27 | struct tty_audit_buf *buf; |
| 28 | |
Alan Cox | 66c6cea | 2008-02-08 04:18:46 -0800 | [diff] [blame] | 29 | buf = kmalloc(sizeof(*buf), GFP_KERNEL); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 30 | if (!buf) |
| 31 | goto err; |
Alan Cox | c481c70 | 2009-06-11 13:04:27 +0100 | [diff] [blame] | 32 | buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 33 | if (!buf->data) |
| 34 | goto err_buf; |
| 35 | atomic_set(&buf->count, 1); |
| 36 | mutex_init(&buf->mutex); |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 37 | buf->dev = MKDEV(0, 0); |
Peter Hurley | a75c9b0 | 2016-01-09 22:55:28 -0800 | [diff] [blame] | 38 | buf->icanon = 0; |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 39 | buf->valid = 0; |
| 40 | return buf; |
| 41 | |
| 42 | err_buf: |
| 43 | kfree(buf); |
| 44 | err: |
| 45 | return NULL; |
| 46 | } |
| 47 | |
| 48 | static void tty_audit_buf_free(struct tty_audit_buf *buf) |
| 49 | { |
| 50 | WARN_ON(buf->valid != 0); |
Alan Cox | c481c70 | 2009-06-11 13:04:27 +0100 | [diff] [blame] | 51 | kfree(buf->data); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 52 | kfree(buf); |
| 53 | } |
| 54 | |
| 55 | static void tty_audit_buf_put(struct tty_audit_buf *buf) |
| 56 | { |
| 57 | if (atomic_dec_and_test(&buf->count)) |
| 58 | tty_audit_buf_free(buf); |
| 59 | } |
| 60 | |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 61 | static void tty_audit_log(const char *description, dev_t dev, |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 62 | unsigned char *data, size_t size) |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 63 | { |
| 64 | struct audit_buffer *ab; |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 65 | struct task_struct *tsk = current; |
Richard Guy Briggs | f1dc486 | 2013-12-11 13:52:26 -0500 | [diff] [blame] | 66 | pid_t pid = task_pid_nr(tsk); |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 67 | uid_t uid = from_kuid(&init_user_ns, task_uid(tsk)); |
| 68 | uid_t loginuid = from_kuid(&init_user_ns, audit_get_loginuid(tsk)); |
Eric Paris | 4440e85 | 2013-11-27 17:35:17 -0500 | [diff] [blame] | 69 | unsigned int sessionid = audit_get_sessionid(tsk); |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 70 | |
| 71 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_TTY); |
| 72 | if (ab) { |
| 73 | char name[sizeof(tsk->comm)]; |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 74 | |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 75 | audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u major=%d" |
Richard Guy Briggs | f1dc486 | 2013-12-11 13:52:26 -0500 | [diff] [blame] | 76 | " minor=%d comm=", description, pid, uid, |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 77 | loginuid, sessionid, MAJOR(dev), MINOR(dev)); |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 78 | get_task_comm(name, tsk); |
| 79 | audit_log_untrustedstring(ab, name); |
| 80 | audit_log_format(ab, " data="); |
| 81 | audit_log_n_hex(ab, data, size); |
| 82 | audit_log_end(ab); |
| 83 | } |
| 84 | } |
| 85 | |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 86 | /** |
| 87 | * tty_audit_buf_push - Push buffered data out |
| 88 | * |
| 89 | * Generate an audit message from the contents of @buf, which is owned by |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 90 | * the current task. @buf->mutex must be locked. |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 91 | */ |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 92 | static void tty_audit_buf_push(struct tty_audit_buf *buf) |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 93 | { |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 94 | if (buf->valid == 0) |
| 95 | return; |
Xiaotian Feng | 00bff39 | 2011-03-03 18:08:24 +0800 | [diff] [blame] | 96 | if (audit_enabled == 0) { |
| 97 | buf->valid = 0; |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 98 | return; |
Xiaotian Feng | 00bff39 | 2011-03-03 18:08:24 +0800 | [diff] [blame] | 99 | } |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 100 | tty_audit_log("tty", buf->dev, buf->data, buf->valid); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 101 | buf->valid = 0; |
| 102 | } |
| 103 | |
| 104 | /** |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 105 | * tty_audit_exit - Handle a task exit |
| 106 | * |
| 107 | * Make sure all buffered data is written out and deallocate the buffer. |
| 108 | * Only needs to be called if current->signal->tty_audit_buf != %NULL. |
| 109 | */ |
| 110 | void tty_audit_exit(void) |
| 111 | { |
| 112 | struct tty_audit_buf *buf; |
| 113 | |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 114 | buf = current->signal->tty_audit_buf; |
| 115 | current->signal->tty_audit_buf = NULL; |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 116 | if (!buf) |
| 117 | return; |
| 118 | |
| 119 | mutex_lock(&buf->mutex); |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 120 | tty_audit_buf_push(buf); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 121 | mutex_unlock(&buf->mutex); |
| 122 | |
| 123 | tty_audit_buf_put(buf); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * tty_audit_fork - Copy TTY audit state for a new task |
| 128 | * |
| 129 | * Set up TTY audit state in @sig from current. @sig needs no locking. |
| 130 | */ |
| 131 | void tty_audit_fork(struct signal_struct *sig) |
| 132 | { |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 133 | sig->audit_tty = current->signal->audit_tty; |
Richard Guy Briggs | 46e959e | 2013-05-03 14:03:50 -0400 | [diff] [blame] | 134 | sig->audit_tty_log_passwd = current->signal->audit_tty_log_passwd; |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | /** |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 138 | * tty_audit_tiocsti - Log TIOCSTI |
| 139 | */ |
| 140 | void tty_audit_tiocsti(struct tty_struct *tty, char ch) |
| 141 | { |
| 142 | struct tty_audit_buf *buf; |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 143 | dev_t dev; |
| 144 | int should_audit; |
Eric Paris | bde02ca | 2013-04-30 11:01:14 -0400 | [diff] [blame] | 145 | unsigned long flags; |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 146 | |
Eric Paris | bde02ca | 2013-04-30 11:01:14 -0400 | [diff] [blame] | 147 | spin_lock_irqsave(¤t->sighand->siglock, flags); |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 148 | should_audit = current->signal->audit_tty; |
| 149 | buf = current->signal->tty_audit_buf; |
| 150 | if (buf) |
| 151 | atomic_inc(&buf->count); |
Eric Paris | bde02ca | 2013-04-30 11:01:14 -0400 | [diff] [blame] | 152 | spin_unlock_irqrestore(¤t->sighand->siglock, flags); |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 153 | |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 154 | dev = MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index; |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 155 | if (buf) { |
| 156 | mutex_lock(&buf->mutex); |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 157 | if (buf->dev == dev) |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 158 | tty_audit_buf_push(buf); |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 159 | mutex_unlock(&buf->mutex); |
| 160 | tty_audit_buf_put(buf); |
| 161 | } |
| 162 | |
| 163 | if (should_audit && audit_enabled) { |
Eric W. Biederman | e1760bd | 2012-09-10 22:39:43 -0700 | [diff] [blame] | 164 | kuid_t auid; |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 165 | unsigned int sessionid; |
| 166 | |
| 167 | auid = audit_get_loginuid(current); |
| 168 | sessionid = audit_get_sessionid(current); |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 169 | tty_audit_log("ioctl=TIOCSTI", dev, &ch, 1); |
Al Viro | 1e64174 | 2008-12-09 09:23:33 +0000 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
| 173 | /** |
Peter Hurley | 37282a7 | 2016-01-09 22:55:31 -0800 | [diff] [blame] | 174 | * tty_audit_push - Flush current's pending audit data |
Thomas Gleixner | 3c80fe4 | 2009-12-09 14:19:31 +0000 | [diff] [blame] | 175 | * |
Peter Hurley | 37282a7 | 2016-01-09 22:55:31 -0800 | [diff] [blame] | 176 | * Returns 0 if success, -EPERM if tty audit is disabled |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 177 | */ |
Peter Hurley | 37282a7 | 2016-01-09 22:55:31 -0800 | [diff] [blame] | 178 | int tty_audit_push(void) |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 179 | { |
Thomas Gleixner | 3c80fe4 | 2009-12-09 14:19:31 +0000 | [diff] [blame] | 180 | struct tty_audit_buf *buf = ERR_PTR(-EPERM); |
| 181 | unsigned long flags; |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 182 | |
Peter Hurley | f229c2c | 2016-01-09 22:55:29 -0800 | [diff] [blame] | 183 | spin_lock_irqsave(¤t->sighand->siglock, flags); |
| 184 | if (current->signal->audit_tty) { |
| 185 | buf = current->signal->tty_audit_buf; |
Thomas Gleixner | 3c80fe4 | 2009-12-09 14:19:31 +0000 | [diff] [blame] | 186 | if (buf) |
| 187 | atomic_inc(&buf->count); |
| 188 | } |
Peter Hurley | f229c2c | 2016-01-09 22:55:29 -0800 | [diff] [blame] | 189 | spin_unlock_irqrestore(¤t->sighand->siglock, flags); |
Thomas Gleixner | 3c80fe4 | 2009-12-09 14:19:31 +0000 | [diff] [blame] | 190 | |
| 191 | /* |
| 192 | * Return 0 when signal->audit_tty set |
Peter Hurley | f229c2c | 2016-01-09 22:55:29 -0800 | [diff] [blame] | 193 | * but current->signal->tty_audit_buf == NULL. |
Thomas Gleixner | 3c80fe4 | 2009-12-09 14:19:31 +0000 | [diff] [blame] | 194 | */ |
| 195 | if (!buf || IS_ERR(buf)) |
| 196 | return PTR_ERR(buf); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 197 | |
| 198 | mutex_lock(&buf->mutex); |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 199 | tty_audit_buf_push(buf); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 200 | mutex_unlock(&buf->mutex); |
| 201 | |
| 202 | tty_audit_buf_put(buf); |
Thomas Gleixner | 3c80fe4 | 2009-12-09 14:19:31 +0000 | [diff] [blame] | 203 | return 0; |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | /** |
| 207 | * tty_audit_buf_get - Get an audit buffer. |
| 208 | * |
Peter Hurley | a75c9b0 | 2016-01-09 22:55:28 -0800 | [diff] [blame] | 209 | * Get an audit buffer, allocate it if necessary. Return %NULL |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 210 | * if TTY auditing is disabled or out of memory. Otherwise, return a new |
| 211 | * reference to the buffer. |
| 212 | */ |
Peter Hurley | a75c9b0 | 2016-01-09 22:55:28 -0800 | [diff] [blame] | 213 | static struct tty_audit_buf *tty_audit_buf_get(void) |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 214 | { |
| 215 | struct tty_audit_buf *buf, *buf2; |
Eric Paris | bde02ca | 2013-04-30 11:01:14 -0400 | [diff] [blame] | 216 | unsigned long flags; |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 217 | |
| 218 | buf = NULL; |
| 219 | buf2 = NULL; |
Eric Paris | bde02ca | 2013-04-30 11:01:14 -0400 | [diff] [blame] | 220 | spin_lock_irqsave(¤t->sighand->siglock, flags); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 221 | if (likely(!current->signal->audit_tty)) |
| 222 | goto out; |
| 223 | buf = current->signal->tty_audit_buf; |
| 224 | if (buf) { |
| 225 | atomic_inc(&buf->count); |
| 226 | goto out; |
| 227 | } |
Eric Paris | bde02ca | 2013-04-30 11:01:14 -0400 | [diff] [blame] | 228 | spin_unlock_irqrestore(¤t->sighand->siglock, flags); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 229 | |
Peter Hurley | a75c9b0 | 2016-01-09 22:55:28 -0800 | [diff] [blame] | 230 | buf2 = tty_audit_buf_alloc(); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 231 | if (buf2 == NULL) { |
| 232 | audit_log_lost("out of memory in TTY auditing"); |
| 233 | return NULL; |
| 234 | } |
| 235 | |
Eric Paris | bde02ca | 2013-04-30 11:01:14 -0400 | [diff] [blame] | 236 | spin_lock_irqsave(¤t->sighand->siglock, flags); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 237 | if (!current->signal->audit_tty) |
| 238 | goto out; |
| 239 | buf = current->signal->tty_audit_buf; |
| 240 | if (!buf) { |
| 241 | current->signal->tty_audit_buf = buf2; |
| 242 | buf = buf2; |
| 243 | buf2 = NULL; |
| 244 | } |
| 245 | atomic_inc(&buf->count); |
| 246 | /* Fall through */ |
| 247 | out: |
Eric Paris | bde02ca | 2013-04-30 11:01:14 -0400 | [diff] [blame] | 248 | spin_unlock_irqrestore(¤t->sighand->siglock, flags); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 249 | if (buf2) |
| 250 | tty_audit_buf_free(buf2); |
| 251 | return buf; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * tty_audit_add_data - Add data for TTY auditing. |
| 256 | * |
| 257 | * Audit @data of @size from @tty, if necessary. |
| 258 | */ |
Peter Hurley | 309426a | 2016-01-09 22:55:27 -0800 | [diff] [blame] | 259 | void tty_audit_add_data(struct tty_struct *tty, const void *data, size_t size) |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 260 | { |
| 261 | struct tty_audit_buf *buf; |
Richard Guy Briggs | 46e959e | 2013-05-03 14:03:50 -0400 | [diff] [blame] | 262 | int audit_log_tty_passwd; |
| 263 | unsigned long flags; |
Peter Hurley | 309426a | 2016-01-09 22:55:27 -0800 | [diff] [blame] | 264 | unsigned int icanon = !!L_ICANON(tty); |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 265 | dev_t dev; |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 266 | |
| 267 | if (unlikely(size == 0)) |
| 268 | return; |
| 269 | |
Peter Hurley | d7c0ba4 | 2016-01-09 22:55:25 -0800 | [diff] [blame] | 270 | if (tty->driver->type == TTY_DRIVER_TYPE_PTY |
| 271 | && tty->driver->subtype == PTY_TYPE_MASTER) |
| 272 | return; |
| 273 | |
Richard Guy Briggs | 46e959e | 2013-05-03 14:03:50 -0400 | [diff] [blame] | 274 | spin_lock_irqsave(¤t->sighand->siglock, flags); |
| 275 | audit_log_tty_passwd = current->signal->audit_tty_log_passwd; |
| 276 | spin_unlock_irqrestore(¤t->sighand->siglock, flags); |
| 277 | if (!audit_log_tty_passwd && icanon && !L_ECHO(tty)) |
| 278 | return; |
| 279 | |
Peter Hurley | a75c9b0 | 2016-01-09 22:55:28 -0800 | [diff] [blame] | 280 | buf = tty_audit_buf_get(); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 281 | if (!buf) |
| 282 | return; |
| 283 | |
| 284 | mutex_lock(&buf->mutex); |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 285 | dev = MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index; |
| 286 | if (buf->dev != dev || buf->icanon != icanon) { |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 287 | tty_audit_buf_push(buf); |
Peter Hurley | 4d240b6 | 2016-01-09 22:55:32 -0800 | [diff] [blame^] | 288 | buf->dev = dev; |
Jiri Slaby | 6c633f2 | 2012-10-18 22:26:37 +0200 | [diff] [blame] | 289 | buf->icanon = icanon; |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 290 | } |
| 291 | do { |
| 292 | size_t run; |
| 293 | |
| 294 | run = N_TTY_BUF_SIZE - buf->valid; |
| 295 | if (run > size) |
| 296 | run = size; |
| 297 | memcpy(buf->data + buf->valid, data, run); |
| 298 | buf->valid += run; |
| 299 | data += run; |
| 300 | size -= run; |
| 301 | if (buf->valid == N_TTY_BUF_SIZE) |
Eric Paris | 152f497 | 2013-04-19 13:56:11 -0400 | [diff] [blame] | 302 | tty_audit_buf_push(buf); |
Miloslav Trmac | 522ed77 | 2007-07-15 23:40:56 -0700 | [diff] [blame] | 303 | } while (size != 0); |
| 304 | mutex_unlock(&buf->mutex); |
| 305 | tty_audit_buf_put(buf); |
| 306 | } |