Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3513140ybn; Fri, 27 Sep 2019 07:28:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxP6bQ5bwKU7Zu+2p/hhGZv5qhn6Mgbgs0k5hEhPSi0HsZw/kxdXvwNB5F7ll9D14eB/5RB X-Received: by 2002:a17:906:d8c8:: with SMTP id re8mr8149670ejb.130.1569594486202; Fri, 27 Sep 2019 07:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569594486; cv=none; d=google.com; s=arc-20160816; b=z5aiyo7BhxDrAXnzR7KwxQUP9lsycRUupFi5UuKo8PK/wp2TES8Vgy/cT/xBf7vtj6 UNuKgKFLBWmwZRXMDEhpZ7QsUKX7gCOoA15QOtChH+BQt6uv40WMIquzSLm4Z9Ve+6NU vqu/QS9LhBTFnGPYN2p41w/zlrIoqohpH8oErFCIVXw2T4h1/yyfve3YjiyeVbyTS6jJ BJ9Mv/J9pBHrE/jHsVXcu+4lDK5ERyOtnYR5mMP2i5CFBCmbU6iNKOxYhZ/N5Y4Im5x5 v6r3bo1azy7zeImdxgwuD6eUJPDClG60FaQ5ieFQGNlLkZ1W7VLK8hbU51snEgSfIKqW yX0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aSckuQ80CIiF/9/8+18nNqYpwKA6GZVh8vgmv4HFPhE=; b=wACWkbOQzMaTsyb1DizNNtrYtTgy7EiMN2hszwDgWl072o/QhjDtD0y+O5FDFneCM+ NEOEw8dEnXw6i4U9xSTmMadvc0/yqn1FaOTI0CGkSIpEuOMx8g/OXGCtjoDMTqCT2+22 q+OL6G3b0Wx03GuaYrht3Pbat7T8Y0Be0HS7wjPa3xHC+iO/zYrSNNlXL6kGW9XvCfnJ FSfAn8bHK/wvrTd0N76KtqOdDmfD+RJi5d+X7KRlGScCWrxg5zStlqCRKF2vixzwjbyX 9SlylPvBXjVj6eS+Ab3/D5O2DlpR5pYCHGTehA2FMPPewMuJmjY46UuLu4nzGB5cFDiq HIWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=atPRrpes; 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 g50si1640694edb.47.2019.09.27.07.27.41; Fri, 27 Sep 2019 07:28:06 -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=@poorly.run header.s=google header.b=atPRrpes; 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 S1727542AbfI0OZN (ORCPT + 99 others); Fri, 27 Sep 2019 10:25:13 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:38052 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727447AbfI0OZM (ORCPT ); Fri, 27 Sep 2019 10:25:12 -0400 Received: by mail-yb1-f195.google.com with SMTP id o18so2074074ybp.5 for ; Fri, 27 Sep 2019 07:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=aSckuQ80CIiF/9/8+18nNqYpwKA6GZVh8vgmv4HFPhE=; b=atPRrpesEZbMNYxnybbWCv+6b4sE7cKx2UAeCJ28BvLsStCMy3jZSkBYiSKlvqytre o/5i6Wli7iHZX9z5HZ3IqR+PVGzvqNKLPWFtaeUa8X4m0GNBrBjoA5tFTX9XhmLvZCvu e9CAdiyRq2VjfnJcYh2eitZMbYYChpjGE4tSnObIEENkIq4n23A1NaJ6VYhGYL2ZaFN6 VLHal0Db4DrplJVIi56yIDXIb4c3ixZ8d8Hb1OvG8rZNvveRSmkjQoPFiqGYcbOIymss 3wgow+cTMHJ92yfdElO87v9ZR+OPfTxTP9a3P/5ZoVj3ceoiOer0rtvy+KMbQRJ73sfN Ttkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=aSckuQ80CIiF/9/8+18nNqYpwKA6GZVh8vgmv4HFPhE=; b=U1XhpsiMj3WAGUsM/TASnmEdXF7fk8ZZaISIxJB7eXOUOT20hEdBg8QGwxLKv4Lia+ VN2GwYLF6uRMFMoQ+PU97qpdvfeLYQD4PymvJFkkRDEkgyPB9ovA6uVEvrghDiq5/b+d H6bZd4IOqrATsfkjByeBjEZNoki6ck1f9P16Zwds47iVuQB0P8hd33wazqIjLK/5UfKv iFAdE2FNcFEWN9YIinopEfaNz6vR4FiqNuIq3LqDZbiESKVT84MTQdaeSmEK7RCBbxFN b9o05ZAePejgp9NTpLE6rPp1e0EJgSgEby3mH4LUL+5IqIPUdy1BkPqe6k6X+0DhjNH6 NRGA== X-Gm-Message-State: APjAAAV13Har6Bmnr2GAc+pF8sTQE4AJZ+6lxoybKKMd1Hq5xKcoUnmV 75yuudt/mN7OHhrrPrMOfS15/A== X-Received: by 2002:a25:af09:: with SMTP id a9mr6448350ybh.405.1569594311669; Fri, 27 Sep 2019 07:25:11 -0700 (PDT) Received: from localhost ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id z137sm616354ywd.18.2019.09.27.07.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 07:25:10 -0700 (PDT) Date: Fri, 27 Sep 2019 10:25:10 -0400 From: Sean Paul To: Lyude Paul Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Juston Li , Imre Deak , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , Harry Wentland , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 26/27] drm/dp_mst: Also print unhashed pointers for malloc/topology references Message-ID: <20190927142510.GS218215@art_vandelay> References: <20190903204645.25487-1-lyude@redhat.com> <20190903204645.25487-27-lyude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190903204645.25487-27-lyude@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 03, 2019 at 04:46:04PM -0400, Lyude Paul wrote: > 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 It's really too bad there isn't a CONFIG_DEBUG_SHOW_PK_ADDRESSES or even a value of kptr_restrict value that bypasses pointer hashing. I'm sure we're not the only ones to feel this pain. Maybe everyone just hacks vsnprintf... As it is, I'm not totally sold on exposing the actual addresses unconditionally. What do you think about pulling the print out into a function and only printing px if a debug kconfig is set? Sean > --- > 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 > -- Sean Paul, Software Engineer, Google / Chromium OS