Received: by 10.213.65.68 with SMTP id h4csp706656imn; Fri, 6 Apr 2018 07:35:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx48SavoUdMcP+JrBJfhy9mUSP+YkbdSAOHAWox/E8aSrGZXAHdSvW9k40NOoC3+Ic4eLRthf X-Received: by 10.99.147.25 with SMTP id b25mr18066574pge.309.1523025346727; Fri, 06 Apr 2018 07:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523025346; cv=none; d=google.com; s=arc-20160816; b=c7U6Iq8K6Dyn3ltBQizbwplr8zc4EfmWmIm3RCMSD3eEh/e5hix0zw9Ped+gjHz8hL fOf1U3VXMNdm0eMiJYFN96rOH/8rjlVmFfjlx+tA3DHjQaQp9rk6YgZZIz/ljLDhtO66 +HlP1Rj+96xavHkG/vb5/w6WQcts8JzHfY1EwykHvNUs0aktgilRiNrb5X1bTcY0JQHO MbK+0CCxUJGAY49zh1aJ8octH9DPGBSZTizAdatz1x6Y78WLSUP+2wrqqIyF5TeqDkgm GCv2TKgZMcxxgtkUG0X+6vkjC+BzMXSxe7ZIOwDTyX0kBJyzqUiiyZ0Uvo6QZ3N17m/0 q+QQ== 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=0jCAW01MRQnETiWDAj3ipy/incCS9SPKpzpc58SNTis=; b=m58xCZVc5nPFyTWN0G8NuKzlM+YGp4yMen0d1BgBpQOJl+pektU2c+BL5O1dPEy2Pi /Qyeatx5QywGoJ4RAYk3FOWXJhDhn6nXGR7i3cRW5crHkFzfxDNuPPz6eb00U2/coNAa BRBeQnDNATksW1h7UQrrxp0XvueWG5apdv8QkRFzE1Kj34abChR918IEaBVbW5Is7x8S BU341p961EuVESzXRu5DWVMEEhZSkZhIV2S5o993x2qmVaZWBQpx5tr7KXlF86+vl/P6 FbqME7hqm1NpdWS6hexl7VKIF2MlhPHcKNOEjXIsHtvSWhh3Jnn/iHYKAULXWIyOp5hS Bd8Q== 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 a1si8094433pfb.415.2018.04.06.07.35.32; Fri, 06 Apr 2018 07:35:46 -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 S1756139AbeDFNgB (ORCPT + 99 others); Fri, 6 Apr 2018 09:36:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59022 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752816AbeDFNf6 (ORCPT ); Fri, 6 Apr 2018 09:35:58 -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 D760ADC5; Fri, 6 Apr 2018 13:35:57 +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.9 081/102] media: usbtv: prevent double free in error case Date: Fri, 6 Apr 2018 15:24:02 +0200 Message-Id: <20180406084342.882386215@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084331.507038179@linuxfoundation.org> References: <20180406084331.507038179@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.9-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 @@ -109,6 +109,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: