Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1331087ybp; Thu, 17 Oct 2019 11:10:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqymbSWkta6LSZFryLmZs2PtApOpQGkZl6u6XqJzPQt+umTG2bYTbUEu3Y9gzC2CpYId5rmA X-Received: by 2002:a17:906:2584:: with SMTP id m4mr4832335ejb.287.1571335802044; Thu, 17 Oct 2019 11:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571335802; cv=none; d=google.com; s=arc-20160816; b=dd5xKyiEy1OsQLSqisEN15wzpjP308rw01qjGiZ3ux7/e0zZR1cgHOi6AAEOtL9nOS fNADSQeg9uQWdE0zl4UZEooQvwpDpO/juBXpg1cgktGp8tIP1pWfWteeAu1cjiDkQWwQ gBFZnSvAutWn6grWZlyXSidpsxQcDx+zmezW8F/TjGz3z1o1E9uwd91ad2HaHXV1ROIA 6tBv/pWov0IFrZFLusfFA+tH9gwHEkLsHj7Wyncbmq6YMY3eqT60arM2W6FVcJe4TDGD WYU6ncKoMY7mTHGmVbxnfVctfv1l1ICS1p+YX04e4MHkxeFFLCBjz1ZCusoBouIcyBxy d+LA== 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=Xvvuk6sylHphkNDAjfQKHIR82dX5MqqA07nufClKNXM=; b=IbtrAPRS8DiM2dWG++H3HxzVjRa1x2eG5lTtrgFUdwR68JyW0xLZjIPuxzJvJCyxjo 2q6x0E7sE2HkyrjAIekovTBCZggjFjqCQnOO//1XJZG2+KRjjwAMbGAAn+WVmYCSzgRp LzeSoJNcHmxWuqKqBK1tZ2OLqbtbdSqtyQ29scfsNknO896GvWbqzpJ9pYlinfkgEyog K79HivIHuVjcrdMHBGjticzS/PWM56lek/zsoABeQjVRrkSXb1063IVvKFTocj9ER6SC ahh6A1sGkVgvrU8L8jQ0vSmefSnKaXlQE4V3+qge/7H7MSnlI6xcSj4pVkSpNqf+1Rg+ kcew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a8INY40G; 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 h3si2073853edh.372.2019.10.17.11.09.38; Thu, 17 Oct 2019 11:10: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; dkim=pass header.i=@kernel.org header.s=default header.b=a8INY40G; 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 S2438570AbfJPV7h (ORCPT + 99 others); Wed, 16 Oct 2019 17:59:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:52394 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438224AbfJPV6j (ORCPT ); Wed, 16 Oct 2019 17:58:39 -0400 Received: from localhost (unknown [192.55.54.58]) (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 6A91F21928; Wed, 16 Oct 2019 21:58:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263119; bh=jFXAIx9g4Rar81Kccj33nbuvqOQF4Z/HIzIz/pbtx48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a8INY40GSNG4n8+h85XAJ8K5UuKS9dPBdgyFANAh7gszMwWcw58Q2GQh8Q0uTc2em TD+H6KqfX5cjFJzr0FyJFUHNjFtwI9MgJlWFUxyWmnaan7Z7I+0vO0RlNths0Z7heW DUNVqgpiX2IyovUXS7h/nbg9zGjEOHUmm7Xstrc4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 5.3 043/112] USB: legousbtower: fix use-after-free on release Date: Wed, 16 Oct 2019 14:50:35 -0700 Message-Id: <20191016214854.683057469@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@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 From: Johan Hovold commit 726b55d0e22ca72c69c947af87785c830289ddbc upstream. The driver was accessing its struct usb_device in its release() callback without holding a reference. This would lead to a use-after-free whenever the device was disconnected while the character device was still open. Fixes: fef526cae700 ("USB: legousbtower: remove custom debug macro") Cc: stable # 3.12 Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20191009153848.8664-5-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/legousbtower.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c @@ -296,6 +296,7 @@ static inline void tower_delete (struct kfree (dev->read_buffer); kfree (dev->interrupt_in_buffer); kfree (dev->interrupt_out_buffer); + usb_put_dev(dev->udev); kfree (dev); } @@ -810,7 +811,7 @@ static int tower_probe (struct usb_inter mutex_init(&dev->lock); - dev->udev = udev; + dev->udev = usb_get_dev(udev); dev->open_count = 0; dev->disconnected = 0;