Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp392316ybk; Wed, 20 May 2020 02:17:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4DURaCfWXEjEbQ+71YXV5FCfZmzGo5f6VIStm7PiPS+UoefmZEKDte/Pw3c7EM9u7/yY4 X-Received: by 2002:a17:906:f891:: with SMTP id lg17mr2778797ejb.443.1589966235404; Wed, 20 May 2020 02:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589966235; cv=none; d=google.com; s=arc-20160816; b=D7KVmnTqWSCbi5U81eOClvKTbs6Qj+7efmAum4SzAzuhnsUjwwyJbgkBJujR4CmQ+A T1In3ZtESqTHTqEr9Fb4wL5NoZyesf96AJiiR1eL6tiiMtxMbuA66tDuxkfB8M4MiwI6 e4I4DHPCvkLA0kwnYBDxNM4Lm5ezcg4oNEv/ij/ramRZ2ziQl5CHsy3bpOdSbihv6MBO EEbZAvzkKEPVYxvxFfWHZf+ZGlUDeqenxc9EOQ4H8CRyL/BB8uUTYEsuUBOaoLc0K3xM mjYrH1SrqBHl58RpNbimn2gy7zwXuuVRsqdM6HPyeclm2lkuKOcP9VAQy/TVqOpf3OV9 YfTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=bqoyHeOoEDMlB+jQwZuDNn8FHfH7mQ3PMOITKSmc9rM=; b=xYxhSs3xJCoZ5bMoaYoegXWpVEhvCDFJtrW1ZE31ZJofDsv2EITyM/twAcfjQUTtGr fScMOwHDa+JOoOlVfL5zdX+0d5nxI5094A2VE4cL7rOMxsICTZPq+1YMEMHgA1leQYYW qTZQ75rh/7cGullUYtiiGNUgwoR0Ggj2xrSQHJFEU799O7rDKCeamXoMsNsFd++L7gun B0IYPrth4wSjV5Pykd48CvLj/tGlrUa55ETfJax1Wqskoe3pTOkoDFsQOFaZPlety8X6 Ujy5JJ23bnSEvvnwNfsH8O7TeXdKkMeXie28uPEhf3nWW3Wb61LQTCmK4n36itDUWFC5 AQwA== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ob20si1311729ejb.401.2020.05.20.02.16.53; Wed, 20 May 2020 02:17:15 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726619AbgETJPc (ORCPT + 99 others); Wed, 20 May 2020 05:15:32 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:45353 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726435AbgETJPb (ORCPT ); Wed, 20 May 2020 05:15:31 -0400 Received: by mail-ot1-f65.google.com with SMTP id c3so1865179otr.12; Wed, 20 May 2020 02:15:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bqoyHeOoEDMlB+jQwZuDNn8FHfH7mQ3PMOITKSmc9rM=; b=DPxvfZqG/qRiPIHMNr4/vnu+UfEN+lEEd+HEWG3e0HDb/0Y2IQCA9o9jMNyM7cualp wuesSXYA4Ci1WBSBiR2hyMpeB0EhlgkXFIc93Ox1FlCQWRCs2qVJLW+RHOSmqGrnjwBq kXq0Kjk31AbojylE0E1rcH7hQrnTp+6Wx7CszxI5QgCS6kXfxY8bLGbVpNu5VtKhRqVx HfxqPw0wsnqkSH4wsDFLeIUdzw8O/cCvNR0CDYDkR0FGTZjyr1qprXpsVHnJKjY3EHE3 rsx2s50glQltQJt0J7WlKaO/2y13T1oLEP8fjZ3yenz7OjzR0I1UP9h812O8SOS/IO8g UuwA== X-Gm-Message-State: AOAM532XxtrZAM5MuSjzwTtMK64QTZtsL1j2jwc6BJQq6ywnmfk1qg+A eDtnF1+NL5vkk2AcU1KacnXG2mPBYjOn6L757kg= X-Received: by 2002:a9d:6356:: with SMTP id y22mr2364835otk.167.1589966129710; Wed, 20 May 2020 02:15:29 -0700 (PDT) MIME-Version: 1.0 References: <20200518222722.GA7791@embeddedor> <20200519225058.GA14138@embeddedor> In-Reply-To: <20200519225058.GA14138@embeddedor> From: "Rafael J. Wysocki" Date: Wed, 20 May 2020 11:15:18 +0200 Message-ID: Subject: Re: [PATCH] ACPICA: Replace one-element array and use struct_size() helper To: "Gustavo A. R. Silva" Cc: "Rafael J. Wysocki" , Robert Moore , Erik Kaneda , "Rafael J. Wysocki" , Len Brown , ACPI Devel Maling List , "open list:ACPI COMPONENT ARCHITECTURE (ACPICA)" , Linux Kernel Mailing List , "Gustavo A. R. Silva" , Kees Cook Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 20, 2020 at 12:46 AM Gustavo A. R. Silva wrote: > > On Tue, May 19, 2020 at 12:25:13PM +0200, Rafael J. Wysocki wrote: > > On Tue, May 19, 2020 at 12:22 AM Gustavo A. R. Silva > > wrote: > > > > > > The current codebase makes use of one-element arrays in the following > > > form: > > > > > > struct something { > > > int length; > > > u8 data[1]; > > > }; > > > > > > struct something *instance; > > > > > > instance = kmalloc(sizeof(*instance) + size, GFP_KERNEL); > > > instance->length = size; > > > memcpy(instance->data, source, size); > > > > > > but the preferred mechanism to declare variable-length types such as > > > these ones is a flexible array member[1][2], introduced in C99: > > > > > > struct foo { > > > int stuff; > > > struct boo array[]; > > > }; > > > > > > By making use of the mechanism above, we will get a compiler warning > > > in case the flexible array does not occur last in the structure, which > > > will help us prevent some kind of undefined behavior bugs from being > > > inadvertently introduced[3] to the codebase from now on. > > > > However, the ACPICA code in the kernel comes from an external project > > and changes of this type are generally not applicable to it unless > > accepted upstream. > > Hi Rafael, > > By _accepted upstream_, in this case, you mean the adoption of the > flexible-arrays in the whole codebase, first? I meant whether or not the patch is accepted by the ACPICA upstream. > If this is the case > notice that there are hundreds of these flexible-array conversions > in mainline, already: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?qt=grep&q=flexible-array > > Is this what you mean? I'm not actually sure what you mean here.