Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3957970ybi; Mon, 29 Jul 2019 16:14:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYTL18fhu5mhnMn0Y4KhNkINPsmThG0uoOySGoMm6ZP2ywQ43Ov+KzXpvre7azvQbOZQ/P X-Received: by 2002:a63:3009:: with SMTP id w9mr32638976pgw.260.1564442047149; Mon, 29 Jul 2019 16:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564442047; cv=none; d=google.com; s=arc-20160816; b=CRHEzNKXfYUhlRFDefR48hUAZLiraaH/SfDYNaYK4bOsHJrhUzdMiKC3gM3PmJGSHM uzrHurpDIabTRpl/rWxtFnv2cCMO4xvV48OK4riDK1TgCX15e9X+JpgguqQv+Fbg1XKC 8AoGXZre1tQR79zC76DzHbZfth4fTrGfcRG7UcScFjQLZdAMUiunXWDcdTKErRPzoqHK 5x38tq50YQ2gq5s0YFZggMj3XHyzfpqfTDBdc0uAzl/haVdUj3qNQiHYcOSRolX9nzdA 1wLLLOay/OMFgzWsaEu2ubqkhQrN+tCirkoTqa6mWrdcVNwRZiOT4xG0qu/fOFKO9L/j CwrA== 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=1elgtI9uM+ZkqgCmqgrIPOaLvLaYSI2hanymy9girzA=; b=hCAY6yrIRr+pwvdnmnvPs92AefZ3/eFHQhfv6bl5bb5UJbevI/kx8y9AMMFISNSOqJ wqU6/0u5uoD6CTiT2iwj12Ifb3ifpIcPkvQOVwOaYP39CtOPG68muwDtbr/X1vUHYw8y 3PrXX8/R6I+GgYc5f7m6OgwtEYtIfrv8q7zh9nn0jZ3NnK+ISNk6wzU/CrtjqE7gJT4k o8dTcjvootRMG85stHvSBnmbiQ56mdAE2Sz7JvdjzQlKNpt1Uv6lDAEG9aUX7c7rxASe 5CdSgmFMLsPtUCH1aJq/bAB+fnEhe7f3j11MmngEF664bJbuOIWy2naFjBBjmbj4cmd7 4fpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wyCD2tp+; 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 j23si28233466pgh.535.2019.07.29.16.13.14; Mon, 29 Jul 2019 16:14:07 -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=wyCD2tp+; 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 S2387842AbfG2TX6 (ORCPT + 99 others); Mon, 29 Jul 2019 15:23:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:36082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727699AbfG2TXz (ORCPT ); Mon, 29 Jul 2019 15:23:55 -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 77C4121655; Mon, 29 Jul 2019 19:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428234; bh=4WRnDc6ccVf1F9VSDNYejaU+jEuRvyZ28WXLUbFz+a0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wyCD2tp+aKPdT4mYkYGkwK8dZKwoo77twCh1WF3FMfT5MMWj/uGXjarQzXjee47kc xR5CvrUUTuSy5MqWZ26nl/hXzR52HdRf1Q1r78M//mzoVUdM2HvBz2OIpSQfeGYr8S +OITFSTreOC3iLPBUcQjTJDGVl6ScG5s92nL3chE= 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.14 012/293] media: dvb: usb: fix use after free in dvb_usb_device_exit Date: Mon, 29 Jul 2019 21:18:23 +0200 Message-Id: <20190729190821.308769253@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 84308569e7dc..b3413404f91a 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