From patchwork Wed Aug 16 18:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13355545 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 8BCFBC001DF for ; Wed, 16 Aug 2023 18:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345316AbjHPSDK (ORCPT ); Wed, 16 Aug 2023 14:03:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345347AbjHPSDH (ORCPT ); Wed, 16 Aug 2023 14:03:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2B9210C0; Wed, 16 Aug 2023 11:03:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6F20961F66; Wed, 16 Aug 2023 18:03:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1956C433C8; Wed, 16 Aug 2023 18:03:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692208985; bh=VZCc7I2wrs8o5Tj4LQsDy02WJ+lFyAmZfvikJnnhvOg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=URUt50Lpu68AZjwzUK65AbwaSQMzaypOHt0B77/aYMGDuEvcrVRbCP1+MjGsLnBHW rzrOzJrT2weHVZqP8tm26Qd/4bIXcDmqiLZe2hrRijXVql6cwBrIIxUpsDXz+dsYBU 5cJb3E4/oK2SuTx8o3zmWvchiZHqLyzyjoUBoyqpT4o7hasfl+FkU2RbrdNKyzAWHT BWUtyLZzYstMWrB4xb2TRrxtWrtYkZ1QmyYJ3V6IEfpn9q5NdHvLA4XjO8PCcUJjdU XPzFthtDC41qhifOl7rC0jhRrqL78Asq6GZcISPt9FnNQ8K1q8OoJzfpauWfxnX3CV EBYQGtj5L6+lg== Date: Wed, 16 Aug 2023 12:04:06 -0600 From: "Gustavo A. R. Silva" To: Ben Skeggs , Karol Herbst , Lyude Paul , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm Message-ID: <087a1c335228bd245192bbb2fb347c9af1be5750.1692208802.git.gustavoars@kernel.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org One-element and zero-length arrays are deprecated. So, replace one-element array in struct nouveau_svm with flexible-array member. This results in no differences in binary output. Link: https://github.com/KSPP/linux/issues/338 Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- drivers/gpu/drm/nouveau/nouveau_svm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index 186351ecf72f..00444ad82d18 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -67,7 +67,7 @@ struct nouveau_svm { struct nouveau_svmm *svmm; } **fault; int fault_nr; - } buffer[1]; + } buffer[]; }; #define FAULT_ACCESS_READ 0 @@ -1063,7 +1063,7 @@ nouveau_svm_init(struct nouveau_drm *drm) if (drm->client.device.info.family > NV_DEVICE_INFO_V0_PASCAL) return; - if (!(drm->svm = svm = kzalloc(sizeof(*drm->svm), GFP_KERNEL))) + if (!(drm->svm = svm = kzalloc(struct_size(drm->svm, buffer, 1), GFP_KERNEL))) return; drm->svm->drm = drm; From patchwork Wed Aug 16 18:05:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13355546 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 92207C04A6A for ; Wed, 16 Aug 2023 18:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239479AbjHPSEO (ORCPT ); Wed, 16 Aug 2023 14:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345401AbjHPSEH (ORCPT ); Wed, 16 Aug 2023 14:04:07 -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 7A3FE10C0; Wed, 16 Aug 2023 11:04:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0F3E762E25; Wed, 16 Aug 2023 18:04:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63FB9C433C8; Wed, 16 Aug 2023 18:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692209045; bh=VIZplUQWDEfLgSE4zA0pe93EPJ0XYGhoZfQF7z/VLtM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SjvIipi7hME4kMUUM9gbC7AP8Oud5NAyZstGoIaGq46r1E725MsBb8ZJe17xQUcVg 8iZ8mgVgf2CHcT2E5o5DG0HitZiK1rdtbqHjfBpT+N/NBnj668l4vXaqc/udxBHWwt XvfkN3mArqgwbtwNVzX08QayJjDbaal2EpRJhFBLJJf+NPHprpfMkFxm9R4SZV8V81 zGZ6TKPlyIp+MkEaxT8VTOQU3b7pUxsluRp87BPVTo+m9/x3ulrUucAZfB9aHMmrRg vIHupO4thIkfzft0S1KShhglVzK1F7MqhJotjQM7N4E8sVNKi6TEMYYt2j6Gda4nvb w4HRE/I1vIpXw== Date: Wed, 16 Aug 2023 12:05:06 -0600 From: "Gustavo A. R. Silva" To: Ben Skeggs , Karol Herbst , Lyude Paul , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH 2/2][next] nouveau/svm: Split assignment from if conditional Message-ID: <6b900e80b5587187c68efc788f5b042ca747d374.1692208802.git.gustavoars@kernel.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Fix checkpatch.pl ERROR: do not use assignment in if condition. Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- drivers/gpu/drm/nouveau/nouveau_svm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index 00444ad82d18..cc03e0c22ff3 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -1063,7 +1063,8 @@ nouveau_svm_init(struct nouveau_drm *drm) if (drm->client.device.info.family > NV_DEVICE_INFO_V0_PASCAL) return; - if (!(drm->svm = svm = kzalloc(struct_size(drm->svm, buffer, 1), GFP_KERNEL))) + drm->svm = svm = kzalloc(struct_size(drm->svm, buffer, 1), GFP_KERNEL); + if (!drm->svm) return; drm->svm->drm = drm;