Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp64693rwi; Sun, 9 Oct 2022 18:35:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM623CbzVXet9qD84lyi7JPZYqWHHcwyhPIDi78XX91uoMIOpwGZO52dwV7vn5XsSwp1d5YH X-Received: by 2002:a17:902:690a:b0:17a:32d:7acc with SMTP id j10-20020a170902690a00b0017a032d7accmr16602124plk.18.1665365701967; Sun, 09 Oct 2022 18:35:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665365701; cv=none; d=google.com; s=arc-20160816; b=AIVAp3hkyph7PnwLLsu6xXtYsjF8lJfAgCM7VmIGk3kQlATIkn8h3GSQ7VfxjhoqD+ p48+UAvq7rzRHLvyAJ+vBjafzz0c9mhoMfJ8MTfR0aVnVKtO5tiXTtgAroZmxL8f8uzG nI/xWOmlx/eu19Tc6GchmNJOMVu3qkIVxo8kCn/GaQKqGiK63uQzMa4IfmtFK4svLokC TuBkvWRadHzLRot/SR41xVbMVJiWuAqWdhl53NpDNKzMu7Jp5V8FK3WYN755uwypHGla 3m3eMVXLRl7HftDa/AjBW/cfCrkwXlGcCUTQnS2at1a4trJY+Vn/SHGqNdFYZLqYNmI/ JFLA== 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=EwSJGF3mHMCZOnht9BZVOnCMNDGDIsnYxiq/ILwUNzY=; b=tjuSxmvreSEwpKs8o83BgaV4mf+dVxDWbBrptXNStHF5Vx7RAn/WqKTpv850iEZur+ MyzLynoOgWjfr9NK8rvPWKLWcAFnNGVAE7ER/38ma0m0LajKyR0n/gB8w5yLmKdAzY5l Ct14RPeQokWyuhYSTkSJ12mojEDviNfzGRM5zJvk0PiM3OS1doryUKpc0y7LdJ5rsHbs y3oK3oVoBwtEcSOMT90CbDrz8/aZE44n4dm+UiyBgYXXIMa0Bp1aJ2JrhCuegrFvqjzT Ks7wEJFrnwm2vU7M0CcQcr08y05BnOAlWpsPaWZmuH7zGMV79ddjvVkbr6RH9BgIQvaL RYxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lWSEUmcv; 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 w18-20020a170902e89200b0017f93a4e32dsi11668141plg.0.2022.10.09.18.34.50; Sun, 09 Oct 2022 18:35:01 -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=lWSEUmcv; 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 S233312AbiJJA3R (ORCPT + 99 others); Sun, 9 Oct 2022 20:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232960AbiJJAX5 (ORCPT ); Sun, 9 Oct 2022 20:23:57 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 655EADF4F; Sun, 9 Oct 2022 16:57:59 -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 sin.source.kernel.org (Postfix) with ESMTPS id C76C0CE0F72; Sun, 9 Oct 2022 23:57:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4254C433D6; Sun, 9 Oct 2022 23:57:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359876; bh=dScKUJ0nPhkOV39awHXuLIp/Z907A7aNO1i/uZNzfkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lWSEUmcv40Cnp54id0+OkUT2HvFV2TqtwMKerhTPp55RMccjtLX7yqB1NfmNX8ket rMCUeyy7X6oq6kYFkwhKyhT+AGPBLe6qlxJX0kwwjtjbs/ytDI/hUTrYe/lGirWVCc nCnmJMX3olZUXtI4NLhc1iATf2Ff1BpdP9s+QwFxHuY4MqVM+xZn3WLiOzqJ6mWgf2 1Z5bgJ1p3guHH20+mpCMkUtGTiX2T3ErfZ5Wiowro1xmoB4JrXcSsf9Dt5OH4LJCg8 DqNEy/HMBdJlDmcEIMzP4sA/mmT9OdX9zbvRzDqTSiuysefejT9pxYdWjp/keem/Cj YiSfyuk0gPvpA== 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 4.19 04/10] drm: hide unregistered connectors from GETCONNECTOR IOCTL Date: Sun, 9 Oct 2022 19:57:39 -0400 Message-Id: <20221009235746.1232129-4-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235746.1232129-1-sashal@kernel.org> References: <20221009235746.1232129-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 21e353bd3948..acbe78f6e0d1 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -145,6 +145,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