Commit 6c633f27 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

TTY: audit, stop accessing tty->icount

This is a private member of n_tty. Stop accessing it. Instead, take is
as an argument.

This is needed to allow clean switch of the private members to a
separate private structure of n_tty.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Acked-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3383427a
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
static inline int tty_put_user(struct tty_struct *tty, unsigned char x, static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
unsigned char __user *ptr) unsigned char __user *ptr)
{ {
tty_audit_add_data(tty, &x, 1); tty_audit_add_data(tty, &x, 1, tty->icanon);
return put_user(x, ptr); return put_user(x, ptr);
} }
...@@ -1644,7 +1644,8 @@ static int copy_from_read_buf(struct tty_struct *tty, ...@@ -1644,7 +1644,8 @@ static int copy_from_read_buf(struct tty_struct *tty,
n -= retval; n -= retval;
is_eof = n == 1 && is_eof = n == 1 &&
tty->read_buf[tty->read_tail] == EOF_CHAR(tty); tty->read_buf[tty->read_tail] == EOF_CHAR(tty);
tty_audit_add_data(tty, &tty->read_buf[tty->read_tail], n); tty_audit_add_data(tty, &tty->read_buf[tty->read_tail], n,
tty->icanon);
spin_lock_irqsave(&tty->read_lock, flags); spin_lock_irqsave(&tty->read_lock, flags);
tty->read_tail = (tty->read_tail + n) & (N_TTY_BUF_SIZE-1); tty->read_tail = (tty->read_tail + n) & (N_TTY_BUF_SIZE-1);
tty->read_cnt -= n; tty->read_cnt -= n;
......
...@@ -23,7 +23,7 @@ struct tty_audit_buf { ...@@ -23,7 +23,7 @@ struct tty_audit_buf {
}; };
static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor, static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor,
int icanon) unsigned icanon)
{ {
struct tty_audit_buf *buf; struct tty_audit_buf *buf;
...@@ -239,7 +239,8 @@ int tty_audit_push_task(struct task_struct *tsk, kuid_t loginuid, u32 sessionid) ...@@ -239,7 +239,8 @@ int tty_audit_push_task(struct task_struct *tsk, kuid_t loginuid, u32 sessionid)
* if TTY auditing is disabled or out of memory. Otherwise, return a new * if TTY auditing is disabled or out of memory. Otherwise, return a new
* reference to the buffer. * reference to the buffer.
*/ */
static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty) static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty,
unsigned icanon)
{ {
struct tty_audit_buf *buf, *buf2; struct tty_audit_buf *buf, *buf2;
...@@ -257,7 +258,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty) ...@@ -257,7 +258,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty)
buf2 = tty_audit_buf_alloc(tty->driver->major, buf2 = tty_audit_buf_alloc(tty->driver->major,
tty->driver->minor_start + tty->index, tty->driver->minor_start + tty->index,
tty->icanon); icanon);
if (buf2 == NULL) { if (buf2 == NULL) {
audit_log_lost("out of memory in TTY auditing"); audit_log_lost("out of memory in TTY auditing");
return NULL; return NULL;
...@@ -287,7 +288,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty) ...@@ -287,7 +288,7 @@ static struct tty_audit_buf *tty_audit_buf_get(struct tty_struct *tty)
* Audit @data of @size from @tty, if necessary. * Audit @data of @size from @tty, if necessary.
*/ */
void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
size_t size) size_t size, unsigned icanon)
{ {
struct tty_audit_buf *buf; struct tty_audit_buf *buf;
int major, minor; int major, minor;
...@@ -299,7 +300,7 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, ...@@ -299,7 +300,7 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
&& tty->driver->subtype == PTY_TYPE_MASTER) && tty->driver->subtype == PTY_TYPE_MASTER)
return; return;
buf = tty_audit_buf_get(tty); buf = tty_audit_buf_get(tty, icanon);
if (!buf) if (!buf)
return; return;
...@@ -307,11 +308,11 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, ...@@ -307,11 +308,11 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
major = tty->driver->major; major = tty->driver->major;
minor = tty->driver->minor_start + tty->index; minor = tty->driver->minor_start + tty->index;
if (buf->major != major || buf->minor != minor if (buf->major != major || buf->minor != minor
|| buf->icanon != tty->icanon) { || buf->icanon != icanon) {
tty_audit_buf_push_current(buf); tty_audit_buf_push_current(buf);
buf->major = major; buf->major = major;
buf->minor = minor; buf->minor = minor;
buf->icanon = tty->icanon; buf->icanon = icanon;
} }
do { do {
size_t run; size_t run;
......
...@@ -535,7 +535,7 @@ extern void n_tty_inherit_ops(struct tty_ldisc_ops *ops); ...@@ -535,7 +535,7 @@ extern void n_tty_inherit_ops(struct tty_ldisc_ops *ops);
/* tty_audit.c */ /* tty_audit.c */
#ifdef CONFIG_AUDIT #ifdef CONFIG_AUDIT
extern void tty_audit_add_data(struct tty_struct *tty, unsigned char *data, extern void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
size_t size); size_t size, unsigned icanon);
extern void tty_audit_exit(void); extern void tty_audit_exit(void);
extern void tty_audit_fork(struct signal_struct *sig); extern void tty_audit_fork(struct signal_struct *sig);
extern void tty_audit_tiocsti(struct tty_struct *tty, char ch); extern void tty_audit_tiocsti(struct tty_struct *tty, char ch);
...@@ -544,7 +544,7 @@ extern int tty_audit_push_task(struct task_struct *tsk, ...@@ -544,7 +544,7 @@ extern int tty_audit_push_task(struct task_struct *tsk,
kuid_t loginuid, u32 sessionid); kuid_t loginuid, u32 sessionid);
#else #else
static inline void tty_audit_add_data(struct tty_struct *tty, static inline void tty_audit_add_data(struct tty_struct *tty,
unsigned char *data, size_t size) unsigned char *data, size_t size, unsigned icanon)
{ {
} }
static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch) static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment