Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9965833ybi; Wed, 24 Jul 2019 13:11:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQ55AkQ/6l0oHsHef10f/Daicc0M2blo3dFbPvzetmLNN9Ja4uGdaz4T8sZhyShGnLuHyA X-Received: by 2002:a62:be04:: with SMTP id l4mr12561659pff.77.1563999083827; Wed, 24 Jul 2019 13:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563999083; cv=none; d=google.com; s=arc-20160816; b=A7fgQrwfgtLsEW4GxIXjUro3zgHW6WYkh03ebvcx6O7y3/lFXGX2aMzUrCVn2Q9WW/ tZYPlhcyApXoxwuPG2tI9xYWg1biGL/yUobHvAL4lTKXElr+Bs7XolM89SYY5rOJnQOg vQ9GkmTNMAu+UTg5MoJBb+fIZadZYEuPqXG4ehAjgrmvd4A1ia1zA0QdPAs3Jh+MsDiO T/xMYdHfVh4OXN1hR9jOyFFYRz1cD8fGukJ2ResibnzIdNcaKkCC0jhsIQtNrA+4yQq3 vT0x+yBU72JlSAf4Y/ykTaMPTR+j1mmj22K8evP69fequadR09YRXKksSPk6Q0MLpRcj voVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jo3ooFImTNE8pMdyalqzal+aTikPHlWPWeQlfZm/voE=; b=NKK/LDgixqFBV3cHY3Qbh1XoAM3LimT096bjphoBoQ1sJ89L+doeWOLI7fanF+NQqE 2Tz1evQCsjpnr+0L+D3nyNRD3Xa3k0GK3mfky9XCFRQMNirdJXhhQhntZsjEOMP1P1xy EHkLlXy8n5hGuJNS85limfCTWOrHuxdhUzjeVJ69G8WE+JT9iWCobWkQCuvQKXkQu2jk S5hu9TpyAqi8TF3YQIpZlXYylA1+0/+/BreWYph7uFSFcTizJaDW7hv2sPKv4QiAKWhp W8LB1s6U1AM/ox01fz1PlvWphwLG9sdtafmt88y3zoAgZv9/Af87MJyVEXKG2eP61f8j Dd8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sYP7ssWs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si15769017pll.82.2019.07.24.13.11.08; Wed, 24 Jul 2019 13:11:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sYP7ssWs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392641AbfGXUIs (ORCPT + 99 others); Wed, 24 Jul 2019 16:08:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:50696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392090AbfGXUBi (ORCPT ); Wed, 24 Jul 2019 16:01:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6FF3521852; Wed, 24 Jul 2019 20:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998497; bh=F6pGKXthEOlJuWDsVRH/bpa9bLWLbmO/grk/l3FiRUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sYP7ssWsce7UZf3MZ1vqB2JjFAYk8MzTS2RoQ3plVUkV9L1L0xJITfLGNjlmImD40 H1VRnxMtL61dw1/1uyOF3y4zydoBYuXpp8ZY3V0qZ/brirFJhoQ1jNUze2ul1TEoW0 /bpD/98p/eWoF8rfGem/yuiwEZk6uOBWoI8aVGhA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , syzbot+26ec41e9f788b3eba396@syzkaller.appspotmail.com, Sean Young , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 015/271] media: dvb: usb: fix use after free in dvb_usb_device_exit Date: Wed, 24 Jul 2019 21:18:04 +0200 Message-Id: <20190724191656.565132068@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 6cf97230cd5f36b7665099083272595c55d72be7 ] dvb_usb_device_exit() frees and uses the device name in that order. Fix by storing the name in a buffer before freeing it. Signed-off-by: Oliver Neukum Reported-by: syzbot+26ec41e9f788b3eba396@syzkaller.appspotmail.com Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/dvb-usb/dvb-usb-init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c index 40ca4eafb137..39ac22486bcd 100644 --- a/drivers/media/usb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c @@ -287,12 +287,15 @@ EXPORT_SYMBOL(dvb_usb_device_init); 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"; + const char *default_name = "generic DVB-USB module"; + char name[40]; usb_set_intfdata(intf, NULL); if (d != NULL && d->desc != NULL) { - name = d->desc->name; + strscpy(name, d->desc->name, sizeof(name)); dvb_usb_exit(d); + } else { + strscpy(name, default_name, sizeof(name)); } info("%s successfully deinitialized and disconnected.", name); -- 2.20.1