Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1615150pxb; Sun, 22 Aug 2021 23:45:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymY/S2/nMdC97XXik3g+XYwaPMAPlmpTyb3Z5t87YUuNMNTAWB4yrIFET8PWFcuGKJmg6T X-Received: by 2002:aa7:dd48:: with SMTP id o8mr32211589edw.44.1629701126061; Sun, 22 Aug 2021 23:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629701126; cv=none; d=google.com; s=arc-20160816; b=o017wdzRj1cjp5qQ+K7YFG4huj7eS1kOzkq0NAUBPbZ+Hjng81uoUMpWCs2VXr8Oe2 C/Okq039hfPp5URmLZ+cOv0U94mYxa2cZZc8FxRn8q5OHDN+s8kkj6AxlULqrKtdjsJ1 EUMLZod9IoD/GD+96eFozsRcOLuZVnd0RGmCMxKHBBcxRtWBBzTUtQs3Q/o4e6Cq3sq1 WLpaXe3xyyXEHa+0byMX21bSF4bp8c32Ssz3cwGRHmnT1uqlebqHbqdiBRmTpPgiho0k eG+hoxMtScB/tZHEpuCME/9UN+gDhdXPyZX8Igr1EI8hc0N4I3R1Q1UcKqsjEZ5rPFfO YZJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=X9FMR7iIGm8hwjI0Az1jlgXDZnDlEXK88Ri4nJkOnvk=; b=zhaIXrWTEyI/VKbWU+yJmi1jGFLdYbSNebywFyvCa7jKL9K73l+ueGPA+70f16y72c Sc9w283id/zEebOokGfWxQ35y7Lb7p+9FSDfGDHZ48A52F2ioyRcIEqznplbBx2yTVpY 4R8Sd6ZpwvdY0zHHTCCfnMTCv8aqGo/ynC4SHllEvsMgTL1Sd+9y+7PPe8DuCMP6W5VX u6mgeQtolCW5X8GaEaMFhJ/tLlUOYnZsHl53JUArYsLwfFiXxtMJ/h260J3QOrEZVpvS ZxLbAU/AhbX5P6wtE2opfs9Xur2JkM6t47YlDejyw0wnkJ1FpD6DtOJ+v4k5t40FVEOs 2c5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=Ib8+qMiG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id aq7si14236173ejc.589.2021.08.22.23.45.01; Sun, 22 Aug 2021 23:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=Ib8+qMiG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232885AbhHWGoC (ORCPT + 99 others); Mon, 23 Aug 2021 02:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231779AbhHWGoB (ORCPT ); Mon, 23 Aug 2021 02:44:01 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CD11C061575 for ; Sun, 22 Aug 2021 23:43:19 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id l18so22021046lji.12 for ; Sun, 22 Aug 2021 23:43:19 -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=X9FMR7iIGm8hwjI0Az1jlgXDZnDlEXK88Ri4nJkOnvk=; b=Ib8+qMiGcXJO6i+tGA0QmqhxNKex0iZSpxnHBbWhdc8YTalcCTQtXxGESavmAvSMiz LawPT0nO36Y8V8IW5DQHRJG7KMZT/g84kVe462xfXjK16NvgfoTNOwPk9UgMcNkgkw0N hyGP/X5KsS6NSbNy6vLDYdhz2Nz7P8vBB99nw= 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=X9FMR7iIGm8hwjI0Az1jlgXDZnDlEXK88Ri4nJkOnvk=; b=q0dykuDnY6FhAKCybXm7Lb/oSc9YkZRPRe3VYkrN++hHVUk1BxhNHLbmHgRj/NlmOP OYhF96GjmzdWBH/6uwHlnezcA06Z1L6cBTjP972zLIGB4QJNHoEEnKreud6chCFZ4+A5 0UYxtoQaktaYQoU8pf1agD2TB30GwGzMmC/QM2Ac6gnL2uuaN17j9wLwxdYDx5W4PVRV qQ651S0WUPvr+Wha6FOX0po4OR7NXAqcC+8GkQabhkF3tolk6Ib/m5fwS/VQzPoMnkco eh6cxsGL8NrWRdkFWEXru69RfcM9GFPFoSOxgxoR0+4TmNJMod3KJu14V7+9NNFj4TRk oQkA== X-Gm-Message-State: AOAM533hZy6Mytkm7iJ5NtgHmGBBvZBB32UT2iRUkQ0aoXPJ4beYTblD YVivmdRv8tayIMz6Xos0G2bKWw== X-Received: by 2002:a2e:9999:: with SMTP id w25mr26140028lji.359.1629700997604; Sun, 22 Aug 2021 23:43:17 -0700 (PDT) Received: from [172.16.11.1] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id r20sm1359329lff.93.2021.08.22.23.43.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Aug 2021 23:43:17 -0700 (PDT) Subject: Re: [PATCH for-next 13/25] compiler_types.h: Remove __compiletime_object_size() To: Kees Cook , linux-kernel@vger.kernel.org Cc: Nick Desaulniers , Miguel Ojeda , Daniel Micay , Francis Laniel , Bart Van Assche , David Gow , linux-mm@kvack.org, clang-built-linux@googlegroups.com, linux-hardening@vger.kernel.org References: <20210822075122.864511-1-keescook@chromium.org> <20210822075122.864511-14-keescook@chromium.org> From: Rasmus Villemoes Message-ID: <4fff1f46-ab10-317b-8cf0-05871e4a9d71@rasmusvillemoes.dk> Date: Mon, 23 Aug 2021 08:43:15 +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: <20210822075122.864511-14-keescook@chromium.org> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/08/2021 09.51, Kees Cook wrote: > - int sz = __compiletime_object_size(addr); > + int sz = __builtin_object_size(addr, 0); Not directly related to this patch, but seeing this I wonder if there would be some value in introducing names for those magic 0/1/2/3 that are used with __b_o_s. Every time I stumble on code using that I have to go to the gcc docs, and even then it takes me a while to grok what TYPE is an integer constant from 0 to 3. If the least significant bit is clear, objects are whole variables, if it is set, a closest surrounding subobject is considered the object a pointer points to. The second bit determines if maximum or minimum of remaining bytes is computed. means. The names don't need to be too verbose, just having a few #defines in-tree with the above quoted above them makes it a lot easier to figure out what they mean. Rasmus