From patchwork Wed Apr 5 13:51:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 79663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp346026vqo; Wed, 5 Apr 2023 07:22:29 -0700 (PDT) X-Google-Smtp-Source: AKy350ZQismmx+ELWSBO3H9I5Mn+nzubUKT4Gq1VU/jp0QSKD2TdwfLXT4I2kZt+g83r8BahhWih X-Received: by 2002:a05:6a21:868f:b0:d4:fcb2:7966 with SMTP id ox15-20020a056a21868f00b000d4fcb27966mr2753778pzb.11.1680704549040; Wed, 05 Apr 2023 07:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680704549; cv=none; d=google.com; s=arc-20160816; b=jxZtJ9E+cEQOWn7HBUpnO3ASUp8xTR9oX3Xxv7CBgGLB0rTVjWYkuJX2dJ9WqaF2EF jLJuJSj7POhsWpHq4WeZMwbfRRJNvqZo76023PmcBZxaXQ7vyu+xt64vsroRDN2w5ajc V1LYXCSFXeoHgOGbXcoPNYHVdS7HpfXx2wXqtuAM1Bnt+MYYnidvx1e6RMV6VE+EMviD mn2ZXilFPPr0+TJDJywVrvcnLnqyCdLdfN1XsLOy8GKyWfC5pm05ENy21xlEKyDu9EqR QDLHyJdFaRZ/q7qdJ+sTabsrx2CP5lubR2wn1Ct6rbNEDwXAVBOXqmKg6AW57PezyBfx lzkQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=A6FvSd3JGFigbHlJPqVT5mg94ehGHiiiGiumNqHZu9k=; b=Z2/vkgVJtvL/CMkbai/wzc9gumBotRLrgh9sc0vUS/AzI8/zXPUZizXC4SOGhPTr8X Qbkkgpv4N9k0zbI5IW+L5Btyhvm15oyevwKzvPbNcxHlo2nB4zL2nV36xkyTTAPkkUAm 3CgRJeTqEqIU4J2rdlDm/G8fH2ve7tGElPChRZD1eGa6KyTP6MF8aQnK2o4Ydpp5vrqw E257h2eWCPHmR+hEyJb2BlRE0wKMOG04ZawicyyXSc05eXZ4MNPb5EVwq81EUPgLx3Jj Q8MvocIbYNagKCNmq9qphGZJvQIOYsWSZ3bn7ije6qAMzyopkCchw9IAWMdpf0w/Mc64 DNOg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a1-20020aa795a1000000b0062ab3f36b11si12504830pfk.129.2023.04.05.07.22.16; Wed, 05 Apr 2023 07:22:29 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238343AbjDEOBf (ORCPT + 99 others); Wed, 5 Apr 2023 10:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238278AbjDEOBC (ORCPT ); Wed, 5 Apr 2023 10:01:02 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AB786182; Wed, 5 Apr 2023 07:00:52 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 2baca87f8f83e7cf; Wed, 5 Apr 2023 16:00:51 +0200 Received: from kreacher.localnet (unknown [213.134.163.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 7FD111B4EA62; Wed, 5 Apr 2023 16:00:50 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Bob Moore , Kees Cook , Dan Williams Subject: [PATCH 23/32] ACPICA: struct acpi_nfit_interleave: Replace 1-element array with flexible array Date: Wed, 05 Apr 2023 15:51:25 +0200 Message-ID: <2652195.BddDVKsqQX@kreacher> In-Reply-To: <4845957.31r3eYUQgx@kreacher> References: <4845957.31r3eYUQgx@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.163.219 X-CLIENT-HOSTNAME: 213.134.163.219 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdejuddgjeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepledtieekkeekveeikeetgffgteeuteefjeevjeegudelvdduheeiuedvieehieevnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkphepvddufedrudefgedrudeifedrvdduleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrdduieefrddvudelpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeehpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhosggvrhhtrdhmohhorhgvsehinhhtvghlrdgtohhmpdhrtghpthhtohepkhgvvghssehouhht fhhluhigrdhnvghtpdhrtghpthhtohepuggrnhdrjhdrfihilhhlihgrmhhssehinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762346453163383941?= X-GMAIL-MSGID: =?utf-8?q?1762346453163383941?= From: Kees Cook ACPICA commit e66decc6fca36b59194b0947d87d6a9bec078bc3 Similar to "Replace one-element array with flexible-array", replace the 1-element array with a proper flexible array member as defined by C99. This allows the code to operate without tripping compile-time and run- time bounds checkers (e.g. via __builtin_object_size(), -fsanitize=bounds, and/or -fstrict-flex-arrays=3). Unlike struct acpi_nfit_flush_address and struct acpi_nfit_smbios, which had their sizeof() uses adjusted in code, struct acpi_nfit_interleave did not. This appears to have been a bug. After this change, there is a binary difference in acpi_dm_dump_nfit() since the size of the structure now has the correct size, as the prior result was including the trailing U32: - mov $0x14,%ebp + mov $0x10,%ebp Link: https://github.com/acpica/acpica/commit/e66decc6 Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki Reviewed-by: Dan Williams Tested-by: Dan Williams --- drivers/acpi/nfit/core.c | 2 +- include/acpi/actbl2.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 981f8b0f595d..a398f32dfd68 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -3476,7 +3476,7 @@ static __init int nfit_init(void) BUILD_BUG_ON(sizeof(struct acpi_table_nfit) != 40); BUILD_BUG_ON(sizeof(struct acpi_nfit_system_address) != 64); BUILD_BUG_ON(sizeof(struct acpi_nfit_memory_map) != 48); - BUILD_BUG_ON(sizeof(struct acpi_nfit_interleave) != 20); + BUILD_BUG_ON(sizeof(struct acpi_nfit_interleave) != 16); BUILD_BUG_ON(sizeof(struct acpi_nfit_smbios) != 8); BUILD_BUG_ON(sizeof(struct acpi_nfit_control_region) != 80); BUILD_BUG_ON(sizeof(struct acpi_nfit_data_region) != 40); diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index 6d3251ea4c53..a51fd4090d27 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -1700,7 +1700,7 @@ struct acpi_nfit_interleave { u16 reserved; /* Reserved, must be zero */ u32 line_count; u32 line_size; - u32 line_offset[1]; /* Variable length */ + u32 line_offset[]; /* Variable length */ }; /* 3: SMBIOS Management Information Structure */