From patchwork Tue Apr 30 10:43:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 10923185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEF2E92A for ; Tue, 30 Apr 2019 10:44:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAA6B285A1 for ; Tue, 30 Apr 2019 10:44:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CED54289DC; Tue, 30 Apr 2019 10:44:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 765DE285A1 for ; Tue, 30 Apr 2019 10:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726793AbfD3KoT (ORCPT ); Tue, 30 Apr 2019 06:44:19 -0400 Received: from mx2.suse.de ([195.135.220.15]:55322 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726294AbfD3KoT (ORCPT ); Tue, 30 Apr 2019 06:44:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4CFCAAD7C; Tue, 30 Apr 2019 10:44:18 +0000 (UTC) From: Oliver Neukum To: mchehab@kernel.org, linux-media@vger.kernel.org Cc: Oliver Neukum Subject: [PATCHv2] dvb: usb: fix use after free in dvb_usb_device_exit Date: Tue, 30 Apr 2019 12:43:58 +0200 Message-Id: <20190430104358.8526-1-oneukum@suse.com> X-Mailer: git-send-email 2.16.4 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dvb_usb_device_exit() frees and uses the device name in that order Fix by storing the name in a buffer before freeing it v2: fixed style issues Signed-off-by: Oliver Neukum Reported-by: syzbot+26ec41e9f788b3eba396@syzkaller.appspotmail.com --- drivers/media/usb/dvb-usb/dvb-usb-init.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c index 99951e02a880..959bbdad8f00 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c @@ -288,13 +288,18 @@ void dvb_usb_device_exit(struct usb_interface *intf) { struct dvb_usb_device *d = usb_get_intfdata(intf); const char *name = "generic DVB-USB module"; + char identifier[40]; usb_set_intfdata(intf, NULL); if (d != NULL && d->desc != NULL) { name = d->desc->name; + memcpy(identifier, name, 39); + identifier[39] = 0; dvb_usb_exit(d); + } else { + memcpy(identifier, name, 39); } - info("%s successfully deinitialized and disconnected.", name); + info("%s successfully deinitialized and disconnected.", identifier); } EXPORT_SYMBOL(dvb_usb_device_exit);