Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1906605pxb; Mon, 23 Aug 2021 07:25:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbQ0uMzMuL1Ig5MEPdvRPJMxBnEk4T1ew9GycWwxwEX1JEASg/AkyosW1Sj6ZdnWBJglVD X-Received: by 2002:a05:6638:2284:: with SMTP id y4mr30666679jas.75.1629728737032; Mon, 23 Aug 2021 07:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629728737; cv=none; d=google.com; s=arc-20160816; b=Cu+/W400N492XYRmcLN7k7Smc3dt0fZkvH7c/0io8BpV4rxe6UKpUH/+gz2uYMB/9O utLvdFdFBcd9IospuDWhJPboWtFm3LcYbUgwL8oBDIu9h4xidY/emr6u9zbfwvqHJgw2 tMvf1CvZGUxZjXXw17wrSrz0ne5LjJGn3LopYB4zsmW7TDgQC3wwuuBFU4MAa8siTHbI bx1JMDSbgPm5ynwaEFyCTswj6SjSvBkU60mco8ZC0Qw4m5JTSR9rpY+oEWdewQQzvxJ1 Kn522eSc7CK54NxzFlF+wZ92SHfBSyu3M+T0j5WpLzM0edpLnBCJU27p6NxRdhMqkQnw skdw== 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 :message-id:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature; bh=WtsUEsqMTxeu0ASY9ZGldGWSKXK/Bt2mBtS4t1K1jok=; b=eKt++Edn1Y0bJ9g99qzQURGkwzQaXnPfiT/BMMSAKRLq6rbFtFtDn5oFZomc6DOBRt Z6jYiOb5J2UIR03I/Bh3K6gGL5R/tssjnNdDEJ5qWfNxsRtohWnVIC6h/EULgxkxysjB b/89nOT0X1NG4M/XJXrHsRBgSO2jXlVOV663RMR/jSZej3awAaqIAzHfxqdpnaCnx5UV aBIAG8eYHpkwM3ZKagctH+KJERSsDglb1vuf9NrpU+NwwQrSzHVa6FiUgXo5r/1Rcybe 2DdGYnNwROnCuAPqKa8SCWrrlzKSrFT25+dia5nfaG02y0063eXwADT0CnwD+LkNnDhz 4R3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Twno2VV6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o14si17263472ilj.89.2021.08.23.07.25.24; Mon, 23 Aug 2021 07:25:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Twno2VV6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229743AbhHWOYF (ORCPT + 99 others); Mon, 23 Aug 2021 10:24:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbhHWOYE (ORCPT ); Mon, 23 Aug 2021 10:24:04 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0FC2C061575 for ; Mon, 23 Aug 2021 07:23:21 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id e1so3299668plt.11 for ; Mon, 23 Aug 2021 07:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:user-agent:in-reply-to:references :message-id:mime-version:content-transfer-encoding; bh=WtsUEsqMTxeu0ASY9ZGldGWSKXK/Bt2mBtS4t1K1jok=; b=Twno2VV6Mfpk9mFt1zef4nXG4k9+uk+hiqK3q7qn6xzeS8fqb9Sd0RsRYk+AW49Sup kwtvnA0rQxXUqxgPFcN5FFmZ1DHdc6mRIoougB08bPum5ctx5mGdYBLMBllI20ZQwywX GsosFTC7bkpcR7C+TuJ+4VIi+eYChTNMCf2uA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:user-agent:in-reply-to :references:message-id:mime-version:content-transfer-encoding; bh=WtsUEsqMTxeu0ASY9ZGldGWSKXK/Bt2mBtS4t1K1jok=; b=j9dA29FElsHTIQJETlxwztUlHdxGaD2mZuwaSYYihucRkFLNFyKKgG5olUNdK9IbQN hCr5EyWYl/xjZUqUXoTlj4YM5xWCjyfRZwtC9D9H1kWh3hKmXbDpoepfGfE1pPMTXU3j LeehIzbh8+c44mIC69dwvgaxabCcmFc7GiqB7vttnagxU1UGdKGkfDxmREBCrekl11ee Z9fX2sXxqVt7EVDDSgYRHHwhizoVRmkDXA5x54qjYhysP0/TZzD0N2VtBXdbzUgW+gqF Ar89oG/lXmKyTLclpNQMKOBoYX1oDMcnJ9Js54qhZ2rPqxJiYUyvrIz807W+lPBVmufL Xj0g== X-Gm-Message-State: AOAM532rWoiidMyRTEY/vbspd6HTO5WW5DSP2cQfuouwqmwxHS7pyB5/ z/G70ETOF+3dSHi199GEcnnzww== X-Received: by 2002:a17:90b:4b84:: with SMTP id lr4mr20672140pjb.32.1629728601332; Mon, 23 Aug 2021 07:23:21 -0700 (PDT) Received: from [127.0.0.1] ([67.219.225.50]) by smtp.gmail.com with ESMTPSA id 10sm16158814pjc.41.2021.08.23.07.23.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Aug 2021 07:23:20 -0700 (PDT) Date: Mon, 23 Aug 2021 07:23:14 -0700 From: Kees Cook To: =?ISO-8859-1?Q?Christian_K=F6nig?= , Lijo Lazar CC: "Pan, Xinhui" , David Airlie , Daniel Vetter , Hawking Zhang , Feifei Xu , Likun Gao , Jiawei Gu , Evan Quan , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Alex Deucher , Luben Tuikov , Andrey Grodzovsky , Dennis Li , Sathishkumar S , Jonathan Kim , Kevin Wang , David M Nieto , Kenneth Feng , Lee Jones , John Clements , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: =?US-ASCII?Q?Re=3A_=5BPATCH=5D_drm/amd/pm=3A_And_destina?= =?US-ASCII?Q?tion_bounds_checking_to_struct_copy?= User-Agent: K-9 Mail for Android In-Reply-To: <4922d89d-1293-7b32-d684-c731c246e6c1@amd.com> References: <20210819201441.3545027-1-keescook@chromium.org> <4922d89d-1293-7b32-d684-c731c246e6c1@amd.com> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On August 22, 2021 11:28:54 PM PDT, "Christian K=C3=B6nig" wrote: > > >Am 19=2E08=2E21 um 22:14 schrieb Kees Cook: >> [=2E=2E=2E] >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu=2Eh b/drivers/gpu/drm/am= d/amdgpu/amdgpu=2Eh >> index 96e895d6be35=2E=2E4605934a4fb7 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu=2Eh >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu=2Eh >> @@ -1446,4 +1446,29 @@ static inline int amdgpu_in_reset(struct amdgpu_= device *adev) >> { >> return atomic_read(&adev->in_gpu_reset); >> } >> + >> +/** >> + * memcpy_trailing - Copy the end of one structure into the middle of = another >> + * >> + * @dst: Pointer to destination struct >> + * @first_dst_member: The member name in @dst where the overwrite begi= ns >> + * @last_dst_member: The member name in @dst where the overwrite ends = after >> + * @src: Pointer to the source struct >> + * @first_src_member: The member name in @src where the copy begins >> + * >> + */ >> +#define memcpy_trailing(dst, first_dst_member, last_dst_member, \ >> + src, first_src_member) \ > >Please don't add a function like this into amdgpu=2Eh, especially when it= =20 >is only used by the SMU code=2E Sure, I'm happy to move it=2E It wasn't clear to me which headers were con= sidered "immutable"=2E Which header should I put this in? >And please give it an amdgpu_ prefix so that we are not confusing it=20 >with a core function=2E Sure, I will include that=2E >Apart from that looks good to me=2E Thanks! -Kees