Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp751870lqs; Tue, 5 Mar 2024 15:52:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6+mJV9LZzVv0EyNL09HlHDkyJF2latG+ZyES8D0lfE8lpxcF5cbHjVZNir8CrzLBcsP56OkRglh2/F/TmHUpe87gZnu3AoF3GI9hZSQ== X-Google-Smtp-Source: AGHT+IG+14TT8rKS769Ph9p15laOQCAo8wFTAQf5L6flQWgON623Fqt7dnODqdFR/OocB5vtPYAS X-Received: by 2002:a05:6402:1ca6:b0:567:658:412 with SMTP id cz6-20020a0564021ca600b0056706580412mr7330233edb.13.1709682758379; Tue, 05 Mar 2024 15:52:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709682758; cv=pass; d=google.com; s=arc-20160816; b=Osp/CTS67Cs3sVs5qEQRK8qN0ZaeX0cuaPAB+cV7bT5RnOiz5K2ERhO7/VsYkOGti0 6tFQjIQxTqR4hGfVxN8DQmOlz0RlKNHYnCrQbvre3XHMWADzVMLK/71O02Tzh7x16fB1 6cuT+MgYv46rQ0H2k/a2aeuVe8PvS0OmGHqThvLAjbR0avFExP64j3OA4soifpd4/2Iy qEbvdNAB8VhQK3afsNQ0OEQO0KcDOhQGhZN6ONrBiWRD+UA1/Ntdpx+xCvUaiCTwiKfe fcJFX8tYEzowKIFnz6yb4+wOmoQhpnmldZ9HfSOvSRSiej90KCupxFbvul18hWXcv0R+ 86ZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=jyoc6sqBdOY+7wLmmpdaiPXTvskeQaEAskb3Q12WvtU=; fh=EmT7+aA+eO4GmfdUKTh0DRtte/B9oZLL4h0wXl89jL0=; b=xgMuaMy5SONqbTenWZ6hxpwq5tpmXfBIcrH/5WIclYLc0jGcl4hTfgOJUZXO0YV78+ XvaMQhePcbHPey93ALu2o43h42iDryTPamykMJKXe1fGz2tR1JAfTPN8nnHWr2+3nSwJ E+airLV2dGnW1enWIhs+XmuYje/oxupNcTN075Z+PqgnDQtrHwS7TCuKGJEWz6l+upUj sBLcP0KwXfxul63dKFmNdssDaf32jXdxS24nviOACqgfmJ+WUNyUs0usj9yq5inhjRex w7qBoHEi9TDfZ5Ln+mlD/caeqArElabj8KPM+guRbpYLtNRq2TiL0mljBj51tnvasfdH 4WhA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hWQNwmko; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-93120-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93120-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c14-20020a50d64e000000b00565e33da345si5643697edj.519.2024.03.05.15.52.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 15:52:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93120-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hWQNwmko; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-93120-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93120-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DD40C1F24B70 for ; Tue, 5 Mar 2024 23:52:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7456A12DD8F; Tue, 5 Mar 2024 23:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="hWQNwmko" Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4506212D747 for ; Tue, 5 Mar 2024 23:52:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709682735; cv=none; b=YPpSKyhmtZkaVnu0LYeqJD48rg2RssICzG9B+7PvAEtMoHgtQnxEv3uQE3jOLNoYCIodXbFhpMnkPrSx8Q3eTigSX0SIPqAMKbQ/AKteA1lH3fsz2q8ysyiSlL3rlR32QzNDmXejrxt+IY3Z/s+G01IUd+UXFjc+2NIfpAbW82E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709682735; c=relaxed/simple; bh=jad1ZTuPBnQnVhyAUaIXJ0sj2KmNN+XpvGPh1Z8NAiU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nIE9RL6FEKg9xmEUInQgd0XBzrZnIzuwS5c9QVRVwoGB+wmA/7Wls8+TSMP9dxDI82w57eOYDv6gqZYwhyzBkYvNiLzPkkchisXLLmRD0o/nV7ppbLbSvnI+uGmb5vaIYsyjj9cI8IqEBXuWSxCG8G9/+KykfWJ9DJcitTTNUZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=hWQNwmko; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1dc0e5b223eso53923665ad.1 for ; Tue, 05 Mar 2024 15:52:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709682733; x=1710287533; 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=jyoc6sqBdOY+7wLmmpdaiPXTvskeQaEAskb3Q12WvtU=; b=hWQNwmkoP6X9trL+mOxnNbMVV5ZgU4F4xTCcdQhzKJqixqNrhe/FaY7XPOdBZH3Wfl sZ6wD2ubgEZpJnJNcab0ofM/vJ4mW3tPl+Eojwwm/m7YFpU6nE63s6Yi2AQqYGPU7tk0 KIfQUPpcg0mZ8Bd8PXd+LPnMZvYWnhgE6gu7c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709682733; x=1710287533; 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=jyoc6sqBdOY+7wLmmpdaiPXTvskeQaEAskb3Q12WvtU=; b=DLVg7hyshbH7VMkirInxPtcZCSXF8zZjf49BnaafKAnlMeyYXFIQm0xMJOM6Rypg2y W65fAPJ9VtNJUFxqC4ehhJeTPutVkUp3jxReAv5n9GftlHOcbHB8Gkyz5DW18okJCcwR 06hQ7xwx+qmD3kPC1xQc67mDXfXFo4oH2BhkBHWCoA4iDYkPI7bNlXe1W9RfK/pNS/rg WVQ0jb8sTRdPkFXsptGFlzAb9XX0kUny/q3ADvCJdRE28qEU5Q3XnvhwNuOUm/aC4Uip JzAEJeaMtLQCW/iKIMBk7HV6bwDofzL8FeDT7s515Nr8MAHd96ZbJrum9sZWQH/6CF6B 2egQ== X-Forwarded-Encrypted: i=1; AJvYcCXcKf7vN0VNSCzludhcETT70ljpIlmphK/SlKbo85RAZrcBw2BevyjaeCU0Y4Adzh8gnoDUZtgsYAcxYO6DdD4QhWYo+sh0jbGqS9hM X-Gm-Message-State: AOJu0Yz+br8ViaDxCDQSoiHcMK0TWwohUR5gwDNiyIGyPe+Owitkt6a0 LX8PYnehPxNOUuuc+KNlpUk+F/j5LUCb5zMN14fG8uwEc9B8g/Uq6z0XGvYnrA== X-Received: by 2002:a17:902:a514:b0:1d9:7095:7e3c with SMTP id s20-20020a170902a51400b001d970957e3cmr3152769plq.57.1709682733364; Tue, 05 Mar 2024 15:52:13 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id k23-20020a170902ba9700b001da105d6a83sm11089065pls.224.2024.03.05.15.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 15:52:12 -0800 (PST) Date: Tue, 5 Mar 2024 15:52:12 -0800 From: Kees Cook To: "Gustavo A. R. Silva" Cc: Jan Kara , Amir Goldstein , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] fsnotify: Avoid -Wflex-array-member-not-at-end warning Message-ID: <202403051548.045B16BF@keescook> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Mar 05, 2024 at 04:18:46PM -0600, Gustavo A. R. Silva wrote: > -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting > ready to enable it globally. > > There is currently a local structure `f` that is using a flexible > `struct file_handle` as header for an on-stack place-holder for the > flexible-array member `unsigned char f_handle[];`. > > struct { > struct file_handle handle; > u8 pad[MAX_HANDLE_SZ]; > } f; This code pattern is "put a flex array struct on the stack", but we have a macro for this now: DEFINE_FLEX(struct file_handle, handle, f_handle, MAX_HANDLE_SZ); And you can even include the initializer: _DEFINE_FLEX(struct file_handle, handle, f_handle, MAX_HANDLE_SZ, = { .handle_bytes = MAX_HANDLE_SZ }); I think this would be a simpler conversion. Also, this could use a __counted_by tag... I need to improve the DEFINE_FLEX macro a bit, though, to take advantage of __counted_by. -- Kees Cook