Received: by 10.213.65.68 with SMTP id h4csp651854imn; Fri, 6 Apr 2018 06:48:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx48/QZJYb32c8bZuNmT8vz67XINQdi4Wcu6rsShjVr65xEaMnvM1ezT2JBIMuF2AGxgQ1reZ X-Received: by 10.101.83.199 with SMTP id z7mr13199011pgr.165.1523022494995; Fri, 06 Apr 2018 06:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523022494; cv=none; d=google.com; s=arc-20160816; b=Us79iACXSs+zWKlCBjIhJG1WsHX0UEdesIu6chscyq1Le4/yBWf7Mf+EyMZeOI2FdR 3/2z3T4BtQv9Z2MGrvO1RUi86Y+vhLds022kBLQDfEYJr+c3KOopRcfxL2rTCX2hmM4/ JTTzN0yfE6FVLjCRNvUFukA+fN2qXcpkVON0d4Ywo70tWB1JbL0Coo5gQ7zmrY2R+wUL PbUqEQ5VXTzqOC2nyAgP7txs+RZ83N52xfqDPciWE4WBJLm6h7pG/Od3ef0ZMDxW+hfu XSNfsC7KhRWfVccgF1sM//44sQyYBe+/WRYr6+G/NlSkFMbVCI4KYangUlUa18zOndnZ 56gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=p7GEUVNemgADW2PR8896eh3cqeEEeZE3cq47+HHY6P4=; b=SPeH385r+yNjUgqEoKhEDlIsnK2Kz8c5EXLBDrZprDkkncH7i+ojSPFCVgfVwG2Fob pwlOxmWtvXXgCZ7pdHP7K4r4MxSzJkC8SShvSobtkvAAGfyEVJSke49Ac8g1ldma10Ej pqPR4S5mxnqeyYkNAbgoUTND49lqJicRkVh2ahrGGkiUKfXSpv0PbYs6RKClf3+I6wCV y/I3tNF+tPpbOtChePwmalWI7fNO3MVIGX8ExqTg9WsM31Hvp4clwEOp9kxN60dYXBN2 57iw+VryJzgMUipjusSgr49g5Pv08l6uCTm/DkOEUMTRMysAAeow7Mb9d/A5aFaeTPh8 jVNw== ARC-Authentication-Results: i=1; mx.google.com; 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 x8-v6si7876644plv.420.2018.04.06.06.48.00; Fri, 06 Apr 2018 06:48:14 -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; 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 S933096AbeDFNph (ORCPT + 99 others); Fri, 6 Apr 2018 09:45:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38134 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933082AbeDFNpe (ORCPT ); Fri, 6 Apr 2018 09:45:34 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E043DE25; Fri, 6 Apr 2018 13:45:33 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Yavuz, Tuba" , Oliver Neukum , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 4.16 08/31] media: usbtv: prevent double free in error case Date: Fri, 6 Apr 2018 15:24:33 +0200 Message-Id: <20180406084342.178292706@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084340.999820380@linuxfoundation.org> References: <20180406084340.999820380@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oliver Neukum commit 50e7044535537b2a54c7ab798cd34c7f6d900bd2 upstream. Quoting the original report: It looks like there is a double-free vulnerability in Linux usbtv driver on an error path of usbtv_probe function. When audio registration fails, usbtv_video_free function ends up freeing usbtv data structure, which gets freed the second time under usbtv_video_fail label. usbtv_audio_fail: usbtv_video_free(usbtv); => v4l2_device_put(&usbtv->v4l2_dev); => v4l2_device_put => kref_put => v4l2_device_release => usbtv_release (CALLBACK) => kfree(usbtv) (1st time) usbtv_video_fail: usb_set_intfdata(intf, NULL); usb_put_dev(usbtv->udev); kfree(usbtv); (2nd time) So, as we have refcounting, use it Reported-by: Yavuz, Tuba Signed-off-by: Oliver Neukum CC: stable@vger.kernel.org Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/usbtv/usbtv-core.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/media/usb/usbtv/usbtv-core.c +++ b/drivers/media/usb/usbtv/usbtv-core.c @@ -112,6 +112,8 @@ static int usbtv_probe(struct usb_interf return 0; usbtv_audio_fail: + /* we must not free at this point */ + usb_get_dev(usbtv->udev); usbtv_video_free(usbtv); usbtv_video_fail: