Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: audit: do not use N_TTY_BUF_SIZE

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>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
ec1132dd a72f4187

+6 -4
+6 -4
drivers/tty/tty_audit.c
··· 12 12 #include <linux/tty.h> 13 13 #include "tty.h" 14 14 15 + #define TTY_AUDIT_BUF_SIZE 4096 16 + 15 17 struct tty_audit_buf { 16 18 struct mutex mutex; /* Protects all data below */ 17 19 dev_t dev; /* The TTY which the data is from */ 18 20 bool icanon; 19 21 size_t valid; 20 - u8 *data; /* Allocated size N_TTY_BUF_SIZE */ 22 + u8 *data; /* Allocated size TTY_AUDIT_BUF_SIZE */ 21 23 }; 22 24 23 25 static struct tty_audit_buf *tty_audit_buf_ref(void) ··· 39 37 if (!buf) 40 38 goto err; 41 39 42 - buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 40 + buf->data = kmalloc(TTY_AUDIT_BUF_SIZE, GFP_KERNEL); 43 41 if (!buf->data) 44 42 goto err_buf; 45 43 ··· 237 235 do { 238 236 size_t run; 239 237 240 - run = N_TTY_BUF_SIZE - buf->valid; 238 + run = TTY_AUDIT_BUF_SIZE - buf->valid; 241 239 if (run > size) 242 240 run = size; 243 241 memcpy(buf->data + buf->valid, data, run); 244 242 buf->valid += run; 245 243 data += run; 246 244 size -= run; 247 - if (buf->valid == N_TTY_BUF_SIZE) 245 + if (buf->valid == TTY_AUDIT_BUF_SIZE) 248 246 tty_audit_buf_push(buf); 249 247 } while (size != 0); 250 248 mutex_unlock(&buf->mutex);