Skip to contentSkip to conversation

memcg: accounting for tty_struct objects

PATCH In review Vasily Averin 1 participant 1 message Mar 9, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 8/9 memcg: accounting for tty_struct objects

Objects can be created from memcg-limited tasks
but its misuse may lead to host OOM.

---
 drivers/tty/tty_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/tty_io.c +2 -2
index 74733ec..a3b881b 100644
@@ -1503,7 +1503,7 @@ void tty_save_termios(struct tty_struct *tty)
 	/* Stash the termios data */
 	tp = tty->driver->termios[idx];
 	if (tp == NULL) {
-		tp = kmalloc(sizeof(*tp), GFP_KERNEL);
+		tp = kmalloc(sizeof(*tp), GFP_KERNEL_ACCOUNT);
 		if (tp == NULL)
 			return;
 		tty->driver->termios[idx] = tp;
@@ -3128,7 +3128,7 @@ struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
 {
 	struct tty_struct *tty;
 
-	tty = kzalloc(sizeof(*tty), GFP_KERNEL);
+	tty = kzalloc(sizeof(*tty), GFP_KERNEL_ACCOUNT);
 	if (!tty)
 		return NULL;
 
Signature · 1 line
1.8.3.1