Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1399019ybp; Thu, 17 Oct 2019 12:12:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEob2iEVfsZoB4msanyZqYRYBd4pnnsbKvDiZwvKBzOf31RyQeuoRel0UEqyJYgxkesksK X-Received: by 2002:a50:b966:: with SMTP id m93mr5471983ede.228.1571339540511; Thu, 17 Oct 2019 12:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571339540; cv=none; d=google.com; s=arc-20160816; b=HKGWMyXgNDKubOGoGWP2HiBsnWwsh9V32ji/+Pm4C2po4ElRlpYGmdqebwOFoeNRSV wj1mOQrFEPRL0NuKJCSHfGBgK91PbtT1gIoKp1rIEczXfgXU2sq+mI1PHOTazfEpUyBy X9iqctv6VP+Xl6hqUEiBQ/EbLnTHr375pFZrZ/KSU9MG7MP5VLbHWkVHnm6mjWuBeLgT ETSEsII1Nlcdmr9G6fJmFqp5k7EbbwGKu+BMLbHLban4SOQuKZ6W4PEMRKl1EZPSjcrY bCdm+CNMkZU8UhwDwDYIsCvS9VjVtXyTdxmhjuZ1Azt6uWWmmbWIrj+SpwyeoHWtj1/n O9sg== 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=hRhBxxWwpiSd/XmkdG2xwSIvANDA27GJyIOs8SSMtqE=; b=fuT0AbTqbYN9n2T2M+GYMwt4NCnTNPZk6lY0pba3xwOWmjIg3EvOtap/GndhUnleLf 67yiU6ItOWWkHcIJuMKi+Se4kvFjIqTHUORCukoHjxwPaJf99FfEqutG92C6E9C+mBX8 g143wwPrNauL0SHnU3Bbqg+LQDwnFVc3PKi92eGBvHjQ8R41ENiGs07gZ3tmdZZpM8iF 1Jmr+TBbfKcb4jKo+VMAC/6ep84uYNJyS2go9vsvfuQe3eTTIS03QpRnVdAPhnfrEAy8 fW1yT6I4FYifIMM20PFVVN/6tAs92/jVQj/Q5RpsKL7OtEv6g5jM8bjXHM0lf2xPRool WkMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U0oyAI5B; 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 q1si2321923edj.354.2019.10.17.12.11.56; Thu, 17 Oct 2019 12:12:20 -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=U0oyAI5B; 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 S2439322AbfJPWN2 (ORCPT + 99 others); Wed, 16 Oct 2019 18:13:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:46958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395374AbfJPVzw (ORCPT ); Wed, 16 Oct 2019 17:55:52 -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 5380F21928; Wed, 16 Oct 2019 21:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571262951; bh=+L2m0d+XklJPtiibixn3X0QJoAzTHcW0+W3FP5p2sME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U0oyAI5BVy0Ha1Bm8KadupCxqQ07jSecoKGfkylaKNfAPfE8MWK2dZmZAK/uPR/Hw 0XPD6J/SakPDlIOHCUDi5ziphvnCh2s5mBa/SWD4HVD2E+CAXiMvPTr7YVQw6a4USi qcsH9rjzhDc9/Td2/LcAO2vvLcZS6iMNdFG9CRqg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 4.14 21/65] USB: chaoskey: fix use-after-free on release Date: Wed, 16 Oct 2019 14:50:35 -0700 Message-Id: <20191016214816.453677699@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214756.457746573@linuxfoundation.org> References: <20191016214756.457746573@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 93ddb1f56ae102f14f9e46a9a9c8017faa970003 upstream. The driver was accessing its struct usb_interface 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: 66e3e591891d ("usb: Add driver for Altus Metrum ChaosKey device (v2)") Cc: stable # 4.1 Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20191009153848.8664-3-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/chaoskey.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/usb/misc/chaoskey.c +++ b/drivers/usb/misc/chaoskey.c @@ -106,6 +106,7 @@ static void chaoskey_free(struct chaoske usb_free_urb(dev->urb); kfree(dev->name); kfree(dev->buf); + usb_put_intf(dev->interface); kfree(dev); } } @@ -153,6 +154,8 @@ static int chaoskey_probe(struct usb_int if (dev == NULL) goto out; + dev->interface = usb_get_intf(interface); + dev->buf = kmalloc(size, GFP_KERNEL); if (dev->buf == NULL) @@ -186,8 +189,6 @@ static int chaoskey_probe(struct usb_int strcat(dev->name, udev->serial); } - dev->interface = interface; - dev->in_ep = in_ep; if (le16_to_cpu(udev->descriptor.idVendor) != ALEA_VENDOR_ID)