Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp64127rwi; Sun, 9 Oct 2022 18:34:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5yyt1FuKVqHzKqJFkUl6A7/4VMpZS7YLXwVVHhGu6i7YIP8T29lGbVso9HUR+bhKG8lPGq X-Received: by 2002:a17:90b:3e81:b0:20a:81b2:bc3 with SMTP id rj1-20020a17090b3e8100b0020a81b20bc3mr28525927pjb.60.1665365658215; Sun, 09 Oct 2022 18:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665365658; cv=none; d=google.com; s=arc-20160816; b=ksndATP+t6Rq5Tgq8pBlMHNQ94DJQSUgfFsQ2FLVMkoZir2NctAv4l1AlD626Wx3Fh ATsHRMDRBV97ROtLehhT2BJ2POkJAoemgNagasioH6w4vW5tjJvuABXxlVdDDw7ddKh6 BpvrExSApknoVg23l/7xFvn4EEH8MApwVQlSOOwPJP3DdGaFqDH6cRgnZHRPK0tAJwsf FvBZBuj1ETQ9066pISsGCnL+YnFXp77DF4V9i5N8kZAU5ZxBeIsVyUIEW/Dtio78UCah zfeAvMykcrpz53Ww8aIyh2v/3pF+/va/jikZ3DIfj9lfykxciv8nzj1V/NY1xKNiE93i 10/A== 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=PN4IKXMfeMtL+/qgolwb6FTMO6TWL9oqe3ubIuRLZrY=; b=h8Su5aAM8bE+EKoNx1bvW7Tq0vaUKPcrsCuz9zQOjSlGCACoI6GhKQM4IB/0DUOuGw MUhPI1MnE35yjineNE5+IzqGpx/rAin6Wh0zcXDzf4hqIXks6M+Dme8AsIA8jKJiqMH1 3+cPmu4JQzeOdBOodEnWjBAF4HTwFHCPHFjvBqtrPEKAsJWViu4SEgsM0bvqqIW2ZCrh pGxs8dEXW/2XYgDYXArPi8y2f1BDQ5K73uLDB8HJohq8AhmcYWIMJksEQyJBbCSGK8QO 4I05tGbpP3KfUkcxrFh3ctyo97weZ7ecYk9vf3FLEPs1BYf9u8tdgjlkkRVG+Dk1UmnZ 6DDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="rZ8V1/D6"; 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 e13-20020a170902ef4d00b00179cf094dccsi10268949plx.526.2022.10.09.18.34.06; Sun, 09 Oct 2022 18:34:18 -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="rZ8V1/D6"; 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 S232572AbiJJAWK (ORCPT + 99 others); Sun, 9 Oct 2022 20:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232506AbiJJAUI (ORCPT ); Sun, 9 Oct 2022 20:20:08 -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 EDCAA13DCB; Sun, 9 Oct 2022 16:54:52 -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 2FF7760CF5; Sun, 9 Oct 2022 23:54:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D66BC433D7; Sun, 9 Oct 2022 23:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359691; bh=E8lnajgY5yjgmA9Ze197EDHKNzbkkiNgzzOdflXRywI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rZ8V1/D6Zw5gwz0jHIuImDbabWO4XClbv5KNGLakWEg2hKk67vMl4k1jueAu0OSKM RAbuXvSha2bUQlmoC38W7d7t5fqDtvueLG/2MJzS+ibWE3I0OjXLP3kDDhNdKB8o3Z XZELkuezVOKs9+RocBA8269gEPIyxbNwe7yZrD1Ciipc+/c2CSGcVB6RNLoLHmLwgQ bBqaz3cioQPSALNhh00YitQyufLE43kH5PnyCcrnisMb8+WQVJH/yDKZISSIRbTluZ Trrrt11Y3USFuTbadWr7SNaKFVeZvML7YENEtR81/HLrSqSCB0UpsjZ0MptPYEFiOC oc2sJQIngmxvw== 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.15 10/25] drm: hide unregistered connectors from GETCONNECTOR IOCTL Date: Sun, 9 Oct 2022 19:54:10 -0400 Message-Id: <20221009235426.1231313-10-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235426.1231313-1-sashal@kernel.org> References: <20221009235426.1231313-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 37b4b9f0e468..6a326b41d193 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