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 X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6AF8C4320A for ; Wed, 28 Jul 2021 10:54:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5577A60C51 for ; Wed, 28 Jul 2021 10:54:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5577A60C51 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rasmusvillemoes.dk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DC4326E7DA; Wed, 28 Jul 2021 10:54:23 +0000 (UTC) Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by gabe.freedesktop.org (Postfix) with ESMTPS id D07FE6E7DA for ; Wed, 28 Jul 2021 10:54:21 +0000 (UTC) Received: by mail-lj1-x229.google.com with SMTP id l4so2565547ljq.4 for ; Wed, 28 Jul 2021 03:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=y7BSRF2BV2wKYMpkMU6AInonSJrtXWVBGV0wA+UfcSQ=; b=HvxZxKORsgd1u77vvKkzSHVmzDZnFgdXGSifvV+HmSIPnClkA6lYo7Qz7nvYlLjejZ PK9B0U1dzVIDM4JKLg5sSHucPcc5bP4ZeDpjmSTAFJSiF4x48AfpDxMdOGxhIAJqc77U oc7qawDYmcTBtp40SM72ZiIXxtcm1lp5rspVI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=y7BSRF2BV2wKYMpkMU6AInonSJrtXWVBGV0wA+UfcSQ=; b=Z0p5NiV03S0cZmaFKRKkqHKvnXSOZF+sScekfnhjv1dJRAqahJVNGKs5dX3S1E/yTV XQIglSRSMZRChwierFLzlAZHXtD9AO2levnbGNapQKUSt6xIF49gqi0Zny5unvcloB4w TI7YDmDy9l+2lxv7KFivR7Dxy8pSoPU2PXcA/cUGkdCUpDLn7UgsK8Qx3RBJDw64aAsa n+AkuLsypoSBSg1pr1qE0LQkcoAjt40qGvB6zfDQv8jM6a0Vb7jgwNk0bRp4G9Bq+6uD QDt9WulAUp5qeX3dw8IrbFdTJY0ufWeQy43vU6eej/FMBGpI4wrwDZznsnnePjh4EO+M 2AZQ== X-Gm-Message-State: AOAM530ljR9i64plbgZwrJSDSe6zJbOx8aA1qCYaAstbY6hjw5XHbz0j DN3pCvvLuDv1WUEVx4bwBUIS9Q== X-Google-Smtp-Source: ABdhPJzsNcjtwcC6XUZJ5ZJ1M5kI8nrl9w1bOGQ6hWCdCY07r8K6xPGQ9TuYLQLsRgK+FjENio3Z4w== X-Received: by 2002:a05:651c:1144:: with SMTP id h4mr18097576ljo.396.1627469659652; Wed, 28 Jul 2021 03:54:19 -0700 (PDT) Received: from [172.16.11.1] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id o1sm555702lfk.298.2021.07.28.03.54.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Jul 2021 03:54:19 -0700 (PDT) Subject: Re: [PATCH 04/64] stddef: Introduce struct_group() helper macro To: Kees Cook , linux-hardening@vger.kernel.org References: <20210727205855.411487-1-keescook@chromium.org> <20210727205855.411487-5-keescook@chromium.org> From: Rasmus Villemoes Message-ID: <41183a98-bdb9-4ad6-7eab-5a7292a6df84@rasmusvillemoes.dk> Date: Wed, 28 Jul 2021 12:54:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210727205855.411487-5-keescook@chromium.org> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kbuild@vger.kernel.org, Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-wireless@vger.kernel.org, "Gustavo A. R. Silva" , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, clang-built-linux@googlegroups.com, Keith Packard , netdev@vger.kernel.org, Andrew Morton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 27/07/2021 22.57, Kees Cook wrote: > In order to have a regular programmatic way to describe a struct > region that can be used for references and sizing, can be examined for > bounds checking, avoids forcing the use of intermediate identifiers, > and avoids polluting the global namespace, introduce the struct_group() > macro. This macro wraps the member declarations to create an anonymous > union of an anonymous struct (no intermediate name) and a named struct > (for references and sizing): > > struct foo { > int one; > struct_group(thing, > int two, > int three, > ); > int four; > }; That example won't compile, the commas after two and three should be semicolons. And your implementation relies on MEMBERS not containing any comma tokens, but as int a, b, c, d; is a valid way to declare multiple members, consider making MEMBERS variadic #define struct_group(NAME, MEMBERS...) to have it slurp up every subsequent argument and make that work. > > Co-developed-by: Keith Packard > Signed-off-by: Keith Packard > Signed-off-by: Kees Cook > --- > include/linux/stddef.h | 34 ++++++++++++++++++++++++++++++++++ Bikeshedding a bit, but do we need to add 34 lines that need to be preprocessed to virtually each and every translation unit [as opposed to adding a struct_group.h header]? Oh well, you need it for struct skbuff.h, so it would be pulled in by a lot regardless :( Rasmus