Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2493817ybe; Tue, 3 Sep 2019 13:51:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuQZ/c2UFpoYfI0ttcxt3up1kv4BAsFi6qIfXitg7btydbMRDdHucv1O6sDzqb3bbpy91W X-Received: by 2002:a63:316:: with SMTP id 22mr1189808pgd.242.1567543861963; Tue, 03 Sep 2019 13:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567543861; cv=none; d=google.com; s=arc-20160816; b=RyQ0+A53wRw1Qh0ZwVJuONyk6TIrHkH83/QmA6L6MPxBIc0tbc/dcwyFox74KHtCaa Y4LSbr6WRJnbxSos7Y7APSEMNxJrNBqvCVGYg3dZVzMoU/5t/gUlI/og8aJDwmqzHU6E Dj1Txp7576XefxhkIKUfhVHiuSpysVgrkYadz79eZsEgLmhNg73Qi4FvStt7oSYu40Ix XLEiPIaLbDVMksVTKXod5bMtQrZ4+LJ9MfaLaDgoeGTRw1TGj3w0CqBJ0EdAg41SFW1S Puorg7Qv0Tbsfox/y1wVQ3ThAO1BnUHO/pc+RxVBZpS86B5IYapM8TzY08slX2pcqKub wjpA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=fTKoSmYy1VR6n6tMse2kQov05aLkp+/21HMOf9rOGmI=; b=wpVLzfZS/GXQ8ZHfRWXCKbpDFEXs7atwZnokk2T+xGZ4Hpk8ne93rcRpCrhyWD0J/Z 0hOYegrLvwhcaMzogKfOh9q3FYcBHQTIW7DOQghzjoP+fdckV5eLQz/3d9Xwzq49KRBM z4+1ZMOo5xQkj9cxleYQNtU1I8gYN9JwTWvb8zcS992sIzbVPEiCmt2y9CBerktfA0G0 DeYF2DQlK8wpSc8df8I2lGFLtehijXt7wwszGkGTOucu42u/9s/BNS+nxYaEDUXQSNwd iESjLhg6q8DgCFKzBKp9ngcXPk3VYM43oSO/KfffU5SFPjad/L0/g4vB7QFO5CtMroC3 ujNw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185si15535674pgc.522.2019.09.03.13.50.46; Tue, 03 Sep 2019 13:51:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728429AbfICUtU (ORCPT + 99 others); Tue, 3 Sep 2019 16:49:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47156 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728358AbfICUtR (ORCPT ); Tue, 3 Sep 2019 16:49:17 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 32A383082141; Tue, 3 Sep 2019 20:49:17 +0000 (UTC) Received: from malachite.bss.redhat.com (dhcp-10-20-1-34.bss.redhat.com [10.20.1.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6E5D1001B08; Tue, 3 Sep 2019 20:49:15 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Cc: Juston Li , Imre Deak , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Harry Wentland , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org Subject: [PATCH v2 26/27] drm/dp_mst: Also print unhashed pointers for malloc/topology references Date: Tue, 3 Sep 2019 16:46:04 -0400 Message-Id: <20190903204645.25487-27-lyude@redhat.com> In-Reply-To: <20190903204645.25487-1-lyude@redhat.com> References: <20190903204645.25487-1-lyude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 03 Sep 2019 20:49:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently we only print mstb/port pointer addresses in our malloc and topology refcount functions using the hashed-by-default %p, but unfortunately if you're trying to debug a use-after-free error caused by a refcounting error then this really isn't terribly useful. On the other hand though, everything in the rest of the DP MST helpers uses hashed pointer values as well and probably isn't useful to convert to unhashed. So, let's just get the best of both worlds and print both the hashed and unhashed pointer in our malloc/topology refcount debugging output. This will hopefully make it a lot easier to figure out which port/mstb is causing KASAN to get upset. Cc: Juston Li Cc: Imre Deak Cc: Ville Syrjälä Cc: Harry Wentland Cc: Daniel Vetter Signed-off-by: Lyude Paul --- drivers/gpu/drm/drm_dp_mst_topology.c | 34 ++++++++++++++++----------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c index 2fe24e366925..5b5c0b3b3c0e 100644 --- a/drivers/gpu/drm/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/drm_dp_mst_topology.c @@ -1327,7 +1327,8 @@ static void drm_dp_mst_get_mstb_malloc(struct drm_dp_mst_branch *mstb) { kref_get(&mstb->malloc_kref); - DRM_DEBUG("mstb %p (%d)\n", mstb, kref_read(&mstb->malloc_kref)); + DRM_DEBUG("mstb %p/%px (%d)\n", + mstb, mstb, kref_read(&mstb->malloc_kref)); } /** @@ -1344,7 +1345,8 @@ drm_dp_mst_get_mstb_malloc(struct drm_dp_mst_branch *mstb) static void drm_dp_mst_put_mstb_malloc(struct drm_dp_mst_branch *mstb) { - DRM_DEBUG("mstb %p (%d)\n", mstb, kref_read(&mstb->malloc_kref) - 1); + DRM_DEBUG("mstb %p/%px (%d)\n", + mstb, mstb, kref_read(&mstb->malloc_kref) - 1); kref_put(&mstb->malloc_kref, drm_dp_free_mst_branch_device); } @@ -1379,7 +1381,8 @@ void drm_dp_mst_get_port_malloc(struct drm_dp_mst_port *port) { kref_get(&port->malloc_kref); - DRM_DEBUG("port %p (%d)\n", port, kref_read(&port->malloc_kref)); + DRM_DEBUG("port %p/%px (%d)\n", + port, port, kref_read(&port->malloc_kref)); } EXPORT_SYMBOL(drm_dp_mst_get_port_malloc); @@ -1396,7 +1399,8 @@ EXPORT_SYMBOL(drm_dp_mst_get_port_malloc); void drm_dp_mst_put_port_malloc(struct drm_dp_mst_port *port) { - DRM_DEBUG("port %p (%d)\n", port, kref_read(&port->malloc_kref) - 1); + DRM_DEBUG("port %p/%px (%d)\n", + port, port, kref_read(&port->malloc_kref) - 1); kref_put(&port->malloc_kref, drm_dp_free_mst_port); } EXPORT_SYMBOL(drm_dp_mst_put_port_malloc); @@ -1447,8 +1451,8 @@ drm_dp_mst_topology_try_get_mstb(struct drm_dp_mst_branch *mstb) int ret = kref_get_unless_zero(&mstb->topology_kref); if (ret) - DRM_DEBUG("mstb %p (%d)\n", mstb, - kref_read(&mstb->topology_kref)); + DRM_DEBUG("mstb %p/%px (%d)\n", + mstb, mstb, kref_read(&mstb->topology_kref)); return ret; } @@ -1471,7 +1475,8 @@ static void drm_dp_mst_topology_get_mstb(struct drm_dp_mst_branch *mstb) { WARN_ON(kref_read(&mstb->topology_kref) == 0); kref_get(&mstb->topology_kref); - DRM_DEBUG("mstb %p (%d)\n", mstb, kref_read(&mstb->topology_kref)); + DRM_DEBUG("mstb %p/%px (%d)\n", + mstb, mstb, kref_read(&mstb->topology_kref)); } /** @@ -1489,8 +1494,8 @@ static void drm_dp_mst_topology_get_mstb(struct drm_dp_mst_branch *mstb) static void drm_dp_mst_topology_put_mstb(struct drm_dp_mst_branch *mstb) { - DRM_DEBUG("mstb %p (%d)\n", - mstb, kref_read(&mstb->topology_kref) - 1); + DRM_DEBUG("mstb %p/%px (%d)\n", + mstb, mstb, kref_read(&mstb->topology_kref) - 1); kref_put(&mstb->topology_kref, drm_dp_destroy_mst_branch_device); } @@ -1546,8 +1551,8 @@ drm_dp_mst_topology_try_get_port(struct drm_dp_mst_port *port) int ret = kref_get_unless_zero(&port->topology_kref); if (ret) - DRM_DEBUG("port %p (%d)\n", port, - kref_read(&port->topology_kref)); + DRM_DEBUG("port %p/%px (%d)\n", + port, port, kref_read(&port->topology_kref)); return ret; } @@ -1569,7 +1574,8 @@ static void drm_dp_mst_topology_get_port(struct drm_dp_mst_port *port) { WARN_ON(kref_read(&port->topology_kref) == 0); kref_get(&port->topology_kref); - DRM_DEBUG("port %p (%d)\n", port, kref_read(&port->topology_kref)); + DRM_DEBUG("port %p/%px (%d)\n", + port, port, kref_read(&port->topology_kref)); } /** @@ -1585,8 +1591,8 @@ static void drm_dp_mst_topology_get_port(struct drm_dp_mst_port *port) */ static void drm_dp_mst_topology_put_port(struct drm_dp_mst_port *port) { - DRM_DEBUG("port %p (%d)\n", - port, kref_read(&port->topology_kref) - 1); + DRM_DEBUG("port %p/%px (%d)\n", + port, port, kref_read(&port->topology_kref) - 1); kref_put(&port->topology_kref, drm_dp_destroy_port); } -- 2.21.0