From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF3B4C433F5 for ; Thu, 28 Apr 2022 15:00:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F164810E06C; Thu, 28 Apr 2022 15:00:48 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by gabe.freedesktop.org (Postfix) with ESMTP id 4EF3710E06C for ; Thu, 28 Apr 2022 15:00:47 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8C59E1477 for ; Thu, 28 Apr 2022 08:00:46 -0700 (PDT) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4FA143F774 for ; Thu, 28 Apr 2022 08:00:46 -0700 (PDT) Date: Thu, 28 Apr 2022 16:00:42 +0100 From: Liviu Dudau To: Steven Price Subject: Re: [PATCH] drm/plane: Move range check for format_count earlier Message-ID: References: <20211203102815.38624-1-steven.price@arm.com> <0b3136fa-8fd1-5496-812e-c03e430da84a@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0b3136fa-8fd1-5496-812e-c03e430da84a@arm.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Thomas Zimmermann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu, Apr 28, 2022 at 12:57:52PM +0100, Steven Price wrote: > On 03/12/2021 13:08, Liviu Dudau wrote: > > On Fri, Dec 03, 2021 at 10:28:15AM +0000, Steven Price wrote: > >> While the check for format_count > 64 in __drm_universal_plane_init() > >> shouldn't be hit (it's a WARN_ON), in its current position it will then > >> leak the plane->format_types array and fail to call > >> drm_mode_object_unregister() leaking the modeset identifier. Move it to > >> the start of the function to avoid allocating those resources in the > >> first place. > >> > >> Signed-off-by: Steven Price > > > > Well spotted! > > > > Reviewed-by: Liviu Dudau > > > > I'm going to wait to see if anyone else has any comments before I'll merge this into > > drm-misc-fixes (or should it be drm-misc-next-fixes?) > > Gentle ping! I think we've probably waited long enough. Are you going to > merge this or would you like me to? Apologies for dropping this! I will push this one today. Best regards, Liviu > > Thanks, > > Steve > > > Best regards, > > Liviu > > > >> --- > >> drivers/gpu/drm/drm_plane.c | 14 +++++++------- > >> 1 file changed, 7 insertions(+), 7 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c > >> index 82afb854141b..fd0bf90fb4c2 100644 > >> --- a/drivers/gpu/drm/drm_plane.c > >> +++ b/drivers/gpu/drm/drm_plane.c > >> @@ -249,6 +249,13 @@ static int __drm_universal_plane_init(struct drm_device *dev, > >> if (WARN_ON(config->num_total_plane >= 32)) > >> return -EINVAL; > >> > >> + /* > >> + * First driver to need more than 64 formats needs to fix this. Each > >> + * format is encoded as a bit and the current code only supports a u64. > >> + */ > >> + if (WARN_ON(format_count > 64)) > >> + return -EINVAL; > >> + > >> WARN_ON(drm_drv_uses_atomic_modeset(dev) && > >> (!funcs->atomic_destroy_state || > >> !funcs->atomic_duplicate_state)); > >> @@ -270,13 +277,6 @@ static int __drm_universal_plane_init(struct drm_device *dev, > >> return -ENOMEM; > >> } > >> > >> - /* > >> - * First driver to need more than 64 formats needs to fix this. Each > >> - * format is encoded as a bit and the current code only supports a u64. > >> - */ > >> - if (WARN_ON(format_count > 64)) > >> - return -EINVAL; > >> - > >> if (format_modifiers) { > >> const uint64_t *temp_modifiers = format_modifiers; > >> > >> -- > >> 2.25.1 > >> > > > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABCF9C433EF for ; Thu, 28 Apr 2022 15:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348719AbiD1PEO (ORCPT ); Thu, 28 Apr 2022 11:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348739AbiD1PEA (ORCPT ); Thu, 28 Apr 2022 11:04:00 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BD7A1B3C5A for ; Thu, 28 Apr 2022 08:00:45 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8A0F11474 for ; Thu, 28 Apr 2022 08:00:45 -0700 (PDT) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4E1173F774 for ; Thu, 28 Apr 2022 08:00:45 -0700 (PDT) Date: Thu, 28 Apr 2022 16:00:42 +0100 From: Liviu Dudau To: Steven Price Cc: David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann Subject: Re: [PATCH] drm/plane: Move range check for format_count earlier Message-ID: References: <20211203102815.38624-1-steven.price@arm.com> <0b3136fa-8fd1-5496-812e-c03e430da84a@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <0b3136fa-8fd1-5496-812e-c03e430da84a@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 28, 2022 at 12:57:52PM +0100, Steven Price wrote: > On 03/12/2021 13:08, Liviu Dudau wrote: > > On Fri, Dec 03, 2021 at 10:28:15AM +0000, Steven Price wrote: > >> While the check for format_count > 64 in __drm_universal_plane_init() > >> shouldn't be hit (it's a WARN_ON), in its current position it will then > >> leak the plane->format_types array and fail to call > >> drm_mode_object_unregister() leaking the modeset identifier. Move it to > >> the start of the function to avoid allocating those resources in the > >> first place. > >> > >> Signed-off-by: Steven Price > > > > Well spotted! > > > > Reviewed-by: Liviu Dudau > > > > I'm going to wait to see if anyone else has any comments before I'll merge this into > > drm-misc-fixes (or should it be drm-misc-next-fixes?) > > Gentle ping! I think we've probably waited long enough. Are you going to > merge this or would you like me to? Apologies for dropping this! I will push this one today. Best regards, Liviu > > Thanks, > > Steve > > > Best regards, > > Liviu > > > >> --- > >> drivers/gpu/drm/drm_plane.c | 14 +++++++------- > >> 1 file changed, 7 insertions(+), 7 deletions(-) > >> > >> diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c > >> index 82afb854141b..fd0bf90fb4c2 100644 > >> --- a/drivers/gpu/drm/drm_plane.c > >> +++ b/drivers/gpu/drm/drm_plane.c > >> @@ -249,6 +249,13 @@ static int __drm_universal_plane_init(struct drm_device *dev, > >> if (WARN_ON(config->num_total_plane >= 32)) > >> return -EINVAL; > >> > >> + /* > >> + * First driver to need more than 64 formats needs to fix this. Each > >> + * format is encoded as a bit and the current code only supports a u64. > >> + */ > >> + if (WARN_ON(format_count > 64)) > >> + return -EINVAL; > >> + > >> WARN_ON(drm_drv_uses_atomic_modeset(dev) && > >> (!funcs->atomic_destroy_state || > >> !funcs->atomic_duplicate_state)); > >> @@ -270,13 +277,6 @@ static int __drm_universal_plane_init(struct drm_device *dev, > >> return -ENOMEM; > >> } > >> > >> - /* > >> - * First driver to need more than 64 formats needs to fix this. Each > >> - * format is encoded as a bit and the current code only supports a u64. > >> - */ > >> - if (WARN_ON(format_count > 64)) > >> - return -EINVAL; > >> - > >> if (format_modifiers) { > >> const uint64_t *temp_modifiers = format_modifiers; > >> > >> -- > >> 2.25.1 > >> > > > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯