Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp60368rwi; Sun, 9 Oct 2022 18:29:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7o9rosa7dkdOjyVKS9NkjPQSJF2DcHYaQ7mWQEQbJ81n7kByT3yPaBKG/4RmLA+2w7TVlK X-Received: by 2002:a63:5b5c:0:b0:440:8531:d3f6 with SMTP id l28-20020a635b5c000000b004408531d3f6mr15019958pgm.114.1665365375906; Sun, 09 Oct 2022 18:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665365375; cv=none; d=google.com; s=arc-20160816; b=NLZ81TjWnE3MrANeGQd+izw1MyoJt/3sa3EVi/RHQ0vqeBFGQCq2aXeaEG44DBodoY AyEYM6Nmb12a7Xwp9GZfNh6aOsdTA9Ru7rxBGQZMolHBqPg81lKU8fMzeSZDaeO0IXXM CTvFxdA0DFd3Dn9NB8Vq2dtBUEgXypvZA6fUE2EiRjxxEVSEOmRxcbqAtMCJcp+nsBsv LixhPEtfT9VOev9NFpSkKQZkeeigGhklRqcEe96f9teGufEeWB40v7cT5VW5Zx4WU7dA hthjVPNZVyUJupNj+Zg4sXkaRJ/r4tNlMdFZy4TcJyQX+zfhWN6tEUB8MJtIKYvuOJs1 sXAQ== 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=0lGDVFzkXvm7hq6/bEp6m9SQrSEmWyhan46nyQsUb+0=; b=bxrDgT65KUjAX/JSi1ppzvErvXkgxJS9t2E8TaWhF+iL//p7NvhF4iZuxCLfN1OneQ cqBsDi7/624nGi9Uz6rbY8jXPgIWtzP80mPVRDqBCx9gvs0z56Fms/2lnGogJxpsfVie B3kRH6y9SMejN7oz7zUpQ5mhcwopQzSFfEEfoEPwyug1aa+X3Sd/ECM4mTguvE4oVOWq Pfexl5COvEh6kfcYH1EC8LOzZ7TV7n1QkbpWVbADarqEx5qECZ1vnwM4Mra3PjhGvI6I /P82Ww723nVKhKm3N/FTLJ7sUbk5jzYqfBNUzDwfu5RJV/5bZaU2XsWl94sQZiFubmlE gyEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ljeA+8g/"; 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 p2-20020a1709026b8200b00182c500d973si594942plk.43.2022.10.09.18.29.24; Sun, 09 Oct 2022 18:29:35 -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="ljeA+8g/"; 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 S233080AbiJJA2n (ORCPT + 99 others); Sun, 9 Oct 2022 20:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232890AbiJJAXv (ORCPT ); Sun, 9 Oct 2022 20:23:51 -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 8D34417AA6; Sun, 9 Oct 2022 16:57:28 -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 2A0EE60B85; Sun, 9 Oct 2022 23:57:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CB36C433B5; Sun, 9 Oct 2022 23:57:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359847; bh=wtxgUo4zhnvlpk87k4mB93R/Fe/peDx+ezu5mX1M/54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ljeA+8g/FOEQZ7JI2x+YYBcwv4xYT0jp3qqCXTj6qDIeUkLNgQxDuyCq82G/Sx58c uZadY+T6ZJ4K3qkGFHaDhGePSNgEo4BgGdooMfgIjs65C2Hecm3nPKsEFlSUNMgtS4 j1wRypQchTfd7Tak/AZEOqhXtzg+jjjO/U99QJUGw2kdyx0R/zxcn4QyyyJgo5akfj hh3iWCFv8BPL7frtoY1We8WV/3phBMrtNExNNk1+Zx4lNyPhmfytCANAcvHVMevpZg +ihx007LE6rDLZj4ZM2aH6+3iHYxD06x+FjxC1K7rT0HX78CHp8tUUfkpb4TJo4nxy /19dFC7Aft7tg== 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.4 06/14] drm: hide unregistered connectors from GETCONNECTOR IOCTL Date: Sun, 9 Oct 2022 19:57:02 -0400 Message-Id: <20221009235710.1231937-6-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235710.1231937-1-sashal@kernel.org> References: <20221009235710.1231937-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 7bc03c3c154f..54cd2b7acccc 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -148,6 +148,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