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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 681C1C28B2F for ; Sat, 15 Mar 2025 18:34:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC602280003; Sat, 15 Mar 2025 14:34:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B4FF9280002; Sat, 15 Mar 2025 14:34:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CA5F280003; Sat, 15 Mar 2025 14:34:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 79143280002 for ; Sat, 15 Mar 2025 14:34:35 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2CD28C1B3B for ; Sat, 15 Mar 2025 18:34:36 +0000 (UTC) X-FDA: 83224636152.08.0A40C74 Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf01.hostedemail.com (Postfix) with ESMTP id 83BDF40005 for ; Sat, 15 Mar 2025 18:34:34 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PDoNB7Dz; spf=pass (imf01.hostedemail.com: domain of kees@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1742063674; h=from:from: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kr5LUMKcSCejctKCEQi+9itzt+jzhk5y9z5IbSxUD1w=; b=ScBP0Vqom+1Qnqt1kCku+hjh3gw/cxfdtdB1OHIL7W8e1HFho8M3i314of2e6dwRlfR+y/ D01dENQrutnIeXtr23kKELDa1Qd9+EKIDESDe+9FS6VlmU7mkL2kyJvWGl+4PGFuJUYrB+ iNKlh17eo9OKFgmAfkZ7E8LAamD15WQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PDoNB7Dz; spf=pass (imf01.hostedemail.com: domain of kees@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=kees@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1742063674; a=rsa-sha256; cv=none; b=1C0ve5oQC1mR35YuQVtlxxZje9FfEohIlf13zxi/LtRt3Cq5rxX2UBDrFyqPBHx+BNg1+v LLZvUpZOg5nlwIE0sU0iaretFW8ilfgFu6KgBcAlB0dUcCHKrpkr1Fw3GTAfyPzyx4y9xX JxyVFFZodutcEor+yDqc7ZeY3VGk9+8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id C2544A48B21; Sat, 15 Mar 2025 18:29:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A38DC4CEE5; Sat, 15 Mar 2025 18:34:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1742063673; bh=X4xpNZ8s/sLlkBevw/itk2vfx1DtriwGopjBQDhHUlk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PDoNB7DzA9Waok4Oz0gdSnJmuGJvm+LFo0WJ6WFGPyGHM6uPTy82o13K5gjCZPPZg pX4v/5/QL+pdLvPQb4aTmjjK0yhu2FrFWvAHMsaLdWwlaiUDgGBY2/Ys4dthN/BZWM vtTlvLY6dWn8a8lm89kCObmxMFyL1Fq289hdcj/j6rPyy6huex/JAHIt2wBvoypqYK 3Ka9NZDENVsrASqFqZumU2REmTbbul8+mTQ/3ihRLHHXDmKst+fGdeKhVNETK/fn9j E6lHMRFqfhQ/Rfthh4hWxx8p0VSXirdabbR2UkvwIO1BLrHkiASgsWyb5MqNd/XL2L F9h7+7zTM/cvg== Date: Sat, 15 Mar 2025 11:34:28 -0700 From: Kees Cook To: Randy Dunlap Cc: Vlastimil Babka , Miguel Ojeda , "Gustavo A. R. Silva" , Nathan Chancellor , Peter Zijlstra , Nick Desaulniers , Marco Elver , Przemek Kitszel , linux-hardening@vger.kernel.org, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Bill Wendling , Justin Stitt , Jann Horn , Linus Torvalds , Greg Kroah-Hartman , Sasha Levin , Jonathan Corbet , Jakub Kicinski , Yafang Shao , Tony Ambardar , Alexander Lobakin , Jan Hendrik Farr , Alexander Potapenko , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH v4 1/2] compiler_types: Introduce __flex_counter() and family Message-ID: <202503151133.3FCFCB70@keescook> References: <20250315025852.it.568-kees@kernel.org> <20250315031550.473587-1-kees@kernel.org> <03d69156-1cee-43bc-901b-5f85f3aa7575@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <03d69156-1cee-43bc-901b-5f85f3aa7575@infradead.org> X-Rspam-User: X-Rspamd-Queue-Id: 83BDF40005 X-Rspamd-Server: rspam08 X-Stat-Signature: ea1eitk675cjctcwhmi4ry9zw1hc3sab X-HE-Tag: 1742063674-853574 X-HE-Meta: U2FsdGVkX19CSlMpmfRAT1gJXk6le5jjBb2MJtn+gJdjtOJ1RwlDh40VE5a1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f13eSV9rdOSxYrkK1SEveTCVJp1dQ4Gd+ozq9QFTF1E55vYFZbcZmx6yI3nlRLFitoYEQs5NCy6Zm5RwirSA80yQOqz0hVpCcu5aJjTgXEk7Ye5tKVo+HftilLT7qh5HEuiAuqv+0VVbAk7+aLR3wbCN1sh5Fy9+HGCn95os3aQb08d25yzHw8cXUOM2dNp9tiPn+duWCc9DyyFrSFcN3KvX0Ia0uos+/5Td3NzXQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, Mar 14, 2025 at 09:53:41PM -0700, Randy Dunlap wrote: > Hi Kees, > > > On 3/14/25 8:15 PM, Kees Cook wrote: > > > > diff --git a/include/linux/overflow.h b/include/linux/overflow.h > > index 0c7e3dcfe867..e2b81cb5576e 100644 > > --- a/include/linux/overflow.h > > +++ b/include/linux/overflow.h > > @@ -440,4 +440,40 @@ static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend) > > #define DEFINE_FLEX(TYPE, NAME, MEMBER, COUNTER, COUNT) \ > > _DEFINE_FLEX(TYPE, NAME, MEMBER, COUNT, = { .obj.COUNTER = COUNT, }) > > > > +/** > > + * typeof_flex_counter() - Return the type of the counter variable of a given > > + * flexible array member annotated by __counted_by(). > > + * @FAM: Pointer to the flexible array member within a given struct. > > + * > > + * Returns "size_t" if no annotation exists. > > Please use > * Returns: > instead so that kernel-doc can make a special doc section for it. Ah! Thanks -- I hadn't realized that the ":" induced special sections. I think I have a bunch of other kern-doc clean-ups to do as well. > > Same for patch 2/2. > > > + */ > > +#define typeof_flex_counter(FAM) \ > > + typeof(_Generic(__flex_counter(FAM), \ > > + void *: (size_t)0, \ > > + default: *__flex_counter(FAM))) > > + > > +/** can_set_flex_counter() - Check if the counter associated with the given > > Needs a newline between /** and the function name, as in set_flex_counter() below. Whoops, thanks! -Kees -- Kees Cook