Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp559507lqt; Mon, 18 Mar 2024 17:00:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVFdh8dWpqC5R80pRCuP+M8KNlLzHvwa7rMXub/E9yVpv2Lh354JoYpvgqPvChnRJKupD+dcA0d82+Y6Jf1Rv+0XG14znKARvfF1JWvYQ== X-Google-Smtp-Source: AGHT+IFOYCg7GumcMurFrOQhvVpvL/wZ6+9aQTusdhI2Lvno2uM4d9xXU2EAy82yyvw5pPZnIfh4 X-Received: by 2002:a17:90a:b28a:b0:29c:791d:b5d5 with SMTP id c10-20020a17090ab28a00b0029c791db5d5mr1254469pjr.34.1710806425578; Mon, 18 Mar 2024 17:00:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710806425; cv=pass; d=google.com; s=arc-20160816; b=AP595cTQ94jI1qDuuukF0wJEA8T253buId/frMIYDolX1eEurUqmRjqyUOlt+OrXA/ nd7/u5aouSs9N6GE/32P91A8qbGxwf9ClWpyKYdKKUTo8rH3AilZTbpokzs3DcmOkFdI VBwP5tp44HsNxeSOeAwJTxV6Or9MUY++zQ2HoL0IULARKs8UydlyOPkrnD6H0mTGkU6y u1dHZ4HZTtldZafEDSI5RQ75BxD+8P+uGw6QWcci5g38KK2aNfU3hFL/Us/adPt+/+jC jMFKPeH777WLeA3wp3eVm4bIiSK8jVliN2O7+IGiafwkqgamA46Tfe/4GN2ng3rdvqWH K9Iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=z3Vya20dY0mWdmCkQilYCaqVfInKVcnxM24ENtjMVvs=; fh=Wc8Noa2GSK8dKSfMxcIa8xbCZ32jZYIVINn4W05p9BI=; b=KJ2Wq7D5QKS7Cx7He/M2dI/4fJq3E2M/Gh0DOhqLF1MlEi2iPPl5kg8TvfZUt3F9nR 96AmcF8q3pgrytHmEKDCVyIB8BOuQonj6YBgVxiBHFvuQa9EEK+VIAhuFkora2EGQxEu 2RZFChh9WDYXjd7G7qyAgDO+G4FQqFq295mxoh8ZApfDot2vsBVeLlQXVWffq1NSeXBv 0mARMhWsretreyb8p1u/+NRqRANgME6AiNzqNWBVKdyIDUKHRf4JLk+pCRfpaz0LH+z6 N754EG39JgEnF6Ph6Bm3xNXJztXG40VHbIcbhcOMch4ZIyFQzf2h/E8PEHYTe7qC2gOU J3TA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b="sidolu/g"; arc=pass (i=1 spf=pass spfdomain=embeddedor.com dkim=pass dkdomain=embeddedor.com); spf=pass (google.com: domain of linux-kernel+bounces-106841-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106841-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id lx10-20020a17090b4b0a00b0029de2ad7027si8935782pjb.29.2024.03.18.17.00.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 17:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106841-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b="sidolu/g"; arc=pass (i=1 spf=pass spfdomain=embeddedor.com dkim=pass dkdomain=embeddedor.com); spf=pass (google.com: domain of linux-kernel+bounces-106841-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106841-linux.lists.archive=gmail.com@vger.kernel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 70C07B20FCC for ; Tue, 19 Mar 2024 00:00:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F7445F87F; Mon, 18 Mar 2024 23:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b="sidolu/g" Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B7485F873 for ; Mon, 18 Mar 2024 23:59:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.89.44.39 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806394; cv=none; b=fgyyHj3ZOYDm4uCBJqpPLiHEb4eWK5qssTpNbbNWa6jmgIzsg9vChk6yQ/hqVltE1B4VWWgSESBqzE+AYBiFjScLJiU3/Wk3KAdFE7mwa6+zcEu0BHwP95CzrmDTqBHZeTZLm3Ba3yYWbQEfXGLsSs08kAc+I6TZmLbPBm3oe4s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710806394; c=relaxed/simple; bh=ElLiTVxcmJle7UtLKCTpM6rcHrJP3m3DslckjAJ+o2Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MUaXgTKl6koDgsTAQncNaeey1rUrnaMaRmgQFgA3wjLvE1LK/Cmlt1QH6UQdC1gzaUArmuitwPQkYI9jeZg1JyYQMWolAF1XmPwrwOSDHo2NBdOnvv8xA6BaYVBBvZK2JhcKB/QtoVJFPtPNanU53pG9/P/IuQaBGrWf+wVV0uI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com; spf=pass smtp.mailfrom=embeddedor.com; dkim=pass (2048-bit key) header.d=embeddedor.com header.i=@embeddedor.com header.b=sidolu/g; arc=none smtp.client-ip=35.89.44.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=embeddedor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=embeddedor.com Received: from eig-obgw-5002a.ext.cloudfilter.net ([10.0.29.215]) by cmsmtp with ESMTPS id mLXZrftxHPM1hmMtNrNPcM; Mon, 18 Mar 2024 23:59:45 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id mMtMrRVAvybtzmMtMr5m39; Mon, 18 Mar 2024 23:59:44 +0000 X-Authority-Analysis: v=2.4 cv=RsAOLzmK c=1 sm=1 tr=0 ts=65f8d570 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=UtBFqMlDG83dypD0sxEoAQ==:17 a=IkcTkHD0fZMA:10 a=K6JAEmCyrfEA:10 a=wYkD_t78qR0A:10 a=VwQbUJbxAAAA:8 a=zL1ebxPFBZ_Ilvq-UgQA:9 a=QEXdDO2ut3YA:10 a=AjGcO6oz07-iQ99wixmX:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=z3Vya20dY0mWdmCkQilYCaqVfInKVcnxM24ENtjMVvs=; b=sidolu/gK1+hPsSXqvNuJY/TZ1 6fqRopQ3PFN2NHqq8Vg7oiEn+0/ZeSQLeluey3K66la59ajHf/7BnFXN8ricrHesma6c8IgSIIpG6 smse2ekSWlyukeFykHLs/YamC+MVy1lMW077IiR8dokcvBtV6crY/bQRhVftblpoCfJpYyrD2EtW8 bLJQ5mNChVW8Y7znDSO/z9JRSxuCbAHufnpXXU8U2k4TmiMTI+aixhUVQLzIOLW6L3UYFr1cUK+R4 Pli8YtXjxD9uKbXoqrzZ0n13Q+EiMqusXEu4clNFUOZsEyDmGVX4nVbq19kaJAHNW+Q3rbTUoK3FP WKvXHyPQ==; Received: from [201.172.174.229] (port=45042 helo=[192.168.15.10]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.2) (envelope-from ) id 1rmMtL-001CBX-2Y; Mon, 18 Mar 2024 18:59:43 -0500 Message-ID: <1c05cba3-41c9-4862-b126-4ec6a79876d6@embeddedor.com> Date: Mon, 18 Mar 2024 17:59:38 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH][next] stddef: Introduce struct_group_tagged_attr() helper macro To: Kees Cook , "Gustavo A. R. Silva" Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <202403181652.B8787FB288@keescook> Content-Language: en-US From: "Gustavo A. R. Silva" In-Reply-To: <202403181652.B8787FB288@keescook> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 201.172.174.229 X-Source-L: No X-Exim-ID: 1rmMtL-001CBX-2Y X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.15.10]) [201.172.174.229]:45042 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 2 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfC5DWoLMRl8B/CfshWFZcHzPAXaHOtJOeZ6SrTSBJjGAD47kvTpsRnwafz+Ge5gThlc0fZwmXgra5OY8hNWtZF3QctmzX3nKCRIMh9gTmsGcvQbJcN8W Yx3+cxtxW01/ZuxgOnrJJ3r74CHuaGGBdDp3Phh9IMbXQmSpejiJ4Uu23zw2FSyspj01hc8VQbzlL/TefC8B2sT2o518IGoob4IMGLbVsqgNmDodWQIMrQ9J On 3/18/24 17:53, Kees Cook wrote: > On Mon, Mar 18, 2024 at 05:00:33PM -0600, Gustavo A. R. Silva wrote: >> We need a new `struct_group()` helper that allows for both having the >> struct be tagged, and specifying struct attributes like `__packed` >> or `__align(x)`. >> >> This new helper will initially be used to address >> -Wflex-array-member-not-at-end warnings, where a tagged struct is used >> to separate the flexible-array member from the rest of the members in >> the flexible structure [1]. There are some scenarios in which those >> members need to be packed, as well. >> >> So, `struct_group_tagged_attr()` is introduced for this. >> >> Link: https://lore.kernel.org/linux-hardening/ZeIgeZ5Sb0IZTOyt@neat/ [1] >> Signed-off-by: Gustavo A. R. Silva >> --- >> include/linux/stddef.h | 20 ++++++++++++++++++++ >> 1 file changed, 20 insertions(+) >> >> diff --git a/include/linux/stddef.h b/include/linux/stddef.h >> index 929d67710cc5..919df9453257 100644 >> --- a/include/linux/stddef.h >> +++ b/include/linux/stddef.h >> @@ -80,6 +80,26 @@ enum { >> #define struct_group_tagged(TAG, NAME, MEMBERS...) \ >> __struct_group(TAG, NAME, /* no attrs */, MEMBERS) >> >> +/** >> + * struct_group_tagged_attr() - Create a struct_group with a reusable >> + * tag and trailing attributes. >> + * >> + * @TAG: The tag name for the named sub-struct >> + * @NAME: The identifier name of the mirrored sub-struct >> + * @ATTRS: Any struct attributes to apply >> + * @MEMBERS: The member declarations for the mirrored structs >> + * >> + * Used to create an anonymous union of two structs with identical >> + * layout and size: one anonymous and one named. The former can be >> + * used normally without sub-struct naming, and the latter can be >> + * used to reason about the start, end, and size of the group of >> + * struct members. Includes struct tag argument for the named copy, >> + * so the specified layout can be reused later. Also includes >> + * structure attributes argument. >> + */ >> +#define struct_group_tagged_attr(TAG, NAME, ATTRS, MEMBERS...) \ >> + __struct_group(TAG, NAME, ATTRS, MEMBERS) > > This is the same as __struct_group() only with a longer name? Why not > just use __struct_group() directly? > Mmmh, the rest of the helpers in the struct_group() family fall in this same category, can we use __struct_group() indistinctly? -- Gustavo