Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4504232ybx; Mon, 4 Nov 2019 14:29:49 -0800 (PST) X-Google-Smtp-Source: APXvYqxVWMoa5XeV7nOiQD6ZNQMNCqg0aQxg7VIv94yW4QKIyBm4z1JQzU2IsZ3ZPvZlHM3ypKqV X-Received: by 2002:a50:d80c:: with SMTP id o12mr32363206edj.251.1572906589573; Mon, 04 Nov 2019 14:29:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572906589; cv=none; d=google.com; s=arc-20160816; b=UIzJMoPQqXSh9u4/qDng4Uc/DN1B696t3rPOrsc0I+sgKTVx3tn1UKuR2QAeUVtFxW W/SKvuoAnfsxDqEd4MVVtmza9L80Mu2YEFZEI4PQdk4jWYsyyc7MjiYoDoyM6P203gnY 8+G/DWZdyqPseW2AucAfHMHRXqFfY/wTTMviVLvm9/4rST03Ts1bEJqdy75BVQ8V1v8d 7gvNVX5NhR6CBFnaKinPup1VBjes19W6Ooi1XXKRisHLFTEvjadiF4NY89GDPi7hkbJh 66uJotKDAQLI4DHgL3bCZs++XC1t9+IHkHXBETvJ5RWluxLSAkGI9E5htfy26mSv/6c5 3YlA== 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=7cTa6xSrd4GP/ZS7xkg1/gKV6i3ohhxW/9j2VeFunUU=; b=0Vp0tm0RrsZUVMe3JzAk4qMDO6OITovjI7JIPOhF9Yi7NcRNf2Dvo6OZNOzEFbDOzB V+4LPKD19RPlJJe7zsISyNHmBWm3FDpboi2Gww6VC/Khnqd277JhyDfd1klG9aBAnWgH QYzn+w2t55izTUpkuIeXpd8G4eugT2l46sdOBbaqisg9IEWh5zE3wDt/MKI/r8OUt7Gk eqUXFHeL3AsSjboWm5zWs9rZ5JaPaWESsctWO9HwmsOHue5wiATsNSduCj9a8PAgxKS3 NGxdM5zn0a/Uq8Lk8leb51pEtE+UStbwLmZb/7i3d48zncNYSkiOk/PdU6WLKX7U+ff0 FBSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=imnYyeUt; 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 h6si8034992eda.258.2019.11.04.14.29.26; Mon, 04 Nov 2019 14:29:49 -0800 (PST) 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=imnYyeUt; 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 S2387594AbfKDW1I (ORCPT + 99 others); Mon, 4 Nov 2019 17:27:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:43002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387755AbfKDVuj (ORCPT ); Mon, 4 Nov 2019 16:50:39 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (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 A3E7721744; Mon, 4 Nov 2019 21:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572904238; bh=QTCPxfOHcDMqsT3sNLrtpzZwxWq4ArbqZGS79lePllI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=imnYyeUthywFw1iPOXp2euVQIkP6xuUAEuLlPF36/H+k7zxjkM7ccMJYHC8Uw1Q9V pdwryFVCsMs5EBESPhJu6elyZhKOkd17ijpaCZu5ejkrhNPJbr9Qjo1sw82+93yRSI 4XUvP1xHh7yWT2N9mfxfcU8XKMlR4RJ9qE5tgPFs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Peng , Mathias Payer , Kalle Valo , Sasha Levin Subject: [PATCH 4.9 33/62] ath6kl: fix a NULL-ptr-deref bug in ath6kl_usb_alloc_urb_from_pipe() Date: Mon, 4 Nov 2019 22:44:55 +0100 Message-Id: <20191104211933.014977706@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104211901.387893698@linuxfoundation.org> References: <20191104211901.387893698@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: Hui Peng [ Upstream commit 39d170b3cb62ba98567f5c4f40c27b5864b304e5 ] The `ar_usb` field of `ath6kl_usb_pipe_usb_pipe` objects are initialized to point to the containing `ath6kl_usb` object according to endpoint descriptors read from the device side, as shown below in `ath6kl_usb_setup_pipe_resources`: for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; // get the address from endpoint descriptor pipe_num = ath6kl_usb_get_logical_pipe_num(ar_usb, endpoint->bEndpointAddress, &urbcount); ...... // select the pipe object pipe = &ar_usb->pipes[pipe_num]; // initialize the ar_usb field pipe->ar_usb = ar_usb; } The driver assumes that the addresses reported in endpoint descriptors from device side to be complete. If a device is malicious and does not report complete addresses, it may trigger NULL-ptr-deref `ath6kl_usb_alloc_urb_from_pipe` and `ath6kl_usb_free_urb_to_pipe`. This patch fixes the bug by preventing potential NULL-ptr-deref (CVE-2019-15098). Signed-off-by: Hui Peng Reported-by: Hui Peng Reported-by: Mathias Payer Reviewed-by: Greg Kroah-Hartman Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/ath6kl/usb.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c index 9da3594fd010d..fc22c5f479276 100644 --- a/drivers/net/wireless/ath/ath6kl/usb.c +++ b/drivers/net/wireless/ath/ath6kl/usb.c @@ -132,6 +132,10 @@ ath6kl_usb_alloc_urb_from_pipe(struct ath6kl_usb_pipe *pipe) struct ath6kl_urb_context *urb_context = NULL; unsigned long flags; + /* bail if this pipe is not initialized */ + if (!pipe->ar_usb) + return NULL; + spin_lock_irqsave(&pipe->ar_usb->cs_lock, flags); if (!list_empty(&pipe->urb_list_head)) { urb_context = @@ -150,6 +154,10 @@ static void ath6kl_usb_free_urb_to_pipe(struct ath6kl_usb_pipe *pipe, { unsigned long flags; + /* bail if this pipe is not initialized */ + if (!pipe->ar_usb) + return; + spin_lock_irqsave(&pipe->ar_usb->cs_lock, flags); pipe->urb_cnt++; -- 2.20.1