Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2913968rwd; Fri, 26 May 2023 13:16:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5n0gGfYJaXp/KvefenDxxuF5M66EzgX+SxsD+qz+O/k+QmVhadCYe+IxOuPkArn1WBmGaT X-Received: by 2002:a05:6a21:3386:b0:10c:8939:fc35 with SMTP id yy6-20020a056a21338600b0010c8939fc35mr618551pzb.34.1685132209822; Fri, 26 May 2023 13:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685132209; cv=none; d=google.com; s=arc-20160816; b=YJedCgkcFkw7jBhXi9KdIBwzXeS6tSFRwElm+IlKw4+xxZJi7stOmrKx2vM9ac2m6o ODfXtDq6V01tahg6VQ6GuRAWxLDSQ8fErekGhMPwl7g0YtUMsoD2m2Sh+llYYMg8fvSr WJ2BV3hDYeabe4OcV82uDLfXXJ2nzi2QTZu6FXSWLil0tAHP9zdvF4fJsyXFyIw+hlYi MCfEfVs7h3ko6mdyVBlymmXVHnMrjzV+0zz+WO7n1bodU0UDx1SSyQOjkgTFZZzIVQ0o E0LQvMiewIIdkz7VlznmGj/jNZhMwke2eAPJmeh6dDQv8Xap9Rc1OOPfi1Tt5iJ6H/hF kWfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Lf4RRkiPUcNUs6sAKxHRjbAkQ4OPhmS/ejzXep+9w6w=; b=u80kCDm3zDEXq9jE9EioRQAzik3tr8EwHm7g5PVQgSk01QBAJJ6JNxcG0rDob2LAr3 Bl6MLw5gufZ+cOnfN3BeZL8UWyV/CZcVsti/Xyzr07nhiVezi/C9rFUPsy7rBWKYzsmk F3GJta+/vE7PLFFAQPv/uc4fg4F6H78qVIt22Cs/volIGgjLdIN7nFM/BLg2XEV0fZha 3e/KWvYC9Y4EYszAVmeiomIu6uvZlrSu1aQoHscMXsIOjm1e7cCqw4UqRaS7qpGJzEqW warjzFHghv9w9YPqi5ayXyPI6GK6wAZsvsyyL07KESrfq5ikSOIPPvEryBKNMBqIVjx9 CgYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=CKJONIHY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v25-20020a637a19000000b00530b86d2f8dsi3510154pgc.37.2023.05.26.13.16.38; Fri, 26 May 2023 13:16:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=CKJONIHY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237482AbjEZTsz (ORCPT + 99 others); Fri, 26 May 2023 15:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237407AbjEZTsx (ORCPT ); Fri, 26 May 2023 15:48:53 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3F8FF3 for ; Fri, 26 May 2023 12:48:49 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-4d9b2045e1cso101a12.1 for ; Fri, 26 May 2023 12:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685130528; x=1687722528; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Lf4RRkiPUcNUs6sAKxHRjbAkQ4OPhmS/ejzXep+9w6w=; b=CKJONIHYBHoJ36pk3behUlnsORLM/bdJ0rKRwmtMPp0jrr/61zx3jD87TcrsYqy7zg k3biIDnQctHE5hJlWcQwUoZNxiDhYsAjQw9EkmEs47vBwpPKETPNuW5TQY/kHezVhRG5 +AEfGjsfL0QOFBMYQqDqo/12R+BmNy9QDg1/Ks8RYLufZoToWmyDVjZ9zNaJoOQ6tSbD mkgN8Z+SQU/8xDSa7AfpFhM5yJiD0fDLr2W5b6q2WasXfoN5IHW3BEgVmKiSxiK3ELxR G27OzqOCQh2nquF0d43d717kdH0nfRAkmnqFWwOZNIE5Ka6tq4XteFx/StgpU26cggge QN4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685130528; x=1687722528; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lf4RRkiPUcNUs6sAKxHRjbAkQ4OPhmS/ejzXep+9w6w=; b=PKmmRCtepplsLkDzqbApP2jnZGgchdCF/q6xXHR3pJwyY1eNGdc5Ej+mzJM9tErk98 69btRoiNjJ1MpDzKGkX+YSLdEO1fUcYRI+vkItVJtcU8MCAy15GPpJC9NnNRpkH+mTsF m9h7smiK+cqOguITo9900hqgve8XujAg2gN0fePmaT23DTf3L1HOqgPSZTF91zegT/gt /JfvBJcIGOKqPzyOOqm3dhFb5TEvWyvx7kg7YzjWuXTIw8XSus4OrzYPH8/giZok68XB afzuE/zF0WE2y8a6kegPoNpJnpV86nyzifO00f1s0ozFdFswQ0jsi42rYc2nQ7x2qNAE cIZg== X-Gm-Message-State: AC+VfDwYq7rh9do5/WCM5lNen/E83KESSi9rX7USE8e8s86hzurW1OCe edNPlhztODS29A7itrZRWsdBZEKlohI6aaWHgwmofw== X-Received: by 2002:a50:aa93:0:b0:50b:c48c:8a25 with SMTP id q19-20020a50aa93000000b0050bc48c8a25mr19788edc.6.1685130528276; Fri, 26 May 2023 12:48:48 -0700 (PDT) MIME-Version: 1.0 References: <20230517190841.gonna.796-kees@kernel.org> <168512138720.187005.8346289423859319616.b4-ty@chromium.org> <202305261156.67CDEE933D@keescook> In-Reply-To: <202305261156.67CDEE933D@keescook> From: Fangrui Song Date: Fri, 26 May 2023 12:48:26 -0700 Message-ID: Subject: Re: [PATCH v2] Compiler Attributes: Add __counted_by macro To: Kees Cook Cc: Miguel Ojeda , ojeda@kernel.org, qing.zhao@oracle.com, morbo@google.com, llvm@lists.linux.dev, trix@redhat.com, linux-kernel@vger.kernel.org, nathan@kernel.org, linux-hardening@vger.kernel.org, gustavoars@kernel.org, ndesaulniers@google.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 26, 2023 at 11:56=E2=80=AFAM Kees Cook = wrote: > > On Fri, May 26, 2023 at 07:47:03PM +0200, Miguel Ojeda wrote: > > On Fri, May 26, 2023 at 7:16=E2=80=AFPM Kees Cook wrote: > > > > > > FYI, applied to for-next/hardening: > > > > > > [1/1] Compiler Attributes: Add __counted_by macro > > > https://git.kernel.org/kees/c/86a76e91cbab > > > > Sorry, I was going to apply it soon -- in case you want it: > > > > Acked-by: Miguel Ojeda > > Thanks! > > > And thanks Nathan for resubmitting the `Reviewed-by` from v1! > > Yes, apologies for missing this in my v2 submission! > > -- > Kees Cook > https://discourse.llvm.org/t/rfc-enforcing-bounds-safety-in-c-fbounds-safet= y/70854 proposes a macro __counted_by as well. This patch uses the same name: > # define __counted_by(member) __attribute__((__element_count__(m= ember))) I wonder whether the two use cases are compatible so that using the same macro name will be fine. #if defined(__has_feature) && __has_feature(bounds_safety) #define __counted_by(T) __attribute__((__counted_by__(T))) // ... other bounds annotations #else #define __counted_by(T) // defined as nothing // ... other bounds annotatio= ns #endif --=20 =E5=AE=8B=E6=96=B9=E7=9D=BF