Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3400499rwd; Mon, 22 May 2023 13:11:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6z1q35jAQ1JoTF4lnCGJy2dHy3O1q3ujJAg8ZhPBwjBJTIKBHNd2imuO4SQZplq075gibR X-Received: by 2002:a17:903:48a:b0:1ae:52ea:5fa6 with SMTP id jj10-20020a170903048a00b001ae52ea5fa6mr10921606plb.8.1684786285540; Mon, 22 May 2023 13:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684786285; cv=none; d=google.com; s=arc-20160816; b=E8rdclYAUy+JDK7fHwdLrvLDyyN48GS0fbQyoIXvSaEXZerBMsg3O6rL0sii+7sQl+ 7VD1SkHxybHeP9aPn1p++eiLz0YK72RpnPGFiB0GbOS9ppj11gWsL+n7OlA6rlcLSvqZ PIqA+JZpBqZKdICfcDgZ0UbNQfHJihs3Bc11T9UuWvmL3Z86dyT82ZQaRITp+ysWCE70 1LruUDklSOR3oEmiBgmpWLrDMbm6fbepWtghZ6pOiCsP/p5lQ/QcuLoIhTW183ITSNvx JAFXeqAvexBQNBHomIYJF+uknk1Q2jh3sOSC8klbHll+AiXfQvnl0eOWexoJVOPiGzPz 2Tcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=1RH0Zf6SSIW6QoBUKPWp/zoQijLydPGslM9QKv8h/5w=; b=0ZmBMPjLK2SqDBuqHJLauxzjnvf6tgPqCPxOQziJ9ueQMT5Nydoir/Q1y2NqyV1+1k wBgNDS1+Ow3JCdQLIopkbOQnZmMqhzm4f5CLQr1+OPXemhvsWl0AXGuD3iBf2ceX6bDQ Ci0rZQXl6SArGIfxSL42AAYumAVb95hj5yRqMmQq6bbhVxaySp1J74y68FDFQ62CuynJ 0VUrDYCLgoC7ONsdV+3vBeRh4ggDQZ/VL4vLQ/zqd06O6lX0THFQUbyE7h6g30UQD11e sCn1bSp0DebqVafbWcTipf75RJ43inZbbIOF/cQlIi4Fl40ZtZ/UIntNGYH6nc8w5Pdz nJYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=oph+D4WW; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jg15-20020a17090326cf00b001a69cb5f7besi4835592plb.525.2023.05.22.13.11.07; Mon, 22 May 2023 13:11:25 -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=@gmail.com header.s=20221208 header.b=oph+D4WW; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232091AbjEVTMu (ORCPT + 99 others); Mon, 22 May 2023 15:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231467AbjEVTMs (ORCPT ); Mon, 22 May 2023 15:12:48 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAED9B0 for ; Mon, 22 May 2023 12:12:47 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-96fffe11714so197518866b.0 for ; Mon, 22 May 2023 12:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684782766; x=1687374766; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=1RH0Zf6SSIW6QoBUKPWp/zoQijLydPGslM9QKv8h/5w=; b=oph+D4WWLxlnyEmFPNjgsPeJBISPU+KD4UUa9fg3DYqpUFyUcSy2A8sXDz1JY90HSj xzoIZxLys2edI8VLxZ8SUICa6hs3ltLdhVckgRuVX12qWbyO/5/P5pXToBwghYmBImM4 GxRtg+DjoFlZs2IQbw0GRuJkLAWdEq1jL02CeY8Oq1Vw/LZ24lXVPWKiu9wvC6wvwqZe 4zxJGa7IFF9hpOxgj4zYfuwN4QgxA9EJl+uW/GIm5xFwfzg32f6498xgXrNJY+sWojOs 3i26c1lUlOX7fCy8Iy8fJMXZc8FzORlXncsYSBRN0ku1dfkTcxAIO4l1uhBY/2ohh+8c +YHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684782766; x=1687374766; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1RH0Zf6SSIW6QoBUKPWp/zoQijLydPGslM9QKv8h/5w=; b=QKXjmeYwggruo91b9oQxuHElJ8YdvK/E7eihGRDFHF2JOKN3mRvyBck+egoZtnYCAg 5/si3N2Wz4V1T57QrT0UBvrIVARLq/6LDuvIwqnoMUvoVnO7OJfG+xxs/OaYy08N0qNs yuc99AbpGmIMMTXJBduNKzfJcs2cmE/zgYOEUZsAL21JXCqNOc99/POY41A8imI9oSJf ZnjpY05nBaCc3fDAutEeZ5vRoWzgd1fUQMqVmfo4mbN3FwHMhNE3zOnoAGXnNc5g41U5 INkUqvJjwNfQ+TaygWX0iBqPNyZ70NptH9s0ZEfTykbt4BhHBfyUbLuCpvdjYPSw4yGT V60A== X-Gm-Message-State: AC+VfDzkirTWfURma8qWO7mj4zZpvcnO/YX02zTjyly0RoSJQT5h3CYo z7ilSv7mPzdtvt0ydT1a4eU= X-Received: by 2002:a17:907:3fa8:b0:965:6075:d100 with SMTP id hr40-20020a1709073fa800b009656075d100mr13228831ejc.39.1684782766162; Mon, 22 May 2023 12:12:46 -0700 (PDT) Received: from ?IPV6:2a00:e180:15c4:ff00:1a51:43c9:7f06:6b44? ([2a00:e180:15c4:ff00:1a51:43c9:7f06:6b44]) by smtp.gmail.com with ESMTPSA id f24-20020a170906085800b0096f887f29d2sm3474738ejd.62.2023.05.22.12.12.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 May 2023 12:12:45 -0700 (PDT) Message-ID: <07ce00de-c686-05c6-3f27-f8857417ef10@gmail.com> Date: Mon, 22 May 2023 21:12:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH 1/2] amdgpu: validate drm_amdgpu_gem_va addrs for all ops Content-Language: en-US To: Chia-I Wu , Alex Deucher Cc: Philip Yang , Kefeng Wang , Arunpravin Paneer Selvam , Felix Kuehling , "Pan, Xinhui" , Danijel Slivka , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Mukul Joshi , Luben Tuikov , Yang Li , dri-devel@lists.freedesktop.org, Alex Deucher , =?UTF-8?Q?Christian_K=c3=b6nig?= , Suren Baghdasaryan , =?UTF-8?B?TWFyZWsgT2zFocOhaw==?= References: <20230509183301.1745462-1-olvaffe@gmail.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Am 21.05.23 um 20:49 schrieb Chia-I Wu: > On Thu, May 18, 2023 at 1:12 PM Alex Deucher wrote: >> On Wed, May 17, 2023 at 5:27 PM Chia-I Wu wrote: >>> On Tue, May 9, 2023 at 11:33 AM Chia-I Wu wrote: >>>> Extend the address and size validations to AMDGPU_VA_OP_UNMAP and >>>> AMDGPU_VA_OP_CLEAR by moving the validations to amdgpu_gem_va_ioctl. >>>> >>>> Internal users of amdgpu_vm_bo_map are no longer validated but they >>>> should be fine. >>>> >>>> Userspace (radeonsi and radv) seems fine as well. >>> Does this series make sense? >> I think so, I haven't had a chance to go through this too closely yet, >> but amdgpu_vm_bo_map() is used by ROCm as well so we'd need to make >> sure that removing the checks in patch 1 wouldn't affect that path as >> well. The changes in patch 2 look good. Also, these patches are >> missing your SOB. > Indeed. kfd_ioctl_alloc_memory_of_gpu, for example, does not validate > va. I need to keep the validation in amdgpu_vm_bo_map for it at > least. I guess it is more ideal for kfd_ioctl_alloc_memory_of_gpu to > validate, but I am not familiar with amdkfd.. > > I can keep the existing validations, and duplicate them in > amdgpu_gem_va_ioctl to cover AMDGPU_VA_OP_UNMAP/AMDGPU_VA_OP_CLEAR. The key point is that unmap and clear don't need those validations. It's perfectly valid to request unmap of an unaligned mapping, it will just fail because we can't find that mapping. Regards, Christian. > >> Thanks, >> >> Alex >> >> >> Alex