Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp125777iof; Sun, 5 Jun 2022 23:08:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiNfE8MdhKtq8VyPL41yP6ZKoX2t3gnkCsH0Clagq60nVOQqv3A6dh/lYKFDknfF5v2S0e X-Received: by 2002:a17:90b:4d8b:b0:1e3:30bd:5a35 with SMTP id oj11-20020a17090b4d8b00b001e330bd5a35mr25127700pjb.152.1654495683358; Sun, 05 Jun 2022 23:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654495683; cv=none; d=google.com; s=arc-20160816; b=bGCKDIOXzHoN04wMJMIHonYjf0GNfXPFNQk8QDxCECNReNvuf5tc11RIdbIkgN6KLl ZScFBquQQoSOLlN1b90VBGXYiY3We+NkmXHh6JRbXaWUZz/4I0wD5v1nmkbogNXNhVHE WDodVTNlzgLppWhQxpB4WvMQCYH9OXPCOXZ2WEmq9vN4JjhmMu+bQHMJQDWrnSirjqz4 qjLhiGmfOYveqQKJkWFr/0CdmtKqRR6s65b2hrkKzFnxITOsDuucQHLTtDnywC4f+9mR +N3M22UFhCGN3owqwbDZfAqoTlBg20XD5hVxAquVmY52GO5lOJ/cdfrBY5453ZtxO7iL 9F8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l4iW0euo2hpUkJUtHiLJMCOQOvdkFw2OylvP6PRtFgU=; b=bG5IS732VNcoa2bNJSLvCHAnoJpdL+ahhRF6ANKoNvrqcFpRa3bjUtTpRGld0wEhzY 4ZCYg2tp/smoCzssPo1bI7j3R4+o5+QrEHWJnbLogBkI5U9/uroZXTtq1mL3M91xKcMj iaem3VWILBF5TK/Dll/RVVhda3wRgRfakoAjuWqhd6SA0ZtrQN2f5hWh8ibwyau4N7v9 BKHd1v80eH0f19zol7klhcAIaDjhBoaith71vWZ96Akgjb2jKBanpR4EqCedzxja+lZS S1z+Ut3FvZo6C+tVsRzB3c7IJxp0sMjJMdVyhPTE81Z9N+ZGbZQNKikGbz9v1Tza66C7 Ty/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Ctm/vu9k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r2-20020a170902be0200b001622e02a816si3657284pls.498.2022.06.05.23.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 23:08:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Ctm/vu9k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1A223719D6; Sun, 5 Jun 2022 21:58:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238230AbiFBUSe (ORCPT + 99 others); Thu, 2 Jun 2022 16:18:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238159AbiFBUS2 (ORCPT ); Thu, 2 Jun 2022 16:18:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1EA241ED for ; Thu, 2 Jun 2022 13:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654201104; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l4iW0euo2hpUkJUtHiLJMCOQOvdkFw2OylvP6PRtFgU=; b=Ctm/vu9kROTsD1prTv5BASdDO195zYSMrK5b0wd8h+o8tnAMrNA0U+XDOghQAVBqMP488P I/cglasJCt+sVER4Yqc2sbnz77ENcOnCOfqJEcp8voz+p3PS7w/J/ItTOuJRmMrdTG1BaZ 8+UM+WTvUUMpaZsDuCp8GiNI75p9zq0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-nJSe9AyMNWyvtZ7uq8_tKA-1; Thu, 02 Jun 2022 16:18:19 -0400 X-MC-Unique: nJSe9AyMNWyvtZ7uq8_tKA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2DE02955B00; Thu, 2 Jun 2022 20:18:18 +0000 (UTC) Received: from emerald.redhat.com (unknown [10.22.34.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2E59414A7E7; Thu, 2 Jun 2022 20:18:17 +0000 (UTC) From: Lyude Paul To: dri-devel@lists.freedesktop.org Cc: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , stable@vger.kernel.org, David Airlie , Daniel Vetter , Thomas Zimmermann , Jani Nikula , Wayne Lin , Bhawanpreet Lakha , Imran Khan , Javier Martinez Canillas , Fangzhi Zuo , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/3] drm/display/dp_mst: Fix drm_atomic_get_mst_topology_state() Date: Thu, 2 Jun 2022 16:17:56 -0400 Message-Id: <20220602201757.30431-3-lyude@redhat.com> In-Reply-To: <20220602201757.30431-1-lyude@redhat.com> References: <20220602201757.30431-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.11.54.2 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I noticed a rather surprising issue here while working on removing all of the non-atomic MST code: drm_atomic_get_mst_topology_state() doesn't check the return value of drm_atomic_get_private_obj_state() and instead just passes it directly to to_dp_mst_topology_state(). This means that if we hit a deadlock or something else which would return an error code pointer, we'll likely segfault the kernel. This is definitely another one of those fixes where I'm astonished we somehow managed never to discover this issue until now… Signed-off-by: Lyude Paul Fixes: a4370c777406 ("drm/atomic: Make private objs proper objects") Cc: Ville Syrjälä Cc: # v4.14+ --- drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +- include/drm/display/drm_dp_mst_helper.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c index d84673b3294b..d6e595b95f07 100644 --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c @@ -5468,7 +5468,7 @@ EXPORT_SYMBOL(drm_dp_mst_topology_state_funcs); struct drm_dp_mst_topology_state *drm_atomic_get_mst_topology_state(struct drm_atomic_state *state, struct drm_dp_mst_topology_mgr *mgr) { - return to_dp_mst_topology_state(drm_atomic_get_private_obj_state(state, &mgr->base)); + return to_dp_mst_topology_state_safe(drm_atomic_get_private_obj_state(state, &mgr->base)); } EXPORT_SYMBOL(drm_atomic_get_mst_topology_state); diff --git a/include/drm/display/drm_dp_mst_helper.h b/include/drm/display/drm_dp_mst_helper.h index 10adec068b7f..fe7577e7f305 100644 --- a/include/drm/display/drm_dp_mst_helper.h +++ b/include/drm/display/drm_dp_mst_helper.h @@ -541,6 +541,8 @@ struct drm_dp_payload { }; #define to_dp_mst_topology_state(x) container_of(x, struct drm_dp_mst_topology_state, base) +#define to_dp_mst_topology_state_safe(x) \ + container_of_safe(x, struct drm_dp_mst_topology_state, base) struct drm_dp_vcpi_allocation { struct drm_dp_mst_port *port; -- 2.35.3