Skip to contentSkip to conversation

tty: fix memory leak in vc_deallocate

PATCH In review Pavel Skripkin 2 participants 3 messages Mar 27, 2021 – Mar 28, 2021 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tty: fix memory leak in vc_deallocate

syzbot reported memory leak in tty/vt.
The problem was in VT_DISALLOCATE ioctl cmd. After allocating unimap with PIO_UNIMAP it wasn't freed via VT_DISALLOCATE, but vc_cons[currcons].d was zeroed.

---
 drivers/tty/vt/vt.c | 1 +
 1 file changed, 1 insertion(+)
drivers/tty/vt/vt.c +1 -0
index 284b07224c55..0cc360da5426 100644
@@ -1381,6 +1381,7 @@ struct vc_data *vc_deallocate(unsigned int currcons)
 		atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, &param);
 		vcs_remove_sysfs(currcons);
 		visual_deinit(vc);
+		con_free_unimap(vc);
 		put_pid(vc->vt_pid);
 		vc_uniscr_set(vc, NULL);
 		kfree(vc->vc_screenbuf);
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 11 lines · Pavel Skripkin

syzbot reported memory leak in tty/vt.
The problem was in VT_DISALLOCATE ioctl cmd. After allocating unimap with PIO_UNIMAP it wasn't freed via VT_DISALLOCATE, but vc_cons[currcons].d was zeroed.

---
 drivers/tty/vt/vt.c | 1 +
 1 file changed, 1 insertion(+)

Is this patch tested by syzbot to fix the problem?

thanks,

greg k-h

#2 lore raw

Hi!

Quoted 7 lines · Greg KH
Quoted 6 lines · Pavel Skripkin

syzbot reported memory leak in tty/vt.
The problem was in VT_DISALLOCATE ioctl cmd. After allocating unimap with PIO_UNIMAP it wasn't freed via VT_DISALLOCATE, but vc_cons[currcons].d was zeroed.

Quoted 8 lines
Quoted 5 lines

---
 drivers/tty/vt/vt.c | 1 +

 1 file changed, 1 insertion(+)

Is this patch tested by syzbot to fix the problem?

Yeah, it's tested.
https://syzkaller.appspot.com/bug?id=083cb8bd8468537151a57339ae72d505bb5bded0

Quoted 3 lines

thanks,

greg k-h

Signature · 2 lines
With regards,
Pavel Skripkin