Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp60612yba; Fri, 3 May 2019 20:41:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNPUSA/f7sGueytukRmlgzqItzaeKf9+WPDyjlrL2Frvbxt6PonZVDQNtQbRC+ozTLappT X-Received: by 2002:a62:6807:: with SMTP id d7mr15756886pfc.75.1556941301289; Fri, 03 May 2019 20:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556941301; cv=none; d=google.com; s=arc-20160816; b=xffIzgoai4C6us+uAqzzhL6o2p5NrW7jOBlp+yV4Ja40q/5MLKQx9NhUPC0c1AkQ9a tswGonBQlzLiUXemqDUOYevnZqb+SxXqkqGLp2G1Qe3XBD7DSSvDLYr4Vtu8twJfX6bN xcCSTrUNBgF1rlk6kDy7XtPEQgKZBGjbhmxKf2EytCfrZ1cSKTPB0JS+BCUo9xl7Fa2V BgOlMxlYP4d87s0DVA+oBN2WYdQG/Y/rL5aZG01VdVuRrNomyJtdzlrEUSOnvnx0t30O fwKmqHqTaDwpxGp8om4skF8Uo4fKMwBdtCA/ueiK+DZEA+EndNWzhfuLUihks6OcD3at PXMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=zlQ6dBfiL4jG+H+7ODXfiGEF1Mx9HAA5I1OkQsfcDT4=; b=bvn6HaXONY5HXntHfrQWXIpjOzx2YKdEfqwP8VuHJYiWx4OMX0TdZOJftG4PUliGnN wGloEuJZn76scB1Wg6+iyw9Om5Gd3QPgduFGcP8TnYrIE+7xqcPYiw2jGA4gsQOfcO6r Ng+wASipzroO695ulxANYO/JQ7rX97Su7UtCWGBu+yjPJ4v8UhrQDvQ7PbVpGuWAQPy1 lC1yyyeasqGYLYoY7ucxjgnh1FRRfqLLaWlF7DykCBpCFzm582HNFqyKH1HPCzzU6HrL G/0eifCCeAKcMb2jYT1k1ntFIuAgHQx3A/wVLUn0K+bpKv/dHV3ZdP2e9yvWJ7V8R0h1 cBCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pUmHZvTd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i22si5184580pgg.485.2019.05.03.20.41.25; Fri, 03 May 2019 20:41:41 -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=@gmail.com header.s=20161025 header.b=pUmHZvTd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbfEDDh5 (ORCPT + 99 others); Fri, 3 May 2019 23:37:57 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:45064 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbfEDDh5 (ORCPT ); Fri, 3 May 2019 23:37:57 -0400 Received: by mail-pg1-f193.google.com with SMTP id i21so3642986pgi.12; Fri, 03 May 2019 20:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=zlQ6dBfiL4jG+H+7ODXfiGEF1Mx9HAA5I1OkQsfcDT4=; b=pUmHZvTdj/NE1RyG31wjZdqVvlWAeWUNdpPrp5odUQvY0nX1fcBlYkZeq3FjE3SjTU p8QDNxF1GMQycaDsZ9zpKLxNvjObLuV4vQgyLHpFH6RVggBhgEFRu/9xpS5ISBV9IhA4 O3T/I+Sf0Mmk2Q2gi8iDO0Fy9nNPx3OX2y4JMIqbIka8ahxLtlqt8eC72BFfwLkketqV dDIT6vlSoqM/CFXQwtTclQY9gSDKFzPSIZyHBKPAMEfo6fS+OmZAtwbpCSZqyJBScLag lU/Nmbi5172OnH1fTDhFm6EitYCVh7ymV9ll1YGJ/l8DnmJyRCstayUNECEwoyj55vKj EFUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=zlQ6dBfiL4jG+H+7ODXfiGEF1Mx9HAA5I1OkQsfcDT4=; b=mqZ4fUA/z6co2obkBonK6ivc9QR3Wny0yROe3EKPtzINq4SBE97/g23Ig/VmSjAHWr kyOsrtt6N7YmBBoilOg7/YQgrMIk4L/S/JnNFYPg3KJb0bmAXNnXrJcwN4mVy9PTFHS7 +3MKQIWyHaDythtpm6C/h7jXiYhH8ZHZf39QPpDwvvLqf+Iry7K7iCmfdeR5kLu/+Qn3 AK5O69sJX+9707Stzpo9BTVX2oCQ/7/8hMlsHKT12y8HpNWdZD2ZqLREqRy5Iirw8s2g 7RbnkJ1pNv4h2N7ho90BXR4bf/9JkvLvs8wVxr+ZSn48ROr1lYpP9LVZEic9rpAp+tV3 4Tlw== X-Gm-Message-State: APjAAAVOzEcX+tFkR7kuidVGa2Vniz3nMiC5MCW7lPTgL0OPqerKkDrf 3wfkHb9PZBWcnInjCxb8+Tw= X-Received: by 2002:a63:fd06:: with SMTP id d6mr15467012pgh.183.1556941076981; Fri, 03 May 2019 20:37:56 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id f71sm6768795pfc.109.2019.05.03.20.37.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 May 2019 20:37:56 -0700 (PDT) From: Jia-Ju Bai To: mathias.nyman@intel.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] usb: host: xhci_debugfs: Fix a null pointer dereference in xhci_debugfs_create_endpoint() Date: Sat, 4 May 2019 11:37:48 +0800 Message-Id: <20190504033748.17964-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In xhci_debugfs_create_slot(), kzalloc() can fail and dev->debugfs_private will be NULL. In xhci_debugfs_create_endpoint(), dev->debugfs_private is used without any null-pointer check, and can cause a null pointer dereference. To fix this bug, a null-pointer check is added in xhci_debugfs_create_endpoint(). This bug is found by a runtime fuzzing tool named FIZZER written by us. Signed-off-by: Jia-Ju Bai --- drivers/usb/host/xhci-debugfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c index cadc01336bf8..7ba6afc7ef23 100644 --- a/drivers/usb/host/xhci-debugfs.c +++ b/drivers/usb/host/xhci-debugfs.c @@ -440,6 +440,9 @@ void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci, struct xhci_ep_priv *epriv; struct xhci_slot_priv *spriv = dev->debugfs_private; + if (!spriv) + return; + if (spriv->eps[ep_index]) return; -- 2.17.0