lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 20 Jun 2021 23:23:17 +0300
From:   Pavel Skripkin <paskripkin@...il.com>
To:     mchehab@...nel.org, tomimo@...rcle.nullnet.fi,
        thierry.merle@...e.fr
Cc:     linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-kernel-mentees@...ts.linuxfoundation.org,
        Pavel Skripkin <paskripkin@...il.com>
Subject: [PATCH] media: dvb-usb: fix memory leak in cinergyt2_frontend_attach

My local syzbot instance hit a memory leak in
cinergyt2_frontend_attach() [1].

The problem was in non-freed dvb_frontend in case of error.
If dvb_usb_generic_rw() call fails, an error will be returned from
cinergyt2_frontend_attach() [1] and num_adapters_initialized of
dvb_usb_device won't be incremented. That means dvb usb library
won't take care of freeing allocated frontend.

Fail log:
BUG: memory leak
unreferenced object 0xffff88801d9c6000 (size 2048):
  comm "kworker/1:3", pid 2960, jiffies 4295150569 (age 17.150s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 54 65 72 72 61 54 65 63  ........TerraTec
    2f 71 61 6e 75 20 55 53 42 32 2e 30 20 48 69 67  /qanu USB2.0 Hig
  backtrace:
    [<ffffffff85e169f0>] kmalloc include/linux/slab.h:556 [inline]
    [<ffffffff85e169f0>] kzalloc include/linux/slab.h:686 [inline]
    [<ffffffff85e169f0>] cinergyt2_fe_attach+0x40/0x110 drivers/media/usb/dvb-usb/cinergyT2-fe.c:271
    [<ffffffff85e15b31>] cinergyt2_frontend_attach+0x61/0x140 drivers/media/usb/dvb-usb/cinergyT2-core.c:74 [1]
    [<ffffffff85dcd71e>] dvb_usb_adapter_frontend_init+0x35e/0x5b0 drivers/media/usb/dvb-usb/dvb-usb-dvb.c:290
    [<ffffffff88f98e83>] dvb_usb_adapter_init drivers/media/usb/dvb-usb/dvb-usb-init.c:90 [inline]
    [<ffffffff88f98e83>] dvb_usb_init drivers/media/usb/dvb-usb/dvb-usb-init.c:184 [inline]

Fixes: 986bd1e58b18 ("V4L/DVB (9107): Alternative version of Terratec Cinergy T2
driver")
Signed-off-by: Pavel Skripkin <paskripkin@...il.com>
---
 drivers/media/usb/dvb-usb/cinergyT2-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/dvb-usb/cinergyT2-core.c b/drivers/media/usb/dvb-usb/cinergyT2-core.c
index 969a7ec71dff..fb60af097535 100644
--- a/drivers/media/usb/dvb-usb/cinergyT2-core.c
+++ b/drivers/media/usb/dvb-usb/cinergyT2-core.c
@@ -79,6 +79,7 @@ static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap)
 	ret = dvb_usb_generic_rw(d, st->data, 1, st->data, 3, 0);
 	if (ret < 0) {
 		deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep state info\n");
+		kfree(adap->fe_adap[0].fe);
 	}
 	mutex_unlock(&d->data_mutex);
 
-- 
2.32.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ