Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp633356rwb; Fri, 2 Sep 2022 22:52:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR5u9FMkqyFl6qPO+wzPI2+WBhiKOxJK5p8AT+F6xzjato7OUETRvb5kVqu1x1b0Td4tfIT8 X-Received: by 2002:a05:6402:31e7:b0:447:d664:83eb with SMTP id dy7-20020a05640231e700b00447d66483ebmr31630979edb.276.1662184338198; Fri, 02 Sep 2022 22:52:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662184338; cv=none; d=google.com; s=arc-20160816; b=uG65cseRzgeXXzW+orFwY/uUsO69arwE2IIWVaBk+DDSW5CjvwD/16av2N6C1a5wPH 0t3Y10vY0TuSjNucBUnHte8tcQUwFmqmMfgmytIHHpGKSMAKUcHgRN2ISd6r9KKZbqLH VXBl3TvRxe+s6ZcdN/bwBIphQz1B551cRJ+fGpMia5TGVnrA3N9xLgAsUhspJGL8Cxm1 5ClyzjXiVRE0AH3SjN7Yx8buFo9CRf8K8n6OasyzxtXOOGAKKtCMPBCU8mb84m2JOCqJ 44kJua6yXP1wELW/z54eazMMnmpAeqp2xBhuC4IQyaRyKnk+pven4DRQLxV6oYoUQS+E kIOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DWQU4BjAk2RKJXcziV8gz7Em/gw7x1iBMRQeoGw/K1A=; b=sfk/NFvYDhXuQ4oIqCihnbXTJHrPpg9uUYChJ3KEJWhtqZ8nl+lCXRNmtSoegmUHqL B4h9YJX4FZPPCeGrFAPV11Crkrr+2Y43ifE5iNVqNegKcVqEStD2bFF3gAq0GUcSLDtc Ab2LQZ8JJkIuADy+t1PEp+hn4eRbGKwQovLhEv9rbrdaJL1vSv0CY+1bmidBPWU+96dA ntW/rSqyEwOisvx4M61QtqHeJqGADnDsOIvbTO4/H9GU+0wShNXq4jY6lRLJ8rAmHfJ3 cQCV0MfDnPzsfPUVey1eeUFYf+1YVDndSUvzRKyp5/N5tfFT0w0CXwlF0nb9k7C+iIpF BQHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=a0Jq0XZY; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn8-20020a1709070d0800b007310a6d6a7esi3361625ejc.975.2022.09.02.22.51.52; Fri, 02 Sep 2022 22:52:18 -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; dkim=pass header.i=@chromium.org header.s=google header.b=a0Jq0XZY; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232032AbiICFMc (ORCPT + 99 others); Sat, 3 Sep 2022 01:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232008AbiICFMa (ORCPT ); Sat, 3 Sep 2022 01:12:30 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C834F7D1E7 for ; Fri, 2 Sep 2022 22:12:27 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id u22so3690365plq.12 for ; Fri, 02 Sep 2022 22:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=DWQU4BjAk2RKJXcziV8gz7Em/gw7x1iBMRQeoGw/K1A=; b=a0Jq0XZYSQA1ZyBSSQtFq3BQ8vg873jp0dp5wazzJ6inOF195+lnsDAOPUGs6u3Knz z1zC7iYuExltCbr1CHrw+kG2wIrjr5zrW75GFzxfyyLEKJZmUAz4MkHYLh2c5VL0y9UD aqsiJxsNXtVG4DXUTWfcxZLABqciAZKarEbtI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=DWQU4BjAk2RKJXcziV8gz7Em/gw7x1iBMRQeoGw/K1A=; b=zq2BR6CAHux6IW1it/b6MsHUOwSFGwuW+8bimd2MwK90bU4mQkQXndZzQz0JzhXcyB ZKMM78laprCLys9QIR6zElq9+QK508vpTe46ygIrCL+LdhjdR8y+64fi6d9mLm/jGpX1 152LmugrlJyNV6ni49kPQYJvJcLod/XjCvS9irpN6YY4Okjuc5wGW0x/iwAW4SVAKMdp z2jUmQvcw7Iq6bbIb5HHIghIym2r+yWp/9BE1Ia0Ov6taxknLEFFODFpuV1g/X5ZlvdH xRZZzR+Vnr2m8vjIBznFfEVOTs0R0az1Agg08ZbideaddJ5OZZm7o++pMw6eRhWvQ8qH uqjQ== X-Gm-Message-State: ACgBeo1MLArlPxD3YLAaMiN4GKqT/ZQaDmwRXsf6QuY0jmn4HqEjyi3/ XOCMSEVPG4NUr42s1IU+qdqaKw== X-Received: by 2002:a17:902:8ec6:b0:172:dc2c:306d with SMTP id x6-20020a1709028ec600b00172dc2c306dmr39278791plo.104.1662181947281; Fri, 02 Sep 2022 22:12:27 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n11-20020a17090a2bcb00b001facb7bc1adsm6140998pje.26.2022.09.02.22.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 22:12:26 -0700 (PDT) Date: Fri, 2 Sep 2022 22:12:25 -0700 From: Kees Cook To: "Gustavo A. R. Silva" Cc: Mark Fasheh , Joel Becker , Joseph Qi , ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] ocfs2: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper Message-ID: <202209022212.7F753284@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Sat, Sep 03, 2022 at 12:59:36AM +0100, Gustavo A. R. Silva wrote: > Zero-length arrays are deprecated and we are moving towards adopting > C99 flexible-array members, instead. So, replace zero-length array > declarations in a couple of structures and unions with the new > DECLARE_FLEX_ARRAY() helper macro. > > This helper allows for a flexible-array member in a union and as > only member in a structure. > > Also, this addresses multiple warnings reported when building with > Clang-15 and -Wzero-length-array. > > Lastly, this will also help memcpy (in a coming hardening update) > execute proper bounds-checking on variable length object i_symlink > at fs/ocfs2/namei.c:1973: > > fs/ocfs2/namei.c: > 1973 memcpy((char *) fe->id2.i_symlink, symname, l); > > Link: https://github.com/KSPP/linux/issues/21 > Link: https://github.com/KSPP/linux/issues/193 > Link: https://github.com/KSPP/linux/issues/197 > Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html > Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook -- Kees Cook