From patchwork Fri Sep 22 17:28:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 14413 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5923163vqi; Fri, 22 Sep 2023 16:20:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPC8mm9mIl1yirePfJ/j66fqpEFZylJfqC1sAPlWyDjT/T6kV2shFIU/ZNYBBto8aydSJP X-Received: by 2002:a17:903:2351:b0:1bf:25a1:9813 with SMTP id c17-20020a170903235100b001bf25a19813mr1016470plh.6.1695424844533; Fri, 22 Sep 2023 16:20:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695424844; cv=none; d=google.com; s=arc-20160816; b=ver/rVmZXHjTi7PkKiKILfMJDnfZDRfzh7EiJmNaEND0gwwqhxAAnS9A9ZEkUTWA3l ImqH4P4bReYTw1ccPPK/LDJdZ8GMsjH0C6kvwI6mUWZxVXJiv9VueruKZnILynjUub1D IohETWXyjX4SD1omWqi9Z7zWnX6adV2N0vEsdD/jDxeCjLTaWGQ1lvaFzWolURqjQcJA 2zooBjB1U4w8KbfpkiFcfdfpnIn1Ow/Y+P/nnTzu/Da0Tqb48qylEqENAg5aQktmhXyj VL/qno3NuxzcChz4OHkcP/zKbSd1MNj8ecuvGNnLLIcluWjl2NvUMWJvQLqL5bKIjr41 8kzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=c8+zsDKqPYa5khoeQ/X2KkaY8mmY8r9M3Aj1MNqbUX4=; fh=KOXtJI67hWLD0IaFvHnedt3G2BVkiWWTQJMKhPfhTVs=; b=aH4CXse50+YODYMAi9nskhhIKR46WcwxxG8N+yvNqgyYDmy5FloVBAq/xCam+ei86N 9AobJMwRF/SlyJN0k4ealSXuZNuGBNsjyqk62Kd1su0VawQchTyZv3ZsySY51W2yz7+q NeU7TLmf4uBtKWNLcjkSXJb8UjYkdD6dIFHyW+ZtHwUSYoFejgDdplbTdeOcACrFydKr 7222hmVYE0HkeqxopWDc3fHBtFi/xfVOj3BzNHI2UV8oDEyOERiv6Nlb0m1Ara5hVOIX wQsJlC6B4cO4s3s6itwCQGp4tiNCABaB9bVMtaVHSMVm6Jrf+O6TaUHXjvTVluBwDoY6 QW7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PLUE5dDT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ja17-20020a170902efd100b001bf2dc67da3si4387157plb.209.2023.09.22.16.20.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 16:20:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PLUE5dDT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6153F81D2ACA; Fri, 22 Sep 2023 10:29:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233132AbjIVR3Z (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232804AbjIVR3M (ORCPT ); Fri, 22 Sep 2023 13:29:12 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0EEC1BE for ; Fri, 22 Sep 2023 10:29:03 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-690d8fb3b7eso2254468b3a.1 for ; Fri, 22 Sep 2023 10:29:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403743; x=1696008543; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=c8+zsDKqPYa5khoeQ/X2KkaY8mmY8r9M3Aj1MNqbUX4=; b=PLUE5dDTqFZ7VWtRtpwVm9vtlfkwNL8vm5+TsbEpX4W9qLxjD3SFs+58HPEu/XteGz MCx9O7xaoxTNLet5Z4OaiMPRwxAUCBZdQ8DarEJ3GdmPNnwtJBBqEctDmkm4XFTbNqKc 93hoJPOkUOrgybb0baWj/GLs2XjeIkT5RSgyw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403743; x=1696008543; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=c8+zsDKqPYa5khoeQ/X2KkaY8mmY8r9M3Aj1MNqbUX4=; b=Sry2EnqO0kZqZjwyAo+DZQkXMwziwAoOoh4K0TCpeKmhiDPcEx0pbO7hTNfcF2j/RQ 6LA+m27PgHDF/56Mth9TtoaSpO2Undk9vIYtsRRz26N4gvY+957Q4LNk3r/fzzPrYtvQ Ya+JYcOf/Z+ECiy9kKOcyxCwQOgZyCt8F8TNbcmWn7o+Cq0MsvYYMeA9oQc0I8t6b6zC 9w8L8SLXMuL3NnRBCNe0T2pe9Z4Q3hy08Y++Ec/EE98Hn8wItzOa2juRTn96E36ob17U 9x9b4OuUWcaE+YLcgtyCGQYktEc7XKvtIU07FWFNmCE0DD3tcJVrG5Uyndv55xydthfg RfXQ== X-Gm-Message-State: AOJu0Yz4AMHCs+z2tu9ohNgZDXfjAJtNiS4S0ZmaRYAoCsg6YGTlPOUF DJomFD2I3nBNDmXHUTZQbPD+6w== X-Received: by 2002:a05:6a00:847:b0:68a:5e5b:e450 with SMTP id q7-20020a056a00084700b0068a5e5be450mr72319pfk.26.1695403743180; Fri, 22 Sep 2023 10:29:03 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id y10-20020a056a001c8a00b006926e3dc2besm2777741pfw.108.2023.09.22.10.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:00 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Jamal Hadi Salim , "David S. Miller" , David Ahern , Eric Dumazet , Paolo Abeni , Martin KaFai Lau , "Gustavo A. R. Silva" , Alexei Starovoitov , Yisen Zhuang , Salil Mehta , Claudiu Manoil , Vladimir Oltean , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Ajay Sharma , Alex Elder , Pravin B Shelar , Shaokun Zhang , Cong Wang , Jiri Pirko , Nathan Chancellor , Nick Desaulniers , Tom Rix , Simon Horman , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, dev@openvswitch.org, linux-parisc@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH 00/14] Batch 1: Annotate structs with __counted_by Date: Fri, 22 Sep 2023 10:28:42 -0700 Message-Id: <20230922172449.work.906-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2504; i=keescook@chromium.org; h=from:subject:message-id; bh=tD+5se4WoWIAJwEPLvlJBN6wlUKoasq6Szn6nibv1zQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7Wu+d5o7777Jp53tWR0nER5gmlkAVoVjoqh J5JIlgoeMOJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1gAKCRCJcvTf3G3A JrqqEACeFuiUMDgjhvtyqa9O/ntgqeTDML08nWyLGJ79aRe6YFXyHEddM/LbmREWkrtJUThTPL+ 5cqYB5ebSIzmAdm4jbres07kHLFvt+2wcfmJa92BLomL4uPyqTUFXgn1mSYnLrb14IzV3e88Sx0 dEDq9SHrXgKyFWkQfaC7RzupSY7nGw1X1Fv3+vLo/ofLr89BRjbc1wH0tOJMrBPr7asUo/F7eG2 7lxjFPkC1mLDulQotR5dcnl637i1mztV/DHfJlCRJQwcUcE/rH65VJ6UPC1PCNvc+eqL/CMKwKM T9iKyVQLU0gOVexJO+FPe5rDRoi/YrXfznJqI0MZx9L7MnZqanTpbTbIIWmdObv8ciWWZz3S8K/ yHSIfhDofc7jQmUJnSJywpwkeAUyF50SOAkYngCVfxzswzgtYznLShCCbrSr2PLyVIU3xwoNL1F GJNRC4AJkef4eAA0hMVt6HF0UypVDq3Kvny+Q0xdl+MznPGBX1NQuKAvUri7Y8KGZ4yVf9N80Lt 88tUHrZopBg7iXoM1qSKMZPHxRK5nqMN/qqfUi48CEB5SZ8IzvOnLAvs7qd5FBCO4P3/yH8OWBy blZo4EB4+EAYhVbu8a/RM7O+YjAH2q2muPkUv7s/sP9KxF8m7FHQgFogan1njOplS3zYEN8SVhu HgXxG8g LJHlR5Bg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:29:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777781801831279206 X-GMAIL-MSGID: 1777781801831279206 Hi, This is the batch 1 of patches touching netdev for preparing for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). As found with Coccinelle[1], add __counted_by to structs that would benefit from the annotation. Since the element count member must be set before accessing the annotated flexible array member, some patches also move the member's initialization earlier. (These are noted in the individual patches.) -Kees [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Kees Cook (14): ipv4: Annotate struct fib_info with __counted_by ipv4/igmp: Annotate struct ip_sf_socklist with __counted_by ipv6: Annotate struct ip6_sf_socklist with __counted_by net: hns: Annotate struct ppe_common_cb with __counted_by net: enetc: Annotate struct enetc_int_vector with __counted_by net: hisilicon: Annotate struct rcb_common_cb with __counted_by net: mana: Annotate struct mana_rxq with __counted_by net: ipa: Annotate struct ipa_power with __counted_by net: mana: Annotate struct hwc_dma_buf with __counted_by net: openvswitch: Annotate struct dp_meter_instance with __counted_by net: enetc: Annotate struct enetc_psfp_gate with __counted_by net: openvswitch: Annotate struct dp_meter with __counted_by net: tulip: Annotate struct mediatable with __counted_by net: sched: Annotate struct tc_pedit with __counted_by drivers/net/ethernet/dec/tulip/tulip.h | 2 +- drivers/net/ethernet/freescale/enetc/enetc.h | 2 +- drivers/net/ethernet/freescale/enetc/enetc_qos.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h | 2 +- drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +- drivers/net/ipa/ipa_power.c | 2 +- include/linux/igmp.h | 2 +- include/net/if_inet6.h | 2 +- include/net/ip_fib.h | 2 +- include/net/mana/hw_channel.h | 2 +- include/net/mana/mana.h | 2 +- net/openvswitch/meter.h | 4 ++-- net/sched/act_pedit.c | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) Reviewed-by: Gustavo A. R. Silva