Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp79718rwi; Sun, 9 Oct 2022 18:57:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4S1GEZ/ajiQLKFmsJCDwVoJJjtY0Xs0pmi+piRO+X1QxEf1WRI3ZUwMChUhkfjXmaNPwx3 X-Received: by 2002:a63:88c8:0:b0:458:9ddd:e8ea with SMTP id l191-20020a6388c8000000b004589ddde8eamr14457436pgd.622.1665367075227; Sun, 09 Oct 2022 18:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665367075; cv=none; d=google.com; s=arc-20160816; b=lmnS1QhfhBd4P5D6v4xuXwjtOl1QS2LgRm7rpQnfsq2WoGNUBVuaJFhmt2WEcy17BJ OwgCsDfGefKjqR7VOhp/Qh1bBbYURyMoTMV9kkkKe2QMQOdbIrUIF/Tc3RgEWn0GBNhb iBfS41+Jo39W30byF9eUObjBc3+HPVgO7pwFFrj+qgyedxCk5xyi6oLNg8GnCKXL+lny lxzdNMsJarI+n3AUxzX0QqMVe32WZZc+mLCHMOa0vRKphqaJ6911vODCibXMdHzc1vH5 dsmMW8vz+SkYozt/dsHIG4UG/HZvN8tHoVBjc3BrrSdmb6rxEXH3ADulUkCw5mRW61xR eLpA== 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=Gp8+uPGy/J0zFRIbK0t52JW3tHAkw9ET9lcJC4KW7Ys=; b=TaMt/ZQsSXfGLyhUzcFBzF9FVZF5kZDZ0ZqEWdfF4DGQLln31XO2GLstfnLorStjyx ZXZWNHgh49E2Yxntt+A9mvqTsMFgRGwXXj1Dy8k1/of7rlmzZKYJaJvOkn7azlZTk7gD R9Fhi+W0dCLYJ+AYyLlYk6bq4t89o6tiM/OVKuSmpwPKrpVFMi3FWGBGWxQlK6C/bEyo KPDOEPnkxOLSuYlWptx6gpwG14tOHlvG6iX++4rchk01eq4CBnD9D4tyqgC5/iNirNDo YzELDntJMnbaVAFtbY1jnYSGKnN4RvFC2qXkqdZEvigVaivWjUdoCq9R/1Rb2zs2Y/Gz eF2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EdDl+sIQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b21-20020a631b15000000b00439e032756fsi9845444pgb.65.2022.10.09.18.57.43; Sun, 09 Oct 2022 18:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EdDl+sIQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232763AbiJJA0b (ORCPT + 99 others); Sun, 9 Oct 2022 20:26:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232749AbiJJAWf (ORCPT ); Sun, 9 Oct 2022 20:22:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DFCB60F8; Sun, 9 Oct 2022 16:56:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E123F60D57; Sun, 9 Oct 2022 23:56:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD534C433D7; Sun, 9 Oct 2022 23:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359790; bh=4PTtWdXmjg58DcnDfoqUi1D2EwzL9HhrXD/pwzSWVpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EdDl+sIQ3y4Zb16f0OJpWZrr6YpV9HBs1cnN5wO9YSN2hrJgEcwb7I6fXVv71OQgF FqK/9CQUJUjTnet2FZ4CiIksJPdNF7d+awp3mNGMgRUca3YK5HG09vTIr8qZoTLosq OObWP+W22jeulfF6/aROUtdRal41tQoA05zVJiYWzhZNaA16BsqNDYHnJAxQeUCOe4 d9iOTwZgsA/hFIfkiLVQpwv08qxUyBAGrXZgCAz43kqvZFQVnmoJteG1Ml0oO2KwTk 5RXl5HDIKRazkkH+RJKIzkohlYvQA04OvW/JCHD95mXA2qd02omFimGHmVYx7EsFOR EDi09pazlasbw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Simon Ser , Daniel Vetter , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Jani Nikula , Lyude Paul , Sasha Levin , maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.10 09/22] drm: hide unregistered connectors from GETCONNECTOR IOCTL Date: Sun, 9 Oct 2022 19:55:27 -0400 Message-Id: <20221009235540.1231640-9-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235540.1231640-1-sashal@kernel.org> References: <20221009235540.1231640-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 From: Simon Ser [ Upstream commit 981f09295687f856d5345e19c7084aca481c1395 ] When registering a connector, the kernel sends a hotplug uevent in drm_connector_register(). When unregistering a connector, drivers are expected to send a uevent as well. However, user-space has no way to figure out that the connector isn't registered anymore: it'll still be reported in GETCONNECTOR IOCTLs. The documentation for DRM_CONNECTOR_UNREGISTERED states: > The connector […] has since been unregistered and removed from > userspace, or the connector was unregistered before it had a chance > to be exposed to userspace Signed-off-by: Simon Ser Cc: Daniel Vetter Cc: Ville Syrjälä Cc: Jani Nikula Reviewed-by: Lyude Paul Link: https://patchwork.freedesktop.org/patch/msgid/20220801133754.461037-1-contact@emersion.fr Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_mode_config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index f1affc1bb679..5ec0157b1426 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -150,6 +150,9 @@ int drm_mode_getresources(struct drm_device *dev, void *data, count = 0; connector_id = u64_to_user_ptr(card_res->connector_id_ptr); drm_for_each_connector_iter(connector, &conn_iter) { + if (connector->registration_state != DRM_CONNECTOR_REGISTERED) + continue; + /* only expose writeback connectors if userspace understands them */ if (!file_priv->writeback_connectors && (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)) -- 2.35.1