Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2534043rwl; Thu, 6 Apr 2023 11:34:57 -0700 (PDT) X-Google-Smtp-Source: AKy350aFplJciH/gBuZwMMCBnRdrRNg3VwUkx1IHFafZvSr8F4VYGXhsX2d8QRUPRhK+U5/KP5gJ X-Received: by 2002:a17:906:c254:b0:946:c60b:470b with SMTP id bl20-20020a170906c25400b00946c60b470bmr7358201ejb.63.1680806097158; Thu, 06 Apr 2023 11:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680806097; cv=none; d=google.com; s=arc-20160816; b=OtLBVC5krXt3+WKmgrLikqGdj0zD6571w75DZH1oRZCAE3+xREyuHdfFZbOCec8XdA YZ49RvhQbRP3faXhwX0vQZQLOI4CPnspCAjmWOHUjHPiFTkajwELnRlHGE9FzZtNx1j0 bY2X3Chzn6wWrqmDQ++itrA3miRdc5h5d9MNu60/7PxpdjSUlmSI/o4McAE6JbUX9IUy geexRWt3UYMlYc8oSq3t5FRtTs4IPvuGOkC3r584e5TVirLbHu1/Wp5Ehm2Td6j8UYsv gxRVM2NrRVcPd2qxDxsP0cTLBx0wDy41gLA8yShnTPjHAze1Pe8Frhj4KeZl2FgeNrvI RKHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=szXBo9Jq3I9JP7Eiu53GP1Ub68CdI9377mD9rljhepU=; b=QHwtFTtHX2odsoeua9RlPO9VFvgDS6frVkPBCG05vXh8/OGXo6NLpvyg01kb5hjVlP kBUhFnFUIwgA62WuCIfORyCVMHJgcBQ9DcTYgc1E4e/WXnQDL15GGvwwnrFmq4pgrNhz Zp44ElhR+wjGOHiukMIArtxPPAy38kuaWMCbK4ortWazCj8JP9Eq0x/4iQXLljE3zb2t XzGq9TVpAhO9zllwmD3Yu+0l7EZNvwCQZsEgSmCl0oCsAfdR60z77wPlSW+EDAcUqcYe C7i8b715EWbxmAOWVWMJmo8CJ9wnPmBFwtgAKwaPQjiAUGZdkgnpyt8ErgTjRAp11uo0 zZ6g== 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t20-20020a05640203d400b0049f1fc7bdbcsi1439161edw.624.2023.04.06.11.34.28; Thu, 06 Apr 2023 11:34:57 -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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbjDFSca convert rfc822-to-8bit (ORCPT + 99 others); Thu, 6 Apr 2023 14:32:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbjDFSc3 (ORCPT ); Thu, 6 Apr 2023 14:32:29 -0400 Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A5367AAC; Thu, 6 Apr 2023 11:32:28 -0700 (PDT) Received: by mail-ej1-f53.google.com with SMTP id cw23so3588087ejb.12; Thu, 06 Apr 2023 11:32:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680805946; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OazaTs0rIDqMjSa8VI/xlda7Ld7jBm3HLpm8D8X9bAM=; b=1hurltdCxekI5BEboqopVhRHI5xVrQbIE3eE1aRywGJVZFNuH9afnZTYcOzA9UYrmd BIQWf42L51WHhTnevlJJC2g1OniNCHk0K3/Spw6wgm9Mb07zv6o0PGyC9nwKyhMNn9ny 2Kghg4dpkfDoCH9bwF8Ae715SYPLpG4DdtFy7T6qpVllI7/wu0gPe41kBkGBWA3VzoHz WqNzmnb1bGCpPBcX9mjKauVpLfvtjTIOJfmynUVSe9N67swCYHf/3mP4anvM/7LgcSQz rF7dawwwHl4vPsYHgExTBo9wQrmv/w+wpkDCd3PKyEzpyJnDRgEjO95dOt41Qn5b0LOg 4OIw== X-Gm-Message-State: AAQBX9ebnNGbwKzZlVRjLU3pJu9SlyEss+qpV3nmdEZNdnAWnrsZFq3v kOijnC/k4b1Wn9i1dA+CmGn5yreFtYOEx5SMzPrbYW7Q X-Received: by 2002:a17:907:6d0e:b0:8b1:38d6:9853 with SMTP id sa14-20020a1709076d0e00b008b138d69853mr3752173ejc.2.1680805946548; Thu, 06 Apr 2023 11:32:26 -0700 (PDT) MIME-Version: 1.0 References: <4845957.31r3eYUQgx@kreacher> <14903668.tv2OnDr8pf@kreacher> <642e13f27c63e_21a829429@dwillia2-xfh.jf.intel.com.notmuch> In-Reply-To: <642e13f27c63e_21a829429@dwillia2-xfh.jf.intel.com.notmuch> From: "Rafael J. Wysocki" Date: Thu, 6 Apr 2023 20:32:15 +0200 Message-ID: Subject: Re: [PATCH 22/32] ACPICA: actbl2: Replace 1-element arrays with flexible arrays To: Dan Williams Cc: "Rafael J. Wysocki" , Linux ACPI , LKML , Bob Moore , Kees Cook Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Thu, Apr 6, 2023 at 2:36 AM Dan Williams wrote: > > Rafael J. Wysocki wrote: > > From: Kees Cook > > > > ACPICA commit 44f1af0664599e87bebc3a1260692baa27b2f264 > > > > 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). > > > > The sizeof() uses with struct acpi_nfit_flush_address and struct > > acpi_nfit_smbios have been adjusted to drop the open-coded subtraction > > of the trailing single element. The result is no binary differences in > > .text nor .data sections. > > > > Link: https://github.com/acpica/acpica/commit/44f1af06 > > Signed-off-by: Bob Moore > > Signed-off-by: Rafael J. Wysocki > > This one needs the following folded in to pass my tests. > > Feel free to fold and add: Done, thank you! > Co-developed-by: Dan Williams > Signed-off-by: Dan Williams > > -- >8 -- > diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c > index 981f8b0f595d..85d9d67e38a4 100644 > --- a/drivers/acpi/nfit/core.c > +++ b/drivers/acpi/nfit/core.c > @@ -894,7 +894,7 @@ static size_t sizeof_flush(struct acpi_nfit_flush_address *flush) > { > if (flush->header.length < sizeof(*flush)) > return 0; > - return sizeof(*flush) + sizeof(u64) * (flush->hint_count - 1); > + return struct_size(flush, hint_address, flush->hint_count); > } > > static bool add_flush(struct acpi_nfit_desc *acpi_desc, > diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c > index c75abb497a1a..745c4a27bc35 100644 > --- a/tools/testing/nvdimm/test/nfit.c > +++ b/tools/testing/nvdimm/test/nfit.c > @@ -1878,14 +1878,14 @@ static size_t sizeof_spa(struct acpi_nfit_system_address *spa) > static int nfit_test0_alloc(struct nfit_test *t) > { > struct acpi_nfit_system_address *spa = NULL; > + struct acpi_nfit_flush_address *flush; > size_t nfit_size = sizeof_spa(spa) * NUM_SPA > + sizeof(struct acpi_nfit_memory_map) * NUM_MEM > + sizeof(struct acpi_nfit_control_region) * NUM_DCR > + offsetof(struct acpi_nfit_control_region, > window_size) * NUM_DCR > + sizeof(struct acpi_nfit_data_region) * NUM_BDW > - + (sizeof(struct acpi_nfit_flush_address) > - + sizeof(u64) * NUM_HINTS) * NUM_DCR > + + struct_size(flush, hint_address, NUM_HINTS) * NUM_DCR > + sizeof(struct acpi_nfit_capabilities); > int i; >