Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1348661ybp; Thu, 17 Oct 2019 11:25:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnb2BcUiCzqwttebIM4Lu7XZhKHkNhB69aKkFUNwGuLbjK6+0nSEgY+/Kcs35agwxpAUs2 X-Received: by 2002:a17:906:181b:: with SMTP id v27mr4986026eje.117.1571336721998; Thu, 17 Oct 2019 11:25:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571336721; cv=none; d=google.com; s=arc-20160816; b=ywETNHdfyAEEVy8f9+4F/7PBZ7VVuObSn7iRG2ptCOt/0+0gv7lXAdMUJvJUk4LHaH 4prsRM2evuHOHMiLfKNV9SVcbTTQXjrDIOk3mOrh7+g6b/kxZtu2a4WwF2rRaWIWnUIi uO5+XsB8bZQNwRTx2txVks9ES/W/QcRJTpa9Bt9u4vC34nBfJt0jALPO03ZyKc4DGagB pYVfGNBg1frx0fTF1dYWI0MfHHtDDcFT0PoXBDgML9GQwh5g5c/VQPLOjlgqLLp4h5gO 0azh/ftUdfQGEvkXNMdgUZ2uAA/CbDx4aSxhNraqXh77oaruoW4xNccX3BKYzk8alNI6 4kfA== 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=rPRXIFrBUwnD2/kIHTjmTURlFI8xZ99+f6QNFFhbE7A=; b=ITc4q8isMqzt4tCSYNz98BUGRJKGPZX4ZgWSlt0RJujg4amTqFk5BxncbLYbAfPEum tbUaKdySPCYqGq3zLdMG1zbcwWsw0N9wiw3TpjR77w7F6+0Ja6r2kDHyY4Jz6ga8/10s KOSbUReuB/lMJWp47S/b8ksZOA+zFHfUyU87S9LmrWrfAW/7BYqmOn9qDcv1RKgC1woW HdWOWgdSfy9TqdbBjFmQ9qbG/J8+YkPp9t1Ta8A+a8EHl5AE+y7h7Y+xbMKX2bsnMn9C hAJdnyrVP3CkiWCVaL+6vwr7HM/xj64WpGFUYGmdv06qI3eEQvF89wS0bBKWvHVRjvK/ OtHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jqgjzvtb; 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 dv21si1973622ejb.241.2019.10.17.11.24.59; Thu, 17 Oct 2019 11:25:21 -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=Jqgjzvtb; 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 S2406852AbfJPWE1 (ORCPT + 99 others); Wed, 16 Oct 2019 18:04:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:53396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438381AbfJPV7E (ORCPT ); Wed, 16 Oct 2019 17:59:04 -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 42BDF21A4C; Wed, 16 Oct 2019 21:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263144; bh=LY9IoeQ4KDR5F+hVavxrD1Vb2SUzTkDoVSL59UYUWi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JqgjzvtbcA1I1lWbbSWSWSA0INzNBm3WMDBnKXSCY8YDYxl42xIK7ko4zM8lKPaVa R2Ocj7pPCN/sx1PbgBIJhxY6Wt3wUQXQbf/FLRmDHr31IucNmC/vPC0EHpvf8LWYWa rNFaC9WvD8V5vuBA9KCyEI5P7vkcWOsIO1xUfGQc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 5.3 026/112] USB: serial: keyspan: fix NULL-derefs on open() and write() Date: Wed, 16 Oct 2019 14:50:18 -0700 Message-Id: <20191016214852.472832602@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 7d7e21fafdbc7fcf0854b877bd0975b487ed2717 upstream. Fix NULL-pointer dereferences on open() and write() which can be triggered by a malicious USB device. The current URB allocation helper would fail to initialise the newly allocated URB if the device has unexpected endpoint descriptors, something which could lead NULL-pointer dereferences in a number of open() and write() paths when accessing the URB. For example: BUG: kernel NULL pointer dereference, address: 0000000000000000 ... RIP: 0010:usb_clear_halt+0x11/0xc0 ... Call Trace: ? tty_port_open+0x4d/0xd0 keyspan_open+0x70/0x160 [keyspan] serial_port_activate+0x5b/0x80 [usbserial] tty_port_open+0x7b/0xd0 ? check_tty_count+0x43/0xa0 tty_open+0xf1/0x490 BUG: kernel NULL pointer dereference, address: 0000000000000000 ... RIP: 0010:keyspan_write+0x14e/0x1f3 [keyspan] ... Call Trace: serial_write+0x43/0xa0 [usbserial] n_tty_write+0x1af/0x4f0 ? do_wait_intr_irq+0x80/0x80 ? process_echoes+0x60/0x60 tty_write+0x13f/0x2f0 BUG: kernel NULL pointer dereference, address: 0000000000000000 ... RIP: 0010:keyspan_usa26_send_setup+0x298/0x305 [keyspan] ... Call Trace: keyspan_open+0x10f/0x160 [keyspan] serial_port_activate+0x5b/0x80 [usbserial] tty_port_open+0x7b/0xd0 ? check_tty_count+0x43/0xa0 tty_open+0xf1/0x490 Fixes: fdcba53e2d58 ("fix for bugzilla #7544 (keyspan USB-to-serial converter)") Cc: stable # 2.6.21 Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/keyspan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c @@ -1741,8 +1741,8 @@ static struct urb *keyspan_setup_urb(str ep_desc = find_ep(serial, endpoint); if (!ep_desc) { - /* leak the urb, something's wrong and the callers don't care */ - return urb; + usb_free_urb(urb); + return NULL; } if (usb_endpoint_xfer_int(ep_desc)) { ep_type_name = "INT";