Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2481543rdf; Mon, 6 Nov 2023 16:08:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuj3d0MkNdX0tmbyLQigjC8ZXnSPymY74whj+KyaTlRgszXwdM3NWKCzTOD3hquBXByCV9 X-Received: by 2002:a9d:4f14:0:b0:6b7:43eb:c1a with SMTP id d20-20020a9d4f14000000b006b743eb0c1amr29223736otl.36.1699315706860; Mon, 06 Nov 2023 16:08:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699315706; cv=none; d=google.com; s=arc-20160816; b=UonL67Kyoxqad9tibnEFuSqX90gTXAs1fclKf79mY4y89G9iGEq4YpmhYP4VJEDMnU rFVbi5ke8fRezqualfwhMArLv5fvgMBW7pKaQrfeOWJmEtcWr/koiU4Sq2+Ul2KDDvty z3N0yIoExW1lpgZZ/U39m5PcVopTaJROtG9Oh8BB60ngbny2t+fF7gtfXXlzS16P5Dvh YxfDoHQUxHlZsmG5yBwBvREeT51tECjnZ/ckv1A6ZM6IAEFPVex0N399mAMpvpgQxbNc qisDFGy+dNAHvtIyFXqGZUwOlB1YMcxgr1ztsgGfY2Omh4uwQcFTMSbrMi/DtrNjaqrB Z9Dg== 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=rpBfLqGQ1VKrTJ3rcs4fBikFzF1QxsAIPWYX8n9C+y0=; fh=iiYfDobHY2MINwdFncWE4AyogtZJ8OG7kkW3c73+dMQ=; b=DVsGQdrZUoFF++0nA7biUOg9KysBVKCNShft/YBScoYlZ+nBy7T/9iRHK3U57r7Q8o Jmjz5wxmME6uDHLFTAyaVetTKtRmyGj89YZ2tsnBcRIm6X7tz9w5hbbT80pkI8KO+InN c4uaSbHHnUFLGW0Ms0UCoCMJi7nZrg8d9XbircxkZRwK8ebzvgGtkLPL76eyVNOFMCjf N0V5gH43OKwBRBjPW0T0FPzYSTM/Nvzy5WOYke2yzqgETdPXkS9CzHbhWYbMJoTs3scQ kjo5eQa9ctfi+dXUziugAgYGyHTVIgvoy82/Gt2bABUPUkvxKXzzKgdghfARNvG+6cvo Ygjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ft2gnIOw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e11-20020a056a001a8b00b006be1fc3ee86si9327106pfv.234.2023.11.06.16.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 16:08:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ft2gnIOw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C71AE80BA7D9; Mon, 6 Nov 2023 16:08:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233426AbjKGAIF (ORCPT + 99 others); Mon, 6 Nov 2023 19:08:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233195AbjKGAIE (ORCPT ); Mon, 6 Nov 2023 19:08:04 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B54F125 for ; Mon, 6 Nov 2023 16:08:01 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6b709048f32so4739639b3a.0 for ; Mon, 06 Nov 2023 16:08:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699315681; x=1699920481; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rpBfLqGQ1VKrTJ3rcs4fBikFzF1QxsAIPWYX8n9C+y0=; b=Ft2gnIOwSF3Ap0pd8Y1sbge0ZRB+J81+y0RvxcnpMVwcUeRC6cC61fKOUs7GiqGh4Y C0hxzu5YEhfJtW2eKWfAeufgWcPvtSPqCc8IxjpLAd+dhhAOGFZUeb2vEN5/tFxdizN4 j/l+iXo+M6WXhP6u1aMGQ3Cnh+WE5ypXNyqHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699315681; x=1699920481; 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 :message-id:reply-to; bh=rpBfLqGQ1VKrTJ3rcs4fBikFzF1QxsAIPWYX8n9C+y0=; b=kZdIWTvOrYnp8cn7EEaruSjvOp9bV+a8RZ5IoT5ZKcb3NsHdQmhBl/rZhkpIFIidtb vLk76nj4V2yV6OwZJF2Z3fqxrvF40aAT9NuOL4YrdF0Xq4GhXkjX9lA1X/Ccj90uYooA uEnVP6m/EamguHN7CUBhOdNEkIYEWLsF0yfqGHGINX8jPVWFcxMFhn+gRSgLYswSnKnP FLfu3oesGKl5iaAp4yDGHNy4MIK3xTcbbGzEKtZvMWzT6C3MsYt4kMfsxJdKf/gYtWgQ 0H8xY+71t4zo+dUjG4Ibt33yxg37AFDusHsG9i8IT5glCWMTfS1AdFt66fOn5HCAo3pB JJ8w== X-Gm-Message-State: AOJu0Yys2tqGG3/aYAmdTZJxIFPlr9uP5RqkehXNKjFrR7OyHufoSlTI 5THaRbEFJ9Bdr84NJi8zejtq6A== X-Received: by 2002:a05:6a00:244b:b0:68e:496a:7854 with SMTP id d11-20020a056a00244b00b0068e496a7854mr27793278pfj.18.1699315681060; Mon, 06 Nov 2023 16:08:01 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id r8-20020aa78448000000b0064f76992905sm6076788pfn.202.2023.11.06.16.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 16:08:00 -0800 (PST) Date: Mon, 6 Nov 2023 16:08:00 -0800 From: Kees Cook To: "Gustavo A. R. Silva" Cc: Kent Overstreet , Brian Foster , linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] bcachefs: Use DECLARE_FLEX_ARRAY() helper and fix multiple -Warray-bounds warnings Message-ID: <202311061607.FFD1D68@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 16:08:20 -0800 (PST) On Mon, Nov 06, 2023 at 04:27:02PM -0600, Gustavo A. R. Silva wrote: > Transform zero-length array `s` into a proper flexible-array > member in `struct snapshot_table` via the DECLARE_FLEX_ARRAY() > helper; and fix tons of the following -Warray-bounds warnings: > > fs/bcachefs/snapshot.h:36:21: warning: array subscript is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.c:135:70: warning: array subscript is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > > This helps with the ongoing efforts to globally enable -Warray-bounds. > > Signed-off-by: Gustavo A. R. Silva > --- > fs/bcachefs/subvolume_types.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/bcachefs/subvolume_types.h b/fs/bcachefs/subvolume_types.h > index 86833445af20..2d2e66a4e468 100644 > --- a/fs/bcachefs/subvolume_types.h > +++ b/fs/bcachefs/subvolume_types.h > @@ -20,7 +20,7 @@ struct snapshot_t { > }; > > struct snapshot_table { > - struct snapshot_t s[0]; > + DECLARE_FLEX_ARRAY(struct snapshot_t, s); > }; Yup, this is the current way forward for 0-to-flex transformations in unions or alone in structs (until it's supported correctly by GCC and Clang, which is in progress). Reviewed-by: Kees Cook -Kees -- Kees Cook