Received: by 10.213.65.68 with SMTP id h4csp664991imn; Fri, 6 Apr 2018 07:01:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/pmx+w1jlaT/8e2HSouwLItSST91p6luhMEQ0q8+Rw5wZLZDcOb4wb88PdN7fgZBZMHXzi X-Received: by 10.98.89.200 with SMTP id k69mr20802831pfj.100.1523023262514; Fri, 06 Apr 2018 07:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523023262; cv=none; d=google.com; s=arc-20160816; b=b/IQK9Y9ZxlASOD8WDfSGgQUIoLDvdJh0vvTXNpkJv5HwW4st2nuv59UoioTfA/HPR 0I5zHNNHxKXTrk6uJvuDCSsWyzk3weHnS46uf5gLZRi17ROFpzjpVbwiYuKpBjs/kNuS rXiPSEnXK7GdBbBwy7LSbnY09DAjhcX8wG0ePIXCK2xTd/J1pBWqQjvN8xyAQT3Ye/Cd ksJLA959p8fUFxUJA+fh9TLon69mYnGHbeONFEfOUpdN1VvUpv6WldZ4zuaoQy+yilAW eCYQeETBuzn2OdcK+/xu3AJ7NYhpndlA/AL06VlUs1GLTnbvANmQ8X5iJZ4A1RyfJu/N WnSg== 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=dPWEFRWw/iST29T6ryeYzoYL8mU3X6dUuTys2avpZjM=; b=i+OSwCSRkTuAqJcGM/6MEfiGavXmmYqWoQ/a1fB+zgx38HkPKnnPwthhLRAsbyiqqS +DKUWVTWiyTZ/dRUSuQll7n9cz+R/rv6CgaI82oM9eWtPpQM3fR07Pxwcv2DZIwe9VgR mMkgyvSwft+FL22eBPPPngY/wjXR99e0L8c52Wo7qqZ7iu1hZKgAy0Hg9pwLTKQiAaee OJ9K5AXfoVPP6nULVBfU2xg4AJ6IEoeKMIlBPASvdteWLLkMitjbguhQZnUAUbtXJCaQ OxV0Hv5xpQ+ISY0gjaHqnlBHrqx8mW+gyueQaQ/OkxDhcMtS5W0gC4wlse46jee++jX7 nsuA== 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 z22-v6si8523501plo.270.2018.04.06.07.00.48; Fri, 06 Apr 2018 07:01:02 -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 S1756272AbeDFN7o (ORCPT + 99 others); Fri, 6 Apr 2018 09:59:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37058 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756617AbeDFNmi (ORCPT ); Fri, 6 Apr 2018 09:42:38 -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 1404DDB5; Fri, 6 Apr 2018 13:42:37 +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.15 47/72] media: usbtv: prevent double free in error case Date: Fri, 6 Apr 2018 15:24:22 +0200 Message-Id: <20180406084352.843302321@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084349.367583460@linuxfoundation.org> References: <20180406084349.367583460@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.15-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: