aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_audit.c
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/tty/tty_audit.c
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/tty/tty_audit.c')
-rw-r--r--drivers/tty/tty_audit.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c
index 6953dc82850..7c586692062 100644
--- a/drivers/tty/tty_audit.c
+++ b/drivers/tty/tty_audit.c
@@ -23,7 +23,7 @@ struct tty_audit_buf {
23}; 23};
24 24
25static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor, 25static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor,
26 unsigned icanon) 26 int icanon)
27{ 27{
28 struct tty_audit_buf *buf; 28 struct tty_audit_buf *buf;
29 29
@@ -61,7 +61,7 @@ static void tty_audit_buf_put(struct tty_audit_buf *buf)
61} 61}
62 62
63static void tty_audit_log(const char *description, struct task_struct *tsk, 63static void tty_audit_log(const char *description, struct task_struct *tsk,
64 kuid_t loginuid, unsigned sessionid, int major, 64 uid_t loginuid, unsigned sessionid, int major,
65 int minor, unsigned char *data, size_t size) 65 int minor, unsigned char *data, size_t size)
66{ 66{
67 struct audit_buffer *ab; 67 struct audit_buffer *ab;
@@ -69,14 +69,11 @@ static void tty_audit_log(const char *description, struct task_struct *tsk,
69 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_TTY); 69 ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_TTY);
70 if (ab) { 70 if (ab) {
71 char name[sizeof(tsk->comm)]; 71 char name[sizeof(tsk->comm)];
72 kuid_t uid = task_uid(tsk); 72 uid_t uid = task_uid(tsk);
73 73
74 audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u " 74 audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u "
75 "major=%d minor=%d comm=", description, 75 "major=%d minor=%d comm=", description,
76 tsk->pid, 76 tsk->pid, uid, loginuid, sessionid,
77 from_kuid(&init_user_ns, uid),
78 from_kuid(&init_user_ns, loginuid),
79 sessionid,
80 major, minor); 77 major, minor);
81 get_task_comm(name, tsk); 78 get_task_comm(name, tsk);
82 audit_log_untrustedstring(ab, name); 79 audit_log_untrustedstring(ab, name);
@@ -92,7 +89,7 @@ static void tty_audit_log(const char *description, struct task_struct *tsk,
92 * Generate an audit message from the contents of @buf, which is owned by 89 * Generate an audit message from the contents of @buf, which is owned by
93 * @tsk with @loginuid. @buf->mutex must be locked. 90 * @tsk with @loginuid. @buf->mutex must be locked.
94 */ 91 */
95static void tty_audit_buf_push(struct task_struct *tsk, kuid_t loginuid, 92static void tty_audit_buf_push(struct task_struct *tsk, uid_t loginuid,
96 unsigned int sessionid, 93 unsigned int sessionid,
97 struct tty_audit_buf *buf) 94 struct tty_audit_buf *buf)
98{ 95{
@@ -115,7 +112,7 @@ static void tty_audit_buf_push(struct task_struct *tsk, kuid_t loginuid,
115 */ 112 */
116static void tty_audit_buf_push_current(struct tty_audit_buf *buf) 113static void tty_audit_buf_push_current(struct tty_audit_buf *buf)
117{ 114{
118 kuid_t auid = audit_get_loginuid(current); 115 uid_t auid = audit_get_loginuid(current);
119 unsigned int sessionid = audit_get_sessionid(current); 116 unsigned int sessionid = audit_get_sessionid(current);
120 tty_audit_buf_push(current, auid, sessionid, buf); 117 tty_audit_buf_push(current, auid, sessionid, buf);
121} 118}
@@ -182,7 +179,7 @@ void tty_audit_tiocsti(struct tty_struct *tty, char ch)
182 } 179 }
183 180
184 if (should_audit && audit_enabled) { 181 if (should_audit && audit_enabled) {
185 kuid_t auid; 182 uid_t auid;
186 unsigned int sessionid; 183 unsigned int sessionid;
187 184
188 auid = audit_get_loginuid(current); 185 auid = audit_get_loginuid(current);
@@ -202,7 +199,7 @@ void tty_audit_tiocsti(struct tty_struct *tty, char ch)
202 * reference to the tty audit buffer if available. 199 * reference to the tty audit buffer if available.
203 * Flush the buffer or return an appropriate error code. 200 * Flush the buffer or return an appropriate error code.
204 */ 201 */
205int tty_audit_push_task(struct task_struct *tsk, kuid_t loginuid, u32 sessionid) 202int tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid)
206{ 203{
207 struct tty_audit_buf *buf = ERR_PTR(-EPERM); 204 struct tty_audit_buf *buf = ERR_PTR(-EPERM);
208 unsigned long flags; 205 unsigned long flags;
@@ -239,8 +236,7 @@ int tty_audit_push_task(struct task_struct *tsk, kuid_t loginuid, u32 sessionid)
239 * if TTY auditing is disabled or out of memory. Otherwise, return a new 236 * if TTY auditing is disabled or out of memory. Otherwise, return a new
240 * reference to the buffer. 237 * reference to the buffer.
241 */ 238 */
242static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty, 239static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty)
243 unsigned icanon)
244{ 240{
245 struct tty_audit_buf *buf, *buf2; 241 struct tty_audit_buf *buf, *buf2;
246 242
@@ -258,7 +254,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty,
258 254
259 buf2 = tty_audit_buf_alloc(tty->driver->major, 255 buf2 = tty_audit_buf_alloc(tty->driver->major,
260 tty->driver->minor_start + tty->index, 256 tty->driver->minor_start + tty->index,
261 icanon); 257 tty->icanon);
262 if (buf2 == NULL) { 258 if (buf2 == NULL) {
263 audit_log_lost("out of memory in TTY auditing"); 259 audit_log_lost("out of memory in TTY auditing");
264 return NULL; 260 return NULL;
@@ -288,7 +284,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty,
288 * Audit @data of @size from @tty, if necessary. 284 * Audit @data of @size from @tty, if necessary.
289 */ 285 */
290void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, 286void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
291 size_t size, unsigned icanon) 287 size_t size)
292{ 288{
293 struct tty_audit_buf *buf; 289 struct tty_audit_buf *buf;
294 int major, minor; 290 int major, minor;
@@ -300,7 +296,7 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
300 && tty->driver->subtype == PTY_TYPE_MASTER) 296 && tty->driver->subtype == PTY_TYPE_MASTER)
301 return; 297 return;
302 298
303 buf = tty_audit_buf_get(tty, icanon); 299 buf = tty_audit_buf_get(tty);
304 if (!buf) 300 if (!buf)
305 return; 301 return;
306 302
@@ -308,11 +304,11 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
308 major = tty->driver->major; 304 major = tty->driver->major;
309 minor = tty->driver->minor_start + tty->index; 305 minor = tty->driver->minor_start + tty->index;
310 if (buf->major != major || buf->minor != minor 306 if (buf->major != major || buf->minor != minor
311 || buf->icanon != icanon) { 307 || buf->icanon != tty->icanon) {
312 tty_audit_buf_push_current(buf); 308 tty_audit_buf_push_current(buf);
313 buf->major = major; 309 buf->major = major;
314 buf->minor = minor; 310 buf->minor = minor;
315 buf->icanon = icanon; 311 buf->icanon = tty->icanon;
316 } 312 }
317 do { 313 do {
318 size_t run; 314 size_t run;