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 67469CFA468 for ; Fri, 21 Nov 2025 08:15:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ABC9210E7FC; Fri, 21 Nov 2025 08:15:15 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="O46oYf9k"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1A22D10E2B3 for ; Fri, 21 Nov 2025 08:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=BQC2ump1/ZDmiI/Ox9lbDlStDU6UDaeJiVcwbUnk2Zo=; b=O46oYf9kfnEvjjVwUYiFgAdTFo cvfIgXdOCLu4I+pVBJbF4l+SzUiSe0/ffMYcdgq58uYzJJRbyLz9OTTeRgHuAPjXWTHeUBDq0y7hC jn3yDIk3hVv/zKKJ0rtioHdMfV0sU4U1JIxDAkeR0yc0oNNtaAdf+VIYhSJvS/DkL32GzZvyhDSI7 qXICggnWGi1b1kLtgnJYg8QduPxuBhCraKGZeUasd1eKHL9GjcPjb34+7/cP9m6n//kyzbXtzMLOg Pu/O807OI3HoCxJKQjom3+1BKpHDKh25i97Laftwsx7ZrdTUKmjU4O7ggoweHKuESrEzGCCwm0CTz v4/KKqKg==; Received: from [90.240.106.137] (helo=[192.168.0.101]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1vMMIQ-003ZbU-LQ; Fri, 21 Nov 2025 09:15:10 +0100 Message-ID: Date: Fri, 21 Nov 2025 08:15:09 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] drm/gem: Use vmemdup_array_user in drm_gem_objects_lookup To: =?UTF-8?Q?Andr=C3=A9_Almeida?= Cc: kernel-dev@igalia.com, dri-devel@lists.freedesktop.org References: <20251112092732.23584-1-tvrtko.ursulin@igalia.com> <765f43f5-2cd8-400b-bb8e-2a03132268f9@igalia.com> Content-Language: en-GB From: Tvrtko Ursulin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 20/11/2025 14:55, André Almeida wrote: > Em 20/11/2025 11:53, Tvrtko Ursulin escreveu: >> >> On 20/11/2025 14:39, André Almeida wrote: >>> Hi Tvrtko, >>> >>> Em 12/11/2025 06:27, Tvrtko Ursulin escreveu: >>>> Using a helper shrinks the code and separating the user and kernel >>>> slabs >>>> is more secure. >>> >>> As in the commit message, the commit description should be writing in >>> the imperative mood. >> >> "Use a helper to shrink the code and separate the user and kernel >> slabs for better security." >> >> This sounds good? >> > > All good to me, thanks! With both observations addressed: > > Reviewed-by: André Almeida Thank you, pushed to drm-misc-next! Regards, Tvrtko > >>>> >>>> Signed-off-by: Tvrtko Ursulin >>>> --- >>>> v2: >>>>   * Remove now unused dev local. >>>> --- >>>>   drivers/gpu/drm/drm_gem.c | 13 +++---------- >>>>   1 file changed, 3 insertions(+), 10 deletions(-) >>>> >>>> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c >>>> index a1a9c828938b..68168d58a7c8 100644 >>>> --- a/drivers/gpu/drm/drm_gem.c >>>> +++ b/drivers/gpu/drm/drm_gem.c >>>> @@ -783,7 +783,6 @@ static int objects_lookup(struct drm_file *filp, >>>> u32 *handle, int count, >>>>   int drm_gem_objects_lookup(struct drm_file *filp, void __user >>>> *bo_handles, >>>>                  int count, struct drm_gem_object ***objs_out) >>>>   { >>>> -    struct drm_device *dev = filp->minor->dev; >>>>       struct drm_gem_object **objs; >>>>       u32 *handles; >>>>       int ret; >>>> @@ -798,15 +797,9 @@ int drm_gem_objects_lookup(struct drm_file >>>> *filp, void __user *bo_handles, >>>>       *objs_out = objs; >>>> -    handles = kvmalloc_array(count, sizeof(u32), GFP_KERNEL); >>>> -    if (!handles) { >>>> -        ret = -ENOMEM; >>>> -        goto out; >>>> -    } >>>> - >>>> -    if (copy_from_user(handles, bo_handles, count * sizeof(u32))) { >>>> -        ret = -EFAULT; >>>> -        drm_dbg_core(dev, "Failed to copy in GEM handles\n"); >>> >>> Why the debugged message has been removed? >> >> I should indeed have mentioned in the commit message: >> >> "While at it lets remove the useless debug message." >> >> Regards, >> >> Tvrtko >>>> +    handles = vmemdup_array_user(bo_handles, count, sizeof(u32)); >>>> +    if (IS_ERR(handles)) { >>>> +        ret = PTR_ERR(handles); >>>>           goto out; >>>>       } >>> >