Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2271240rdb; Tue, 3 Oct 2023 16:18:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFE/RA/uFQNpDyHjWhtPYW9eoNiKTt/yaoNTwABqT5jy32ek5lu1sJtwXYMY3zRhUiCuBDC X-Received: by 2002:a05:6a21:6da0:b0:14d:446f:7212 with SMTP id wl32-20020a056a216da000b0014d446f7212mr973260pzb.46.1696375123418; Tue, 03 Oct 2023 16:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696375123; cv=none; d=google.com; s=arc-20160816; b=c0jBG5UWRAsYT5wV/raPtXE3+rTcM7NiqyUYJwP4RGRJvZPHJpC08jkFDmDU5h8y0G F2E35y7o3jwuFM2KDJvQiENTKwtBubuTIMzHGM2bnvina3o6viOOjt02Iw6rRQvQK+Hb hriyWDl88U6tmKctr5dprfQyUrKC0rC0L3AEapX2VHtGxmJ3V6YX1s31jqzC5Jy0XGm0 w7iaDBO1Z2WPcTYSCrolnJqukghg6SPjq41oITbsTMeD8ZvLTR0FdVSra02Uq24jE+Co 7kmkwr+4hbLNoFFIYi/9mwkZ4D7/nSPky1RzHdua1RzQxMX9eUsy4dU2EfxqT5uxvnYt xNyg== 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=+XM09kEc8Kp8BRYEzLwAFk6cBdvMXUL/+IkaIgbusPU=; fh=DNrln7ER0d0qT5DFCEcofc3FzGcXhyS9797MKVNrZWs=; b=GsszWvCeHr9xYGT9F8qJq6g+ROwpt2g9Dvd7Rqsm82n0FiNrv48F4v6BkmdUDCEXYg pM1GKas+a4rw7d2uC9UtgoZ4AJqJf04B/n8a0dq5lilOcoES88wKdX5xp5jMxGBvBKnO GRMrvZJ7cnWQ8t/Q2Edq32//FYN5fcOhyi67UEMpMEGTDxfPiba0MK43eXcq/joKcEGg q4aYllFiAHvWbp6MmFPD7DaLmJRaqCtjqOSs6ZX1til+VKKK4LxZJW6OfO+ewdrP0qlJ cFoMw9oXJdR1WblIrz0rzCGb6FSIkJVw7dg3z2FgWhBZqcL+lOg12jHkYZiyiMjabEsT i3gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DgV33KWR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id cm12-20020a056a00338c00b0068a590d8043si2441913pfb.375.2023.10.03.16.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:18:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DgV33KWR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 1EEE88197047; Tue, 3 Oct 2023 16:18:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233030AbjJCXS2 (ORCPT + 99 others); Tue, 3 Oct 2023 19:18:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232636AbjJCXS1 (ORCPT ); Tue, 3 Oct 2023 19:18:27 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D12C4 for ; Tue, 3 Oct 2023 16:18:23 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-690f7d73a3aso1179388b3a.0 for ; Tue, 03 Oct 2023 16:18:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696375103; x=1696979903; 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=+XM09kEc8Kp8BRYEzLwAFk6cBdvMXUL/+IkaIgbusPU=; b=DgV33KWRjRyaG4hdlHqFwxcF+xsTY7MMOrQ8lp+fjpgkLw6S7tyTwNeXvDKeTuXC+q dDKHZN530ZZrgOxJ1IzrxdaZNyPgHY39l9hYVEpz14lyZ8O22vHvntA3g1TiC89UlV7l Mtzpm9+vXgIyrQpHe5yzxDmIzJ+ftDUXc857o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696375103; x=1696979903; 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=+XM09kEc8Kp8BRYEzLwAFk6cBdvMXUL/+IkaIgbusPU=; b=m0UWSzhphY1YycbGiy/SA3AzhpUQ1LUHhn0UNbvqXAsegbl7zDt4lMsGZaHZO1w/6Q 4eR7OOWod0t0neFvccCFXwGUWx+MRQMNGmjlcGfA66wsnOdxKobtkrx6Z2ErYEGbh7MV slOS13yTGhgvqEo3sUlFXm3YK8ABT9y2OF6YZ4ov1bS+nkT+lZ4jtSJF90jwUzSsyXjf BecgJa22m+GVu+LnFbU7OlTRi87oegLbi0WrzvK6GH/0GELEu3lpUqjFqqOHLAhERjaX 4+pzb7p66RVG4pkKzxi0AYaSzNSNBrgcVsNdCQuI3OHxq0zmolgmI3RpW1H9eilKxtmG eAhg== X-Gm-Message-State: AOJu0YxEz30JlY+rQ/5hjdj9qN24WsPAWkOaFhRGIwD7+Rkvu4W78TqK fIBflK3ngaeWpWEVxc3ou7Jzfg== X-Received: by 2002:a05:6300:8001:b0:153:5832:b31b with SMTP id an1-20020a056300800100b001535832b31bmr692118pzc.53.1696375102984; Tue, 03 Oct 2023 16:18:22 -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 c23-20020a62e817000000b006933c582ed8sm1897059pfi.20.2023.10.03.16.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:18:22 -0700 (PDT) From: Kees Cook To: David Ahern Cc: Kees Cook , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor , Nick Desaulniers , Tom Rix , netdev@vger.kernel.org, llvm@lists.linux.dev, "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] nexthop: Annotate struct nh_notifier_res_table_info with __counted_by Date: Tue, 3 Oct 2023 16:18:18 -0700 Message-Id: <20231003231818.work.883-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1440; i=keescook@chromium.org; h=from:subject:message-id; bh=AjwLE9p8WGopinEsMtaz3ddOS1mI0qnJXpq5C0mCIUo=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlHKE6FRvS+TBAwxc+K9caUt8f5xq1QuruutNKl 6rvdNKdQguJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRyhOgAKCRCJcvTf3G3A Jo+FEACDuxBwqD2j1hWN5SQMxl3AwTJawunug8XKcPvJfIFp/RTGo5A8ClW1vELUc4+BpLeROLv H119H972/sNz7cDkp2Nlo60Yk9V4jEhyU5mUpqiXjhUR8nnTZPJijFiH/wkyilrzoR+laOjaIX+ y5iEpgcZYGU04GWtAJDfObUCyEqkPhKfXtQQNri4Lm5pwvaKoAxprAufBtOY+xfselLRdr3M9K2 8rJ+IBolsSlAXKH1DftdiFSBjG9EmwKydkha47kSrOeMG4EMTWOfNlOj+YdBWoOvgg6r6B6hobI II7hEMTRvU5zBkb9jMAiE1MUR41bJFcMSSWInv3uIPQGQImd+PM2F+16cpUGdVWqMi/zY4MWl4d ZkNf3hGG2jsfcjW260crWJ3B3c/f7ik61m2RqIvv9gTXKwwzriycjijPvJ56VWzAkBjzHYz1Equ 4BzfYYzNpowHL2EVmsFWkwOLFOkg6f0OvU671kIkH7nJollSOeArKap+mtlpo2ZtSiR6nKgq2MM KCXt4zv+CZYnTmDaL6RXHJwY6D+HQRHjxXm/4W7pJviek1bH2cFpF90D3HVYkkFbds1nHi0mTyX 8f4hhCx3uO86L40eqe8XCihbEkXxUIKOk4u136dDDUmMByv6kH2SP/Ns/K9u/bhM7VW0tdp5jvj UIdLPZZ 1WOpGYgQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 16:18:41 -0700 (PDT) Prepare 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 via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). As found with Coccinelle[1], add __counted_by for struct nh_notifier_res_table_info. Cc: David Ahern Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Tom Rix Cc: netdev@vger.kernel.org Cc: llvm@lists.linux.dev Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1] Signed-off-by: Kees Cook --- include/net/nexthop.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/nexthop.h b/include/net/nexthop.h index 09f9a732e640..8f5a2ab45920 100644 --- a/include/net/nexthop.h +++ b/include/net/nexthop.h @@ -200,7 +200,7 @@ struct nh_notifier_res_bucket_info { struct nh_notifier_res_table_info { u16 num_nh_buckets; - struct nh_notifier_single_info nhs[]; + struct nh_notifier_single_info nhs[] __counted_by(num_nh_buckets); }; struct nh_notifier_info { -- 2.34.1