From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59A82C35280 for ; Fri, 8 May 2020 02:52:39 +0000 (UTC) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0664F20731 for ; Fri, 8 May 2020 02:52:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="alSxzR9x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0664F20731 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=paul-moore.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-audit-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588906357; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=F+rY43UAdrhHSUHHjU9E4ThhDKkx0Z4uU3dNNFkmVtk=; b=alSxzR9xuzmwmQ0j5gAw3Qrhh0plrzI6E/ufaBYi2i4N6SekCnLA1XOvdqINOVnbMso4C9 Za9Ha0Z8vButh/hNex7ukB6fexbUEfm2qGIHYSPq+SPCZw2aymcqnVBYubgMVq35cawuAQ rIOEcy6lk5WRvln0hhQqWuuv2WbxXTg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-55-DXDpTECqNDeNvWbtNNifpg-1; Thu, 07 May 2020 22:52:33 -0400 X-MC-Unique: DXDpTECqNDeNvWbtNNifpg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2CB3B1800D4A; Fri, 8 May 2020 02:52:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E885764449; Fri, 8 May 2020 02:52:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 70E671809543; Fri, 8 May 2020 02:52:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0482qRFo013251 for ; Thu, 7 May 2020 22:52:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id C290E53C2; Fri, 8 May 2020 02:52:27 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE92811D292 for ; Fri, 8 May 2020 02:52:24 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B36371859164 for ; Fri, 8 May 2020 02:52:24 +0000 (UTC) Received: from mail-ej1-f68.google.com (mail-ej1-f68.google.com [209.85.218.68]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-liTfJwyRPJadHYfbtuFYNA-1; Thu, 07 May 2020 22:52:22 -0400 X-MC-Unique: liTfJwyRPJadHYfbtuFYNA-1 Received: by mail-ej1-f68.google.com with SMTP id re23so115021ejb.4 for ; Thu, 07 May 2020 19:52:22 -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=I+1cQWgxt1/5EB9HjjZokgUdamjeR9vKZIDzakJvGZg=; b=g0wekwve2A2CH8aNqL79ZzWUeL6Ivl1L9WmubhhACoPBi6r1k1Abame/OKJ3I4XlSx R9ZHVLq7/mBlq6l+5inpfJz5X2YG1PvkG1wcOIb4mwhd8ba7MfFwCaPCMWSeSZ4Z2Can pMZJbCOrqLrFwprOwGs1sm+oeZ6rnhwYh8ynxrpQ6fUWVL97YDKu5yD930DSDDZEhsnS bH2gv2P51pCgI5OMgYQf+P0kK6ZV/d8rh6TZpqJTS7XtLUKtdfNYFeKGfrXCONuTtT+P gP/+B3dHFgPwGCbyK3Zr8GwRceDKaF3ze2TPzeZV8GdG6Z+Pr2CsK3eJSc597twQPwMK KuVA== X-Gm-Message-State: AGi0PuY0gS9ESNLE8RIUjsJw2NU9fvL3vUuCw+1PicQ9sbgFAlVxI8lD TdLqMpjZHrH4xu/CoT7Sc+r03JCHkbYEskQYn+p7 X-Google-Smtp-Source: APiQypIoy6GdXKb146yh6AuN5kdW/00MOaAx9ReHHhW8zKqMsU1nfHRFkS++ItJFML6mGa+GYeDn3Vz0arJiOWV+kKk= X-Received: by 2002:a17:906:31da:: with SMTP id f26mr112797ejf.308.1588906340722; Thu, 07 May 2020 19:52:20 -0700 (PDT) MIME-Version: 1.0 References: <20200507185041.GA13930@embeddedor> In-Reply-To: <20200507185041.GA13930@embeddedor> From: Paul Moore Date: Thu, 7 May 2020 22:52:09 -0400 Message-ID: Subject: Re: [PATCH] audit: Replace zero-length array with flexible-array To: "Gustavo A. R. Silva" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 0482qRFo013251 X-loop: linux-audit@redhat.com Cc: linux-audit@redhat.com, linux-kernel@vger.kernel.org X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Thu, May 7, 2020 at 2:46 PM Gustavo A. R. Silva wrote: > The current codebase makes use of the zero-length array language > extension to the C90 standard, 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. > > Also, notice that, dynamic memory allocations won't be affected by > this change: > > "Flexible array members have incomplete type, and so the sizeof operator > may not be applied. As a quirk of the original implementation of > zero-length arrays, sizeof evaluates to zero."[1] > > sizeof(flexible-array-member) triggers a warning because flexible array > members have incomplete type[1]. There are some instances of code in > which the sizeof operator is being incorrectly/erroneously applied to > zero-length arrays and the result is zero. Such instances may be hiding > some bugs. So, this work (flexible-array member conversions) will also > help to get completely rid of those sorts of issues. > > This issue was found with the help of Coccinelle. > > [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > [2] https://github.com/KSPP/linux/issues/21 > [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour") > > Signed-off-by: Gustavo A. R. Silva > --- > include/linux/audit.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Merged into audit/next, thanks! > diff --git a/include/linux/audit.h b/include/linux/audit.h > index f9ceae57ca8d..2b63aee6e9fa 100644 > --- a/include/linux/audit.h > +++ b/include/linux/audit.h > @@ -19,7 +19,7 @@ > struct audit_sig_info { > uid_t uid; > pid_t pid; > - char ctx[0]; > + char ctx[]; > }; > > struct audit_buffer; -- paul moore www.paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit