]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tty: audit: do not use N_TTY_BUF_SIZE
authorJiri Slaby (SUSE) <jirislaby@kernel.org>
Mon, 17 Mar 2025 07:00:17 +0000 (08:00 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Mar 2025 15:00:50 +0000 (08:00 -0700)
N_TTY_BUF_SIZE -- as the name suggests -- is the N_TTY's buffer size.
There is no reason to couple that to audit's buffer size, so define an
own TTY_AUDIT_BUF_SIZE macro (with the same size).

N_TTY_BUF_SIZE is private and will be moved to n_tty.c later.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20250317070046.24386-3-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/tty_audit.c

index 1d81eeefb06842b84ea9949bf7d4884a6c9f2dca..75542333c54aa04370d3f81c3755f86a5dca3620 100644 (file)
 #include <linux/tty.h>
 #include "tty.h"
 
+#define TTY_AUDIT_BUF_SIZE     4096
+
 struct tty_audit_buf {
        struct mutex mutex;     /* Protects all data below */
        dev_t dev;              /* The TTY which the data is from */
        bool icanon;
        size_t valid;
-       u8 *data;               /* Allocated size N_TTY_BUF_SIZE */
+       u8 *data;               /* Allocated size TTY_AUDIT_BUF_SIZE */
 };
 
 static struct tty_audit_buf *tty_audit_buf_ref(void)
@@ -37,7 +39,7 @@ static struct tty_audit_buf *tty_audit_buf_alloc(void)
        if (!buf)
                goto err;
 
-       buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL);
+       buf->data = kmalloc(TTY_AUDIT_BUF_SIZE, GFP_KERNEL);
        if (!buf->data)
                goto err_buf;
 
@@ -235,14 +237,14 @@ void tty_audit_add_data(const struct tty_struct *tty, const void *data,
        do {
                size_t run;
 
-               run = N_TTY_BUF_SIZE - buf->valid;
+               run = TTY_AUDIT_BUF_SIZE - buf->valid;
                if (run > size)
                        run = size;
                memcpy(buf->data + buf->valid, data, run);
                buf->valid += run;
                data += run;
                size -= run;
-               if (buf->valid == N_TTY_BUF_SIZE)
+               if (buf->valid == TTY_AUDIT_BUF_SIZE)
                        tty_audit_buf_push(buf);
        } while (size != 0);
        mutex_unlock(&buf->mutex);