Received: by 10.213.65.68 with SMTP id h4csp686917imn; Fri, 6 Apr 2018 07:18:53 -0700 (PDT) X-Google-Smtp-Source: AIpwx49FKe5ApBVe4CndoIrpllHs75TuVKotjJztHsdZKOf19eF7ugCW2oY1f8cwF2EPxnR1oBYr X-Received: by 2002:a17:902:bf03:: with SMTP id bi3-v6mr20412834plb.392.1523024333716; Fri, 06 Apr 2018 07:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523024333; cv=none; d=google.com; s=arc-20160816; b=UdA885DqIBVC89QmYVIqbNbJFL6qWXxI2GRDEBEeR+aHryFNsf85R6i853u65Xa2O5 +b/R+4e1HTj0d6X/nMUZfYrnPZlhxr3hDQiYwMuC85vtD7IsrhiF3AqLakTNIueDz01e Chv8hO84VSlxtfQi932bI0+WszuL4Zh1YbvNIkEzPwfBr+ctI4jZpk1PJ6l35yiOZqrz pU5s99P2056UUFERcQr4yAtaEuWyna/bk5oxMtpJGs30LYtnJmQthtY78Lo1HLbc0RCT 3UeXf/1PEYPVDSshq8endEPHtzpyhPFHtknxoWRWBmVPBz9xgLc1faMJ9DZ0Xl8WQZgS h5BA== 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=F1htOeUtAeiZB/Fxfu/0mBIeTuhHZmIf/S6cC1C6kE8=; b=teSWwesBArornByRcxe4Hg7M+07RSM8s2VtryjeMcC2MaWS8+YrtJ/wDpA+MuhWTZ7 ECDGrIJZ10SYfiSEyYtMFWn6/+3afBYS/ui9wgT4+YI143cF/REX4sN1aiEFzrNH5MCn ejFk9nDCwHy1/KLtzmOvYdjclST4bq8rd7L5y40z5QxBPfM8SlD/DPDFFZkcm5vo0K6G F3e/oPzhpaBbUYwYXFu9zZ9/uPxK1RlGyeywDl8iYKRRHwI1gVvaW7oW9Ry1Ur8DHxCv M8c94XWSfq8+OamNE9gSJBlQw7CP4EEsIeObT8B9x1twvQ2naUu9Jl9odIhspPe19dxf wpjQ== 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 s16-v6si8019786plp.113.2018.04.06.07.18.39; Fri, 06 Apr 2018 07:18:53 -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 S1756532AbeDFOR1 (ORCPT + 99 others); Fri, 6 Apr 2018 10:17:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34224 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932558AbeDFNjI (ORCPT ); Fri, 6 Apr 2018 09:39:08 -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 1DD76D66; Fri, 6 Apr 2018 13:39:06 +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.14 44/67] media: usbtv: prevent double free in error case Date: Fri, 6 Apr 2018 15:24:14 +0200 Message-Id: <20180406084347.207654052@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180406084341.225558262@linuxfoundation.org> References: <20180406084341.225558262@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.14-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: