From patchwork Fri Sep 22 17:28:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143613 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5816829vqi; Fri, 22 Sep 2023 12:25:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdbnI1M3vLzFtCZqban4oEV2VT67WMUj7zR17bleHzoJW/AKJ/p5n7La8VOS2FLTqHmrTQ X-Received: by 2002:a05:6a20:244a:b0:13a:59b1:c884 with SMTP id t10-20020a056a20244a00b0013a59b1c884mr496074pzc.40.1695410710927; Fri, 22 Sep 2023 12:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695410710; cv=none; d=google.com; s=arc-20160816; b=IpxwnjxE6cNvg64EkaaTSaAuYHgh3Oh+0Pf8l8osF/zjAmxnIY81zUYu5sNYCRuEMe XyKuw3h7+UW5lihw0INFQg48dKiW7ew9E6gPHmr+eh3NeynRl0MoXTddSMWJsh+Mh3bB HD6luueYDoly39GojEavx+I1QIEGHRLuiD83sOIDsGjtXxvfZFhDxPQbjWxQzyHgJwPR VdLXT48OXuE3FjocZLoVR6vWX1FxFAv3nbUocjPIQb2hMJvPKlPhLM0LF3P5Q/D7QAIi 5UmaWU2PBUJA6CaevkUzu+I/rkr/1lNbvzFKafZ2dvgtm88Nxw15WosphBiuLF7wWphe oO+g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8x7bQDxEJ+vAEVTZtm+5duUGDbyuhOyRqLHGlsgE3Ss=; fh=LrFap7ZJ8IyOVoCT63jdvJyXFOje4IKGTB6JEm104Xc=; b=l6J1gl5klDgang9igFWVvzxIZoAUzMxpHI67bvhBEe+qfdNF9lBeNNr3JmKtrxYH/R KGmtyElC0cjtdbpmECEslJMO/IyFMROrh+jw1HeVGZmnGnzsBQY3eXnZiKIZcNxtSdPj tubbwyJjiKKpz8bjE4ShW9c9TwJC3SKPVWai7rkAxg9AHPSAE7aYVGxDRiUFXcl+IQn0 wFHUkeDimhAJu4N9/RLl7LKNf0OE8CIrALT3+EpHp2iWqiyJ1KXHsPdCVhz5TL9UP/lt gQM2s4XSk2naE2l0Zbp0zY3NXALgICfwm1Wcuv4bnJp6rHxytWNAWX05pXgNVVxedyHc 0nOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ywnen8g2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id b12-20020a056a00114c00b00690b88a9c32si4543254pfm.82.2023.09.22.12.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 12:25:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Ywnen8g2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 4F96B81A337C; Fri, 22 Sep 2023 10:29:18 -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 S232953AbjIVR3S (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232606AbjIVR3K (ORCPT ); Fri, 22 Sep 2023 13:29:10 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C55FD1B6 for ; Fri, 22 Sep 2023 10:29:02 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c43166b7e5so21834635ad.3 for ; Fri, 22 Sep 2023 10:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403742; x=1696008542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8x7bQDxEJ+vAEVTZtm+5duUGDbyuhOyRqLHGlsgE3Ss=; b=Ywnen8g2tiuhXANVYCzELEjXyAfBdmz7wrxzvByFd4e+cAlvTetJU/gEUkd0usSnOS mKtOg5Rtl9rPoysu7p3c0KeVLFNv+yA52V1KHH3XQFxzdjlCDkGbeG7TKnBR3Erv/+65 wHMgkQdjjlI0MZdp8enNYnhCgGIt60vTo1bpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403742; x=1696008542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8x7bQDxEJ+vAEVTZtm+5duUGDbyuhOyRqLHGlsgE3Ss=; b=RPquxIRjIzxgjvqxtiLZRj/tNsfP/CCtxBggCPIamPYUav4N0oyYS7jycKj71702dm qTRgKfRkbzneKjNCQJ/a/GyooAmcFJlF2ZBdPscw27SgKaBrkiOc99ljHj8kI6xAUSyM 0pC9nZm4LMOE3NG7K9bo6/JhLkNDXttomslrW3oyIS8bwA8+9YpF2/RWTXSG1CO7BR5L fFBflK5KaMEdlvqUbT9h4KjJkKKDorT7J2RrHhhw9m6VRB4sI/x/eNrBWgI5XAX2IYwo ylSYVWUdwovmsgIJTcG2xgf8ZgIzouHMrx5wvw1hhG2KBeoqQEx5ZPvugAT56bS3f05R jQJA== X-Gm-Message-State: AOJu0YwffvFV8WCV0uNEA//z0ap1Nj/GF/JHZnPjQbnypeSIEMek7tN4 I4rmxegzgkUOVUOHhsd4Vf3dYA== X-Received: by 2002:a17:902:eb53:b0:1c3:df77:3159 with SMTP id i19-20020a170902eb5300b001c3df773159mr114541pli.50.1695403741978; Fri, 22 Sep 2023 10:29:01 -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 19-20020a170902ee5300b001bc59cd718asm3748963plo.278.2023.09.22.10.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:28:59 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , "David S. Miller" , David Ahern , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Jamal Hadi Salim , 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, 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 01/14] ipv4: Annotate struct fib_info with __counted_by Date: Fri, 22 Sep 2023 10:28:43 -0700 Message-Id: <20230922172858.3822653-1-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1203; i=keescook@chromium.org; h=from:subject; bh=dITmoQTmuhgzCLWCT8goEHfc7A830wvh1pihCZiDgng=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7W581CiX0BzIe+nRF4lrrgJ1mImWjZxMUky lhl45FPgwCJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1gAKCRCJcvTf3G3A JkxgD/9FJt5i+12b1FsimGOC4rvZuSOh0fD5qHoltugSaCw499cKIkWY4qGZeYvZrUk/VYa+HZI Y1E1zplO4VIUWFc80b9mGipW2Q54e6MVVeAovzcraatq2BSOVpOWRAbSUY281k44af6Gtf+2mBs WOWy65xHdw0hvyD8jqTd8MMpVfq9wUgJiUSRlTX2yvNlUL0CUR9xPOI9i9pvWG4C+OnvabSctpb ixyKCTDUXy3+CJoyEA5Sit5mwYWRoegNNcPDJNKvMhzUEKMeyEEhoOPDDaPF8pRrfeQVX5KV756 E4KlQi7c9BlvkTwUI6fnYnOoxKi+4OS+60VRBt0svnxPupKqu0zr+DNDORx0bln3OZmq528yFTh 8ZontT0IXYdHSjmkO+UEJKCl/88D5e2LgwJRoj5gYxKcE9JqS9WQffGYcokW51pOUfGKBT12r4m dX2Hb24VXL3BJb5d3Gn1VmDidQgp50eEBiimYRKDfH4ItKrIyLysiwe6PcDNknkDIbAcjQF9Irc 35iHi4lgvDHPBz6mDA4C6ARaURw/bvc7EtRzuRePO38phoNlzDwep1XxUQiBgjfK12Pm9o80j79 SNVi44GUOM1o9BuXUhT0KUHCOh+ALyuSPWw3T8gMYKvOu+OU341Y5Tjavk2KgvxyGjew6YnyYDs ylWk8JpcjP0A8zw== 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_BLOCKED,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:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777762264765320180 X-GMAIL-MSGID: 1777766981515790077 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 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 for struct fib_info. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: "David S. Miller" Cc: David Ahern Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- include/net/ip_fib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index f0c13864180e..84b0a82c9df4 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -156,7 +156,7 @@ struct fib_info { bool nh_updated; struct nexthop *nh; struct rcu_head rcu; - struct fib_nh fib_nh[]; + struct fib_nh fib_nh[] __counted_by(fib_nhs); }; From patchwork Fri Sep 22 17:28:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5802150vqi; Fri, 22 Sep 2023 12:00:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtWxUaYqBzplNDFh70DQfmXCY1lyP/cUQe+IyLdNTYx25E7c/4OBCauxuo3UVTsbv5EDvs X-Received: by 2002:a05:6358:4287:b0:134:c650:cc0a with SMTP id s7-20020a056358428700b00134c650cc0amr408993rwc.15.1695409223590; Fri, 22 Sep 2023 12:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695409223; cv=none; d=google.com; s=arc-20160816; b=Rg6sz3g8pV4yj+145Sjzoz2F0jKAm9ocIYIndrhqJGwnvKjlzs5NoQ5qdcU00gcbOx ndKlPBknzWGHCcUk4pnPkzcgLq1givf2OegD6BlibhGI7Z/NpUUrXPKWr4Bud1BCBZEA q3suY+niHf5eX+TXe/9P26VITp97mYDJdftjYBlfmM8Os5eJ20J7ihY6ElghYcGfRyWp M9n+fRLvJ2WgV2xUQ45EE/5B+5QKF/ZWvAVi0520CBofpqE9GsH2SyyaSK47oFN790kP f4k2ugVrZ8lDSr6dx7PT1BTBGmxoPsCAOQvkP+4XxCCBFoIXE+kKAcKYMQ+n5l/7qU8n GwgA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YQgcIF4PySsFwzeoGRYEtks5LIc34ltXAoSUNKMo2rM=; fh=bv/4PqN/dWkcv/i3CI0ZV13h9Kn8CCiNcK3e9sFRHH0=; b=EpTS+w9NBemjY+rKGYyNucR+i1wJ0fHn2s3JaB1gHSfK0nccnsxNOe4qqrhHccM4Bn 9RyHQCvRM1Px/sDaDij24kroPkuGnXpEZGNGZabRMJE6RG8XN+vq1GvPi1gcQq7H6wgP nLIBSUX09SU4ioQsq7ZLxTZ5VjVj8J+Rjvc4Y/OgsI65d7/8A55/ZbJYbyeuS2BADfj8 CS2fxQRYU/PCP17TDCYaDOKCsvN9Yfx5szuzDBVjwLdQtBksckPN+LFbHug0tF0MzSoU DsSKMpgcciac+yvoxlW5aIWJfLiSvCYgH17h7Lef4zyfBd0ESn1HYjwzOMiQBlYpQnbW TWjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mSkhcL9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id r200-20020a632bd1000000b00578afd89baasi4213541pgr.744.2023.09.22.12.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 12:00:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mSkhcL9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 8F5AF85C6CFD; Fri, 22 Sep 2023 10:29:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232265AbjIVR3K (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbjIVR3J (ORCPT ); Fri, 22 Sep 2023 13:29:09 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA1719C for ; Fri, 22 Sep 2023 10:29:00 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c44c7dbaf9so21953715ad.1 for ; Fri, 22 Sep 2023 10:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403740; x=1696008540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YQgcIF4PySsFwzeoGRYEtks5LIc34ltXAoSUNKMo2rM=; b=mSkhcL9TEa9hydf9ojWyGlsNy28su6oNKnOUyO2feJRC98SbLIqAQ+F0lyRwx1RCdT CMEgYQhgmI8GTtZoyKGGjRlQQcNC15aizeCcivLzbu6DO+2XrevmPp859gLuJ8nMNYv+ IT9U53XPaTbh+qoZkq9cNu/NU7NnBaX4UD2+Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403740; x=1696008540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YQgcIF4PySsFwzeoGRYEtks5LIc34ltXAoSUNKMo2rM=; b=Cy4w73rkmjrcYEZPqCGI8VU5ov9dRjWLJc8U8aTeeGYYuxN6vdWe1uDr86mQ4xf26F kGKTNa+zh6eTnhfUKCMo+sxU4Ckzl9OeutF5KYbcpndXxFj2zRSfVOCO8RoJ6SWhaY4C PkY4lXetxk2Sw2jjmfwnlUy1jHhbVEHnaopiPzfHqiPse84tzl4CKoA10x9AfNPBTQRi /LuAur7JN5eCkH+rGo4K+7taYWxyl6PjGZ9VyDkSwfcVqRcKQQgWDYkANntEWVkPoIkZ XkZ1+TJj6x5gk4yXN+AH/+3hbKKJP2u3IOi3sQ1yfyVv66CTjhT/L82Z+uQKmQwFjTwv /UdQ== X-Gm-Message-State: AOJu0YyPcgLzPWActi3X1EBqeN46OJDcZZu+1aiTeMTr1gbBrGpYhPFa Fo01UnNaGirKFolNuOHK7NSvyA== X-Received: by 2002:a17:903:1104:b0:1b9:de75:d5bb with SMTP id n4-20020a170903110400b001b9de75d5bbmr129615plh.7.1695403740055; Fri, 22 Sep 2023 10:29:00 -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 ju4-20020a170903428400b001c5684aed57sm3747496plb.218.2023.09.22.10.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:28:59 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , "David S. Miller" , Martin KaFai Lau , "Gustavo A. R. Silva" , Eric Dumazet , Alexei Starovoitov , Jamal Hadi Salim , David Ahern , Paolo Abeni , 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 02/14] ipv4/igmp: Annotate struct ip_sf_socklist with __counted_by Date: Fri, 22 Sep 2023 10:28:44 -0700 Message-Id: <20230922172858.3822653-2-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1297; i=keescook@chromium.org; h=from:subject; bh=6I/UlxaeVfPSNCQK2wJRk7LvdQNOEqFwEHhj61WBOvM=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7WtZKzI4JHFCjzeBDKOaLb2wkieWFO9YYNa DG+55LdCDKJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1gAKCRCJcvTf3G3A Jm8qD/9eheMPlBV345+ln0OsLw143sFPp/IgjC2ffDkvS+vNvlyGKo1pdDfWL/Dy6yQbTqJIKWj izxzityDxwVA5CrakAWjh0OUEc71/HYUErA4IzMs7+UoxJbgLn77IWWpyw9Xwj46b3IrmRsWA63 IRzPhOYgKmjgTZ0/P5uk+86O0fX3UFW7aDBTUCxijuYfhGodNshSKQoHWNQDyR+Runv2Mr5/nrV 47/zpDx45NGiHVXKH/RB+v83VHSSg0B80AvuKBtrrECHT3uGd0vQxajYOXF6kIdhsnLEojhkSdB 6hJsvl9SL8mu/kw37S2hPbbF7ZSwyNqtNPXAJwTUX91YRDiwUz/E2Id35bAX6iAYZJPOgqQNlba m9sGLSd5M1FNeb7BMZFfkHlvXtRU3lGqmxTCythMv9l5vOFelYrWm3Ed5DsDzUJso4uHqMoeJLG abH8O7CdTeYTSBEPqKO+hOU2RbQvGjJSGgpqkNnGadIH7wsREbIh4wpGIoeyjG4AFJkWcJHPW0X pclEzg1B6BV3xUvk+Orq3M6MIdEdE7Qeag5HRs3i20O1tA/6Nt5Zg1GDi6PGIU8czPirNy7vi7Z 1/e6fS4U10TVhrJ0/X1IdhPx94mERDlb73y5W8AJNMIpUO3NKcKwi94OZp7UCYdY6dy+6ShVhDg QMQF1oNmMT1fAvg== 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_BLOCKED,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 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:29:11 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777765422076933528 X-GMAIL-MSGID: 1777765422076933528 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 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 for struct ip_sf_socklist. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: "David S. Miller" Cc: Martin KaFai Lau Cc: "Gustavo A. R. Silva" Cc: Eric Dumazet Cc: Alexei Starovoitov Cc: Jakub Kicinski Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- include/linux/igmp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/igmp.h b/include/linux/igmp.h index ebf4349a53af..5171231f70a8 100644 --- a/include/linux/igmp.h +++ b/include/linux/igmp.h @@ -39,7 +39,7 @@ struct ip_sf_socklist { unsigned int sl_max; unsigned int sl_count; struct rcu_head rcu; - __be32 sl_addr[]; + __be32 sl_addr[] __counted_by(sl_max); }; #define IP_SFBLOCK 10 /* allocate this many at once */ From patchwork Fri Sep 22 17:28:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5856638vqi; Fri, 22 Sep 2023 13:46:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFL23gzJZ7EB45adg7MzEaUU/6PgZzutMaFUkIjatFuRI6CKv2flMlVn2OFOz2Irmm1YRWk X-Received: by 2002:a05:6830:20c1:b0:6b8:dc53:9efd with SMTP id z1-20020a05683020c100b006b8dc539efdmr780902otq.3.1695415618643; Fri, 22 Sep 2023 13:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695415618; cv=none; d=google.com; s=arc-20160816; b=kgvvJMOoO1Te9yDBZTH224B1HEoLW2dKLt2yVgQM8fJJxOPWP0RkgvVU9EopPfhjc2 l+2jS9a7oaCkWqAoU47OIIJG1qtmvRgOfJ7qJ84uaxWmryAFvsLf4qMrCD8uiQxjyTg5 U8eGYPk7HNSrA1fB0+Ruc8cydiaFtl7U5YVp6dkCcI69H0Q0yWOWQg4dlVX5eLKwJl1j 0A3rABmSsruSlELyScQxEHI5JrXygq7OxmQ0PcMHUnOEq1Ybw/fO3lVCdYM82kk1HdcN pWwEPaKsyHaN5zIRWat1leeeLtUlzDlIAGI5jHTI3kI9jB9wiUhxLQwc/dmEPN6raFUU Ylyw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gnbuNOS48ZNXGx3qE7i6qDaIIscfCr6TPOESNc92Xe4=; fh=8N0VtS2yBoutbiuN23ZVoFZ67fBZP/6DdoNSV8uowIA=; b=EPT1VkjlVaSgLbgL+ot953o65239ur0VI4olpApsWuLWJiL47CFlirXZBx1sFP3WQi Qv4ulAaGkK2MJhKVNGLxKoLsfkd7LCA2KGYKnI/7yh58v0rhpmJx0C5BPcjAUgI9Ti6V Pv72wO+1qc5nU9kY0fpbyNysvtYwQeXFzhN5MAQ9zgNC0oHc3keL6kwWPxbr1ReRF4l7 sqCgjy6+/YEf+CQ6ToXKJ2TYxNnapdO0+Dcdm/xtt4uw7AyrztGxG0DZbqUSKTHrdrjt Cts2IEEkTwsaU/r4mvBHUYQA0FogbOphDCb3Bbx6JGWD5qU9PvmaWvxYcgCsMdjlU99G lKHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EQTEiUEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id z16-20020a656650000000b0056a1ea34f45si4149899pgv.670.2023.09.22.13.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 13:46:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EQTEiUEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id A6F9A8600C68; Fri, 22 Sep 2023 10:29:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231173AbjIVR3P (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231716AbjIVR3K (ORCPT ); Fri, 22 Sep 2023 13:29:10 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F16B11A3 for ; Fri, 22 Sep 2023 10:29:00 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c5bbb205e3so22959145ad.0 for ; Fri, 22 Sep 2023 10:29:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403740; x=1696008540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gnbuNOS48ZNXGx3qE7i6qDaIIscfCr6TPOESNc92Xe4=; b=EQTEiUEhu4mw8Yllk6I8iSDL00rrpzzbjxGgHTm48P94Bsy8w9FIcAi0/YNwy/HEiP 6pkON2YkTTKs/Gz7lVq1+Go/ui3PGl79b/dT3o3wQ5+t1t62piERSDUHsAXph1u7AoDD fRH+c1YILqSDofLactDVzr683oaR2NjaiPTVk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403740; x=1696008540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gnbuNOS48ZNXGx3qE7i6qDaIIscfCr6TPOESNc92Xe4=; b=pDZM7K1NiNM0aJWd/+RC3gsegIHjT6pAviDiGpoKnwCsdQmrrW4JunHsraSaTQ31Eb z4YdiFQDUakMki6kb22/eRvpMOlL004nH2Abh0UeThQfoCF2BMEL9czb+iveX+Mz+8ZS WnrbST1+wwKTOpHib6hEBiBqgwCCg+rBKhgI8E4IJ7X3bmy6k2VUkR/yFyQLrYX7mQCn FU1Aj2WpQMkTDER4r8b1nyxIGrxIBVTmS3g/QW9FiDyLF966PbmiF11wA5bxlcKAUAO7 ftqj1dFi2INP7j8cg8kg8eJW3tJeKHM5v3k8xJuoPauRWlipO1jIMY4dgLNSQV3aAHaq wKPA== X-Gm-Message-State: AOJu0Yy4gFEkuoHqaRRNcuPt6/54LHRw+2CqYGC7qmTDBVaAR0LgjewU rpcoefgOViS8bzsIeP9k2RvM3Q== X-Received: by 2002:a17:902:c950:b0:1c5:db4e:bb2c with SMTP id i16-20020a170902c95000b001c5db4ebb2cmr107551pla.64.1695403740357; Fri, 22 Sep 2023 10:29:00 -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 s4-20020a170902a50400b001bc676df6a9sm3728000plq.132.2023.09.22.10.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:28:59 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Jamal Hadi Salim , David Ahern , 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, 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 03/14] ipv6: Annotate struct ip6_sf_socklist with __counted_by Date: Fri, 22 Sep 2023 10:28:45 -0700 Message-Id: <20230922172858.3822653-3-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1253; i=keescook@chromium.org; h=from:subject; bh=2ca9VJgIAhIuAJFgWJCeV9xORJcl3qwKnOZDA8bb15U=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7W7yeFnrNv8DYkf6K4e0eMtWV9Ow6AlOLTo oQ0W7nV+tuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1gAKCRCJcvTf3G3A JuwVD/99skLCWI618iB8ZWCJjHBr86wQXUIEC3QazU9r6E9O7WmV0Ca/Lf4PWUdmKTLzg/NbH/u PxF+kuGXZ27LalW2q5dPBeBElEVHRSJvFP2s41TixGzuoc5Xdrd2dEXv1qSLw/Rjy4Xd2e8J+Qz buwXxllOFRxP4mw4JWs4lNcQsjzWCGDuY2kxs9HEPNcCaYeWz7/iHab5eXWQPMJa+FdS9adHHsl wpkVBE9c0Gr5oR1ONhxCz3l7LLoQvKYOrRcpV3r5cQY2UEhswD9cwAzi1ZMkGsyUi4Afuw9CR1z /5Jvu4yVaonNtxPE6LiYgQJA51cSvzH5xESn+y35kK8kyTade6JnWBm5Q4rXdyWk+ugx65LbkwS fx9jcKY7HamgjyBzwEkaX9uhOGaXzINDTENvp1r/aTCWmR9YmiE/jDI8aRFXiQljqz29BmXk5k/ +T4OSX+S7Zp+e3WWMAmyMtg+a07jEi02oypRoZQdmGu7CcKNueojV959YMXDu2dTRVV4M4y1lX0 WYVzplIFKHsZsjYKtUu9Qd/EBvBXrRNdvkL+Ecy6CzUv47Xmv1U24pUA6t/OG52eSB0WL2c301l NVQbrUOCSH9rcq6GuhVo/p+W/5eVeCs+cRKjQFm/pVPZguH2LfFggOeb0jA1vRwuZcXv12dUNlk tsNd0bZ4UfjHBvg== 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_BLOCKED,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 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:29:14 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777772127754870237 X-GMAIL-MSGID: 1777772127754870237 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 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 for struct ip6_sf_socklist. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- include/net/if_inet6.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h index c8490729b4ae..3e454c4d7ba6 100644 --- a/include/net/if_inet6.h +++ b/include/net/if_inet6.h @@ -89,7 +89,7 @@ struct ip6_sf_socklist { unsigned int sl_max; unsigned int sl_count; struct rcu_head rcu; - struct in6_addr sl_addr[]; + struct in6_addr sl_addr[] __counted_by(sl_max); }; #define IP6_SFBLOCK 10 /* allocate this many at once */ From patchwork Fri Sep 22 17:28:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143637 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5840040vqi; Fri, 22 Sep 2023 13:11:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+Xa9Wa6IGUNqBvjtt3SYQ7xtKwqWN+l9THEsEEYAlVZGSoL+/3lGjH5yeqwDqYAmQ0AKG X-Received: by 2002:a17:90a:590b:b0:274:7dc2:45fa with SMTP id k11-20020a17090a590b00b002747dc245famr748477pji.1.1695413489894; Fri, 22 Sep 2023 13:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695413489; cv=none; d=google.com; s=arc-20160816; b=TJLooKdTKHvaiP2POicmMG3gZnn6rWg6eBdVX9X1N9eDStRbf2bYhWqlSUdHd6W/vQ q5NR8hxR2K/ZLpZ7R8v6Ka1BGwfWHzbAHZwF2hjt2q0kFCIg3ThaLaJA77jHtbvkQ0ZQ dE3DVXmHfA90uViHrst2Jbk4oyA2TtEHhrcfq4zdQb4gWkoZxrBiDUUw7mzEA8A5NWcY O+ETVQnujEavX5GFWrUxCF8AWZL9BgBXfSoyPoAuHqEO2GTrt27q7kM6DqiSL8wPxvFP t/tn7EABfH4bVws4JFtHR4g07DiXmmHUMDixbpYhs3VjVj4nhA+Se5rt2/o5FeGEsEU1 xD4Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6Vq50cO/AnizqX6/47UHK+JR2ZlGTPocZM47T7rf36c=; fh=pnnt6d0aUHW+JiVFdyN3gJ47v9ZZxL1plXbKoFiUfvg=; b=Pt/8ktE8/j0A2aJI2PtBECTvWSfgAtlyTUmwAj+7ADkL3HuRebmdqC7hyTFd9+abid 6DAk78GjTB7s/Y0x5x4xgWscxQb/+0we2d0wfsI7c6GpoLr3Vo8C1Qo+jOdrJW8BOT6D VHH5f5MvZe03ovZcf/hh3qzoNXvsKMlsf7PjmwPyqJ3srSZbuleb2aK/tVrQvgyOkj5S jke4jrJY96liX39leBvt6J8mmCtW414z7TYHes2g7j8MaBQLdfO1yoYVSh03zZipmmRY 16DDt3BntX9fHiHni95S403aeAy1tBhes8A9o119fYQu59rWz2Qwts6conJczLvWNVx7 Ol6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X3Z5KANW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id mv10-20020a17090b198a00b00271a453203esi6640882pjb.130.2023.09.22.13.11.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 13:11:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X3Z5KANW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 11ED881D2AD4; Fri, 22 Sep 2023 10:29:26 -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 S232983AbjIVR3V (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231789AbjIVR3K (ORCPT ); Fri, 22 Sep 2023 13:29:10 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F2FD1A7 for ; Fri, 22 Sep 2023 10:29:02 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1bdf4752c3cso19958095ad.2 for ; Fri, 22 Sep 2023 10:29:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403741; x=1696008541; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6Vq50cO/AnizqX6/47UHK+JR2ZlGTPocZM47T7rf36c=; b=X3Z5KANWvxS+2EiRKfgJM7+MZxtACYSo3V6zJ7E3dMI4fEx7GrcUwmJz0u6hM3Z5SL bJfIxBgdKE0PxdvrvnpzjvMCA+CLJfLoNplE0b+p/NLiTxsaQksasV5Yzy1/frz4sRFu R6CCLxm9CupFyFKRlANs6grhAYCZNKdlzBfs8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403741; x=1696008541; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Vq50cO/AnizqX6/47UHK+JR2ZlGTPocZM47T7rf36c=; b=sG3/UxeeNEbNXqBIbRo+FRT+uiAYwoOxSaiZZjGZcqeuBR/zb2bbv1xas5+GRlf4HS D+GSmGduxsuGUwSVWU4lQ7IcMKfYqSkIu+VQFiOhPnhau6u0M/+GHT2ZvfunL/J1A+Ah Yv/6DtBu3LD0E7asl92hzUDXP3qP7tf6UNe/qXnSvbu/OpgAU/rsJyq/68liiCfAOJLZ uaqZsct+e5KyXly1//aXa5aOyoWVh5Pq3UH6uDx/Ca6oZBMf582+4Erc44e67CA+dHZD XjBzLzuB++Gp/fI8kaxbRBPZSq3v79jsXDsI5EqSyVr3tI4lSZFnLjJDNIb1HHbpXoYY Wftw== X-Gm-Message-State: AOJu0YxDJAC+qfQ75z4MvSIN6FxnQLr89/UCvLdxE9/Ly1Q4NW6KIoun wxpH+Wq7ppxegMzcdhczRnQgdg== X-Received: by 2002:a17:902:ce92:b0:1c5:be64:2c71 with SMTP id f18-20020a170902ce9200b001c5be642c71mr152987plg.8.1695403741464; Fri, 22 Sep 2023 10:29:01 -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 iz19-20020a170902ef9300b001bc35b14c99sm3751035plb.212.2023.09.22.10.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:28:59 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Yisen Zhuang , Salil Mehta , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Jamal Hadi Salim , David Ahern , Martin KaFai Lau , "Gustavo A. R. Silva" , Alexei Starovoitov , 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, 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 04/14] net: hns: Annotate struct ppe_common_cb with __counted_by Date: Fri, 22 Sep 2023 10:28:46 -0700 Message-Id: <20230922172858.3822653-4-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1399; i=keescook@chromium.org; h=from:subject; bh=cTl8c1Nsj5H86YDYuCjzIM6AfXRPvipiHH9wexbSTFs=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7W7T7fWYQIhp0VWwCK4vkC2/gAT7GYx0S2a rDc3obMtJuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1gAKCRCJcvTf3G3A JlguD/43W9S3RVXTT12fwP5xKbgPceVLaoFjLypFqCmF90EoMP0tlys43BbYW9AL/UdsBC/AzDA daZjg3W0qJcSKHCfa/fw0KI5T7Ys1zC/WuM6VgF/PnFd90CnKJyFqT9w8APuL7jJuLkioTLXFNm KKr/xM/Q6RpBeeCmnOPPla1PC1J7fITAPWboovdEmWaNXJDeaA/cqkuc0O/fl2bK34A2E+YRSX1 Ga/1u7Et9/vZoGrMjL48CarwhFBgZ/07BX1Vi1ck2cFt3Vgf9vNaMYswfMP2jTL88g1pO9tP+iH +PtCE2i0idGsQeCIQpAEjzfUjgiVq6LSuzhhFhZxO+CZpG+ddA6MhWJBLB+OALoPI0/HszPfbQP tjDdztTV0Y1ijsgDX5Fo/YENa2cUZXIOSoNxqs3q7ZVixjjXKrjYgplwnqm5Nor2mYpInDP+gRr 3Y1KSMXIduKLLeC6nxgv7sdqWJffKmjhvFAbpJi86vpkRq8IZ0BFFxHvafq4MKH3bKaPgpR4HJN HpHjwpAnZ22Cavskf4a41Tuxb6Vpf/edTeJBdNMHPAAUyCfy1fuc9k9ywm7blE1SvkPrxqwwiHx Mm3miLrMAtDE7GIEY1Cp+8oAIBA9+hZbl0or6VFDsIQkuczyrghQ+29chyaUqnLYAEIV2DL78yK qSGI6K6tMv6mcjw== 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_BLOCKED,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:26 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777769895704062040 X-GMAIL-MSGID: 1777769895704062040 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 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 for struct ppe_common_cb. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Yisen Zhuang Cc: Salil Mehta Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h index 0f0e16f9afc0..7e00231c1acf 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h @@ -92,7 +92,7 @@ struct ppe_common_cb { u8 comm_index; /*ppe_common index*/ u32 ppe_num; - struct hns_ppe_cb ppe_cb[]; + struct hns_ppe_cb ppe_cb[] __counted_by(ppe_num); }; From patchwork Fri Sep 22 17:28:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:81b:b0:402:e146:ef86 with SMTP id fz27csp1822137vqb; Fri, 22 Sep 2023 17:11:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG47z+d8V1l874Fgeq5afbDKk6J1xnhcPJSosTXfTK8X6NJIj+b4Mbulh58fIDcludyTace X-Received: by 2002:a17:903:2445:b0:1c5:cf58:48f6 with SMTP id l5-20020a170903244500b001c5cf5848f6mr1121405pls.57.1695427904829; Fri, 22 Sep 2023 17:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695427904; cv=none; d=google.com; s=arc-20160816; b=p42GANYCeKGZx15ibZxXZIzb9Hj07Tw+lppS5IALgkx6XDanBeC90jHwwIKT3qmGjo iC2nwAGsz2dhNA/LC+dzhtEAjhhUWZZ4C6biUh1Xkkd0Wlh17kQKLIreGKmytFlf2OMf kp8SUKj7qw43qPoi+OBX8oE5fwvreV+YXkNFjhufzQ1VXnemS+2bunjdq7160ZYIDXok VcVoseupzsHJ3+pA/K7bDyx45xPNtMsHN+qXMcyUK6jr3bWEp+TneQUfW6KNgCg9YtIA +SCXg/AdiQzZgpNfQ7aTNiPC1Gps1k/2Gd47ZrNPlXgBiI12Ouu1T0tdyQbo3zMO4BdB BEQw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jsPm5p8OVWWQhvwQRnJAR5En1I13+6E+l5lagSHHfoE=; fh=udbq/ASM5GPloArVnDry5+1gGOZpGHNygw7ly8CtxKA=; b=jxNlBpBoPzXd5efJQoqZWhpmwOUOflmA5ljjd3fv8XzoVm8Xejr/Ai7jOZkVMrvhux Bf0/Z2hG16Y0y2EDI7YiOc7FhUodSkHRvQTd50Jdd58/QNw3RtASBNMoO9KGgbeEeCfH Bi+ld9bG76Gf6OZIxb2/VkUUOV7/Sqja/KiUUaykXOda3BWfmdQWK4iVfnl+pz5tGMtD /YCXlmE8CYB/CdQ22dLDpdWb/RteZgC20Lu+SHqKJzwh+HMDUU41Hb8AaNjdbK3Mq7fs 7gNq6qcuWB1uGCUDymSh4H2vq701c4YO/On4tb1WC9Hpip+T3bcF2ptX/FmrdfJQWZEn eTNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PlSIN8Fm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id o9-20020a170903210900b001c2218c375esi4521894ple.445.2023.09.22.17.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 17:11:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PlSIN8Fm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 478E6860AD1D; Fri, 22 Sep 2023 10:29:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233260AbjIVR3n (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232971AbjIVR3Q (ORCPT ); Fri, 22 Sep 2023 13:29:16 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6C2C1B4 for ; Fri, 22 Sep 2023 10:29:06 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-691c05bc5aaso1964868b3a.2 for ; Fri, 22 Sep 2023 10:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403746; x=1696008546; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jsPm5p8OVWWQhvwQRnJAR5En1I13+6E+l5lagSHHfoE=; b=PlSIN8FmnOTcSZTQ//UJdOk4CJQWcDW9wR3D+7xBohFxAFQZziU3sDcxUmvfCLG5Jr VrBV+Xvm6mD89RlsQrWlk6cwYGPFjk1QK9o3W0kvaLHD0V6BCs8CcucKgqSAW3rlu1cv v9CitUGc5ZX7lcvprHSEzRHkd8YcDaye8qf00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403746; x=1696008546; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jsPm5p8OVWWQhvwQRnJAR5En1I13+6E+l5lagSHHfoE=; b=hdXhr53G37SP5vbNTUPdcLL+JIBaFmJrsAl+zAsrJK48u9ldRiW1CMWHqzwrdLE7wv YxRnbiVuS9YPqK2HayvFOOsMczdWbv9U+alXiUUfllNuPamDsZatbW2V4Jj9gDJ2l+S9 G/RqgaKBiHQxqCarl5m3ve+kaskfsurw2MdXqVgxRyLvUs6WJVUPki3D9gXEl6Ak/7nt qlStCzAoVw/RAAI+feslFWGaAi8DjJexZgDnFex2KhRB0Po5l3SMLRQjC4Rk9PMtnaR2 DtQviSFOO/CZfzj7s3jLlxzjov3+eTP3V9zMb/YRC3SVmFtXy+BJwBHBH//NeZOOv0q1 Dxcw== X-Gm-Message-State: AOJu0YyeQEiCf7Kuioarqh1E0pBkWMiSTFAEGMNKKbwYdhGxFa1WLLDp G7m6I6LqSaQoWKHnmyGi0IH85Q== X-Received: by 2002:a17:90a:1197:b0:268:18e:9dfa with SMTP id e23-20020a17090a119700b00268018e9dfamr351769pja.5.1695403746060; Fri, 22 Sep 2023 10:29:06 -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 t6-20020a17090abc4600b00276bde3b8cesm5199670pjv.15.2023.09.22.10.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:03 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Claudiu Manoil , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Jamal Hadi Salim , David Ahern , Martin KaFai Lau , "Gustavo A. R. Silva" , Alexei Starovoitov , Yisen Zhuang , Salil Mehta , "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, 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 05/14] net: enetc: Annotate struct enetc_int_vector with __counted_by Date: Fri, 22 Sep 2023 10:28:47 -0700 Message-Id: <20230922172858.3822653-5-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1453; i=keescook@chromium.org; h=from:subject; bh=NFekoCD1Jndm5KHIwVT2SInoZJX6zogZTm9dOrowHzQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7W8CYHJBq+iZChIknbZLiTR3vO/ABrVlFx0 5vu41SusMWJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1gAKCRCJcvTf3G3A JmMYD/9COcX3uXskEKki372umoZXpS81TFgyqr1SaYIobu+5/nsnHubNj4XIFIxtkKLQ9x9iJNr IGdgXYn2Ne+XjjnR2+5XdpYSVYBhpwMps87h8MkXg3FgVtutsJSrhDEKlalntK4k8P9/tEqbe5V s6/2BskuqXGJHZntea0S9oGq10CGovJ5oyy4N1B2ipZQ14jv2qyZJ/lL/L7Q1aceJAE0WCEhhlO ewuaoB4Iaj1WVPn8GmFZWHflwlLoeFYnDxWVtW/H9p1oAJbaNHvU5uaKdOs4wZmZtVealaxZifp DQvaHczxdEA/tAnbrF6p4+WcJlKt3/9Icc0gj7E9oH5U6B+L15s9vqreUMO7oLmuL8aZvODffmt Ij1zFTVn4YdJS/plXhp20WXehVFBbKACLxaSMDoZzAKtEyPU6PXeaNxRbhcgJbShgddSkKTUYWP eokdZ178LoIMhSB2zIB02vsPNIewOqKwQ9sJb3K+8fgUVP1PNSUJtgPxYmcO/8Rgb69FwD+w/YW U4BvwhJZ4C/8DUXSM7dMugskhUaorg2i0VNx/i8UMKoL19+6vpEdmgzWJAmKG0fzPbZPtx0/pQh 6PJff6pa1RRmV9QDJQuRueIM2N4jPj2I500uPYvFks3+UgRgZI5TlteIopHrUU9XbzdtZlI1afV Qrj7qVw0gAScGlA== 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 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:29:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777785010697323783 X-GMAIL-MSGID: 1777785010697323783 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 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 for struct enetc_int_vector. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Claudiu Manoil Cc: Vladimir Oltean Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/net/ethernet/freescale/enetc/enetc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 7439739cd81a..a9c2ff22431c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -297,7 +297,7 @@ struct enetc_int_vector { char name[ENETC_INT_NAME_MAX]; struct enetc_bdr rx_ring; - struct enetc_bdr tx_ring[]; + struct enetc_bdr tx_ring[] __counted_by(count_tx_rings); } ____cacheline_aligned_in_smp; struct enetc_cls_rule { From patchwork Fri Sep 22 17:28:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5932657vqi; Fri, 22 Sep 2023 16:47:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExoPWEPW9Fsej/qZq18RptOmgbBzzDvdafo/0SMqcOn1xqoKaU9kTjTDnFSCLp/qrn8/WW X-Received: by 2002:a05:6358:5284:b0:143:1063:d1ed with SMTP id g4-20020a056358528400b001431063d1edmr1326342rwa.26.1695426438575; Fri, 22 Sep 2023 16:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695426438; cv=none; d=google.com; s=arc-20160816; b=Vgx5uJSiQOmld5OCE8Xm6jdYx4Rk0zRV5TtDzycuQeOXCJn4kytqc2Qqx0HCTweQD0 Ay5IMyKa0deZ3+jF4D3D2BULiMMtXXzsPPjp0ustOBcwhC5+pxcgw7ZwueITptFqvjva NcF9/+tU5yJ3YJ5yX3D76H4o6tXIY4caF9tV1vmZZi9Ftm65T6o2hcMuq8xD1jSZyJOE ZTtjvv6uGQ47pazOow0Kt0B72Fyn8tl79ZJfX+hOFxgGhBfqTGwbWLU2pk6/PUgYTMPx JNbwZVIuLqLMOUw3W5EWFoC8l9ZvlyWCMMVCnxdtvDaf6nlf3+rPV6vuiAv2WknF03i2 TQNQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H8wcxdgkYAvkCOCoP6EB5xh89rywD8lhufIcjStIsos=; fh=pnnt6d0aUHW+JiVFdyN3gJ47v9ZZxL1plXbKoFiUfvg=; b=E9FcvD6zRUkzjJYeyZisQYqnPK5XJeunSTaWVP8qBZYIXPbKym8wdMeslmrNTz2VyP lHpEqUqiByS0cVUsRtZ1syvOrIyOCpiAIxpX2l3Jmxg1Cz+uUx7lNAJVP7fYYcwH87sg xc2mecEVKaTC6NOrpJuNrJeA1rEHBmDK8Yvge7CUlOVgDAdzS1qYbbEvhIjpwCHE7VZA eKB/0mFyPhctuRFkjNQ/wxISYiXrk9DMsQKIXdc03ozv26J3Vprky8wGhGmBXoESYOgZ qVJmZMA7SzyxmG861J4fLhKibzWmfeK7j6eSu/5lb03HSpFB58SDISpHDIWnbRNskjvx sckw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K9gwfT3q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id h184-20020a6383c1000000b00578f6d31b78si2768638pge.73.2023.09.22.16.47.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 16:47:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=K9gwfT3q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 1F71683D25A0; Fri, 22 Sep 2023 10:30:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233169AbjIVR3i (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232946AbjIVR3Q (ORCPT ); Fri, 22 Sep 2023 13:29:16 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33D82197 for ; Fri, 22 Sep 2023 10:29:08 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-578aca5a6bbso1709796a12.1 for ; Fri, 22 Sep 2023 10:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403747; x=1696008547; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H8wcxdgkYAvkCOCoP6EB5xh89rywD8lhufIcjStIsos=; b=K9gwfT3q/qgboUPNthyJid9JOGy1mcVoGccSt914InaP28QcC/on0g3lNtGgwcry6p ErxmNSrbihsHEelKeNEqYEw+TX37ed7kY1MdLA3fqR4G7GXSkgJ/R4VyeQK2MOBWBF6z t9JxmsvJLC0m0ls0rpLgqGLhix9VJIURcN2aI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403747; x=1696008547; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H8wcxdgkYAvkCOCoP6EB5xh89rywD8lhufIcjStIsos=; b=UZXGhKoCvdy2t+7t6ERj8WeZuF0VqUrQ/17BhsbwLah4xJv9m5uskkaw8uEjuHEyi/ qegAxMCVmAG3Vi/oP/MmikYBFF4+fBMghYZJbsKK4NsTdg5UKa5+kXHROtV7PDbj8fK8 c/RAzfmyC1nmXP4rpKQLxt1OadQ6LEn7i/UHG0XfvyFuScj/xyrdNcitwnlOXFEX87J7 WDJZDwrSCoNCyos3iv3jvxIblkOGWiNwIPQuZtOHAkm1bWWkxn8RC6PxGP5I0ikAMT91 G7wKDwbuMwH4LA/bysmZnEWsxoR0wAPHDxxmovHVu3CEYw1A5C0mFF0HLOnoeIT/gMfN Z9bA== X-Gm-Message-State: AOJu0Yx3tc3GzRl78kEZa8Fri/x2N5v6k1u92YcjYSjLyrjMPkWqDF19 DDHZf7lirNqEKUCFNAGUOpuu9w== X-Received: by 2002:a17:90b:350a:b0:267:f094:afcf with SMTP id ls10-20020a17090b350a00b00267f094afcfmr382935pjb.12.1695403747365; Fri, 22 Sep 2023 10:29:07 -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 on16-20020a17090b1d1000b0026cecddfc58sm5168623pjb.42.2023.09.22.10.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:03 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Yisen Zhuang , Salil Mehta , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Jamal Hadi Salim , David Ahern , Martin KaFai Lau , "Gustavo A. R. Silva" , Alexei Starovoitov , 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, 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 06/14] net: hisilicon: Annotate struct rcb_common_cb with __counted_by Date: Fri, 22 Sep 2023 10:28:48 -0700 Message-Id: <20230922172858.3822653-6-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1460; i=keescook@chromium.org; h=from:subject; bh=1a7NieutkFX6AaDPkEeHOZVHEoHBt5bQcCIJutpCWUw=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7WrIx18IVUGp+00bkbeA7+GMMa1sOqiyBAN /AV74Ua6mWJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1gAKCRCJcvTf3G3A JtWVD/0YjudsxRE+Gn/6ufjGzrUTJPOLYENG3QXjmKKMjykihDhpS8roKUz2639IJQ3ofG2lpRk pXxt1nWBR3nqg+5tD17nHNX5VrKywlSBPf5mb3whcLu+0iyWDcCOXNHRNmjXVj4DsvbXClNK+s2 axrhXO/7+2urhIqPiZBSj8fZ+gMdMkGrkTBOpVOlpXCI+ALT+DTMX6XrGCT9blczSojxLyMi+fR 56bjaJ5DQmkfNVF9FbmQqkz1kvtSMt8EJZgAJQvO3Co2nhnYjG6aWv7Co4NraY1+y/uXZ5UM0Wf CS3m75U8q7P31UyY0cYZZBAOAGYs7vDBolcGl0mkgZpmulcb2JGvtrCQtJbSX67BqG6ABbzt0ua D+v6y10gAogt3nTCEqz+86wi6NATANnhftFkrO/hMg5JH1ULZskFkOHKabuV8Q0h2ZtE5tIcnuJ MmFspm4sTsM9Wt/0MPN1VfS0UYoTpeMjQEpZYVztnxaTa4vFLrLf3YCRTllV0iflQJtbLe671v0 SepA6Jp/5ELNjbuHEwQ3U04XAtLLSsXxaHj9U/t0HrxsKL7gOXQ0lPrqAVCgVPw9PRh/cNTIIky mCWwUUCQMoVQOj63jYvTKofBHWWpzbkDdCd6A6q0o3QG3sbwrilQzwD1k6NViARVdu8Js0Qo++i 4um6OXwKgBbqLEA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:30:01 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777781741477100683 X-GMAIL-MSGID: 1777783473131040481 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 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 for struct rcb_common_cb. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Yisen Zhuang Cc: Salil Mehta Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h index a9f805925699..c1e9b6997853 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h @@ -108,7 +108,7 @@ struct rcb_common_cb { u32 ring_num; u32 desc_num; /* desc num per queue*/ - struct ring_pair_cb ring_pair_cb[]; + struct ring_pair_cb ring_pair_cb[] __counted_by(ring_num); }; int hns_rcb_buf_size2type(u32 buf_size); From patchwork Fri Sep 22 17:28:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5792312vqi; Fri, 22 Sep 2023 11:39:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIWdf6hd9EWTbDcxpJRDcKSg2w6bKZshd5tIG4N8pwLTu8uvXNZVUp5I+Zawkxmq/0M79J X-Received: by 2002:a17:902:6bc5:b0:1c3:a4f2:7ca3 with SMTP id m5-20020a1709026bc500b001c3a4f27ca3mr263166plt.66.1695407997455; Fri, 22 Sep 2023 11:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695407997; cv=none; d=google.com; s=arc-20160816; b=ScLml//KJNIkc0pUMe8qXz5tzBIRQitXo+8oHFBii8CtFEnmnmEw3x8OKOA/ZeIzN9 /+g1MbTh1iywVoorLkTgKeUgK0/mcZVDRC+XBDqleRKy+IDDSSpEuZUjK94JSX57uc6h QorVGkF9xnzwSWY0oqKhRWU2zBini7Ne7h+c4vs3OfGm5paOwxNxhARfpCBSKJg148RJ slBqVMZSs+dYunL2s3GYqZCrYDOjakm26KSDLqmXIx4MsQ7Yto5ZWh80SnOtdNUX6n+o XM0RkSad0v/UjjMWgU25P3YtEgmaZhR0xSB5Er8HB9r1h9R2Tf1HSaziFgX6JnBs5hqW y+Ow== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=C+fG/1IUZcjxNvMlyP56fbg8HR7JVnjt3riwCi0wfhY=; fh=ICmRX/RCVFHSRQsamOjS/kXQLTcG0ujrgeLsQ1wiZEc=; b=Fm0ES1GP5W2vM52ONgmWuN8XkVpGdvx+uoEyxugltGTB1EdEBFAuGDWkxmft/YJo0q Vmd9VypCalinOUqG1h8xUT9wzY/IRIK17aTI4ZJLxt6DfeQC4OdcK/9v96zwtHNgFq0T wamTeiP2fDYiiY8EALkE79nSWtxl6FXCmEPj8ZsXIyui98PuolP5/dI35I7fhzOTd+gY b8+nUhuhgXomiof3DHjwx64ZX4vlOJ72sXDZi3s0agiNRtESuTZXaK7UhEiuhk7+gVk+ HfYX3a8jbQ+GSzeAP0POYk+wLEJzLwoZrvJd5c8v7crDeHSDfZ3M38/UYHCWysrcQNjI HO8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="J/+k5jsA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id f4-20020a170902684400b001bdc664cd5fsi4179283pln.168.2023.09.22.11.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 11:39:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="J/+k5jsA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id DEB4783CD96E; Fri, 22 Sep 2023 10:30:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232997AbjIVR3a (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232808AbjIVR3M (ORCPT ); Fri, 22 Sep 2023 13:29:12 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4971C198 for ; Fri, 22 Sep 2023 10:29:05 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-274b01849c4so1782558a91.3 for ; Fri, 22 Sep 2023 10:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403744; x=1696008544; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C+fG/1IUZcjxNvMlyP56fbg8HR7JVnjt3riwCi0wfhY=; b=J/+k5jsAmIx4bdTb3V8uyh1rGB+L9KfD5cv+cgSCFbnWoaDnNaiNgkFLhtM61PH467 aLZMY4X2BNfN9jeMDjnITDn1Ur9ZDSBXYVOPXb9N1kGtdW3L7q4GRNwhhzjsbrjXHdZe kkT4ggSAQoj3iVDQ+4siAXS/gLXbwnKzYJskc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403744; x=1696008544; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C+fG/1IUZcjxNvMlyP56fbg8HR7JVnjt3riwCi0wfhY=; b=bnMKtU5nM/60tWHzDXl+lq1oI1EZT9axnMOu5+s05P5dSdCo0vlTlvNGdgR2NXpeFY /KRj9dL/F24RpWq+2plcq4LvIHxuNxr5uTiQx04XZibjjVnPf5OODvqiAAZfKUDryMXo EkpQlzjDYbvbU7/sOcVo62Wc6YqAXlWk1Sk3f8o9OljMl8Q/CznqgUpzD/UPaAqQ/QeO cd/VAXechNOjQuL+SAJnmUwxxEJtlK+AraH5gZlD91w1b8WYiczppa/c2kFLAZRJ9AVW C5kxilaT37/paDZmC0xe2btSq6NIIBovLiHqj+08gDrvO3jW2PkH5dx7I4SqEo4lnFj4 U5Sw== X-Gm-Message-State: AOJu0YxF+S/alosFEVWniIOCYYfv4b05WwBevdVkWX4TjWWlW2W/e/D8 n7bU6X8dSi4TmA/aMMnDVmX63g== X-Received: by 2002:a17:90a:fb8c:b0:274:4fb:360a with SMTP id cp12-20020a17090afb8c00b0027404fb360amr385633pjb.16.1695403744652; Fri, 22 Sep 2023 10:29:04 -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 gq7-20020a17090b104700b0025bd4db25f0sm3544485pjb.53.2023.09.22.10.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:03 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Ajay Sharma , "David S. Miller" , Eric Dumazet , Paolo Abeni , linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, Jamal Hadi Salim , David Ahern , Martin KaFai Lau , "Gustavo A. R. Silva" , Alexei Starovoitov , Yisen Zhuang , Salil Mehta , Claudiu Manoil , Vladimir Oltean , Alex Elder , Pravin B Shelar , Shaokun Zhang , Cong Wang , Jiri Pirko , Nathan Chancellor , Nick Desaulniers , Tom Rix , Simon Horman , linux-kernel@vger.kernel.org, dev@openvswitch.org, linux-parisc@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH 07/14] net: mana: Annotate struct mana_rxq with __counted_by Date: Fri, 22 Sep 2023 10:28:49 -0700 Message-Id: <20230922172858.3822653-7-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1560; i=keescook@chromium.org; h=from:subject; bh=ZdDX1htO5g9RU0JVxl8E3nenoSp50ETWGlk5dSjb3Pk=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7XhV+304GTOyf/fNFFzA18xiqgiag6BHBkU r6QL6lj+iGJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A JttUD/4nw3GnIK/006QbQZGOylTpwCOUiis/9zO+cYuRhscdH8v/ABtugcRwPC6Cn46YyRhmelJ I2EjfW+CUaswbO+4XodbsNw1MP3/9Rh2Z9hxWJp/ixVY+9Gr/Xso37A3Kx7yx/j9g7cJ5G8FsHR BhADK3SY0PK+fm8vEQHbU47FLD+SDObsUZwCTiQppe3Qyj4rtHRPkpvlP8Xtnc3oktAK9NfjPO4 BYX4lmas+XoVTX/BFSYNV+dbtgn9PgTb5cIcrf+KYs1b21rtyLu7FAM/T0PHhS5lrEfGjiDqIXO 0HnCVEXXW+bGsbCUW5vcgJX0NOpM8VO45dmzonA+kMLxzbeOr31HUL+vx9F41U6UFLiosKhC35X QKeQKslSIwT9mFn9vcACY3wusuQlm2dm5Gb6CJ6xJhihRmK+yH+a6EZadQqvSoyBI1jX/P4o4cg sNTuPs+4n3fXOjGWHI1inrX2o79utjzSj6NnfBHfWaSsJwBy5DLPBUA7QEk5YnSa0PpkGZXbZov 542ytPJTcKvRQlZRIwvp7bbD6cF+jq/ZtXo/ut0guz7iB3rUVKztN8ninv86elhhA7yicM598rP JLBjpJsix6aeD9dFf7JzIxn3ZYFhogdNT5fm/Nauo9VfLHWZCflPIDWW1LOXoXjv/A12uH/gUeb k+LcfI33E0wxohQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:30:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777764135828609763 X-GMAIL-MSGID: 1777764135828609763 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 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 for struct mana_rxq. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Wei Liu Cc: Dexuan Cui Cc: Long Li Cc: Ajay Sharma Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: linux-hyperv@vger.kernel.org Cc: linux-rdma@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- include/net/mana/mana.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h index 9f70b4332238..38441be68592 100644 --- a/include/net/mana/mana.h +++ b/include/net/mana/mana.h @@ -338,7 +338,7 @@ struct mana_rxq { /* MUST BE THE LAST MEMBER: * Each receive buffer has an associated mana_recv_buf_oob. */ - struct mana_recv_buf_oob rx_oobs[]; + struct mana_recv_buf_oob rx_oobs[] __counted_by(num_rx_buf); }; struct mana_tx_qp { From patchwork Fri Sep 22 17:28:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5916780vqi; Fri, 22 Sep 2023 16:06:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGym6snLfFkaoH+fXuSqPzeBqnpRuB6x7SiWW3o/vkWRZ0vTMlDU/GwTU0b9gHBTgIbJYTk X-Received: by 2002:a05:6a20:ce94:b0:15d:f3ae:665b with SMTP id if20-20020a056a20ce9400b0015df3ae665bmr949313pzb.28.1695423983864; Fri, 22 Sep 2023 16:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695423983; cv=none; d=google.com; s=arc-20160816; b=cGtxH/shdXC+6GsxOMijQ7Tfg8f+eDGnZlNgmQ1eQ2Zc0y0eHtbyIjCRvvEi8GqF+q IVvdzic9vzk7Evdb2xrZfjX3Lj+4MFk5bU0oZhwvRc3oE0IYs8TxorkzDfyXS4WcEDen DZX0ZOmYsqPWXdt+cceydRIPH67pXaj0TIuf9miqwrLZkjmG26mj0hdYRYXDht9yIKct Ixx8r6GZFcfp+zTkPsBPCe+oklCqGvbShaBQ27asgSHUAPhq4WB45mbQD2zBnb6KF8xZ kvRg40NqlYwgfV4iT1EHgEkyuUv7kGXX5Na0fg8ixtFDzE60U00gHShUutsh60TsBfXI vpCw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZheShKBMXsJafSBhUem9NUmco8TlRbxuPgRJhrYLuF4=; fh=EVOjgj+CHRmdD4EtZw/Xkl4EwHIWgdzRh/7nqdeuwBQ=; b=X1f+aHFZnj8D7BJN7uN2HRLoNIxYE3lIN+weR5myiZpWO2ifJYv8LQcG2jYPdYDnOK x5buShT9jRYiM6FSk0yanM//nlWHtsDVrwZbY2PRFIkRNZyDgLR9KUrR/5CtqPty7C0d p8sZMXYht8NcC/k9wXM1F1O4fbonuX6Xsa/x2DKLER8Yem6Z7TdhpCVFt+PjnPIe9VTy S2aJcU8ZtJZDxcz0wyl/L6zjJ1SM7eQDYKWcOx3YSLp+XfDfwkQUjgEQffpyD0/aei+d UULNZdbHJ3nHLVaTpo9xOm92NHCk/VaoQ+CdJ5edT53wC3bPKNy4avKTyFoV6le8N7NT 5Q/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mu+50WzR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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. [23.128.96.37]) by mx.google.com with ESMTPS id n22-20020a63f816000000b0056f7592d732si4577373pgh.424.2023.09.22.16.06.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 16:06:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mu+50WzR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 0606081D2AF6; Fri, 22 Sep 2023 10:29:35 -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 S231589AbjIVR3f (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232893AbjIVR3N (ORCPT ); Fri, 22 Sep 2023 13:29:13 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42FD41A7 for ; Fri, 22 Sep 2023 10:29:06 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6910ea9cddbso2038610b3a.0 for ; Fri, 22 Sep 2023 10:29:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403745; x=1696008545; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZheShKBMXsJafSBhUem9NUmco8TlRbxuPgRJhrYLuF4=; b=mu+50WzRPb9bbl0T3bxpkUbT0QWHF28QLLRdjKAqoxTUvyL8dLakRT9mSMy8lklS0G SZCcmYbRKmIRKqXI/PoNdd33PDM4nBOXc2Uk66KQpQPVK/WcrYEb0rtxrEERka1HXJ9I xABIWUdNXMizKp5cTzCu6E7/2r1DaXyKNacTA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403745; x=1696008545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZheShKBMXsJafSBhUem9NUmco8TlRbxuPgRJhrYLuF4=; b=VRVCSsdImDbvbZp2k9Id8znzLV+2sDKYraz+xamXieplckFwI1b9KFzaTE2T7XcnvP xZ2x+wiDu8shthfhUm5qPCCQC4LcqcdC0gBzc4J67D9xvB1HmzAhLC+sZLabf41hKtSs cvwwwCyEl3m0Cq3bxqn1JCsEgbE0veiq51E1pdO/1s0VcDmp0J/AK8sz1XqPz068CEyc 7bws0OOwSIQn5uCTZ2a7M2ehAsTo9a5G4mWlyM9tHIHRAGeKjuJCs80gwor5Xznu+1I2 7boeKU94tCJZWGKTYf5wvq7RRax+nyi0pqgXTJC4UwXNTBJ4YJjUVzOIX55nFPXYtWC8 yJPQ== X-Gm-Message-State: AOJu0YzEncf36AGHsoEGDJKeCBIPhCbMfP0VXYi1bBX6/OeQdCe87o/k 91mlznIeGlsOx7X3c96HTbraHA== X-Received: by 2002:a05:6a20:3cac:b0:158:17e6:7a6 with SMTP id b44-20020a056a203cac00b0015817e607a6mr221373pzj.42.1695403745651; Fri, 22 Sep 2023 10:29:05 -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 b6-20020aa78706000000b0068e12e6954csm3458358pfo.36.2023.09.22.10.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:03 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Alex Elder , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Jamal Hadi Salim , David Ahern , 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 , Pravin B Shelar , Shaokun Zhang , Cong Wang , Jiri Pirko , Nathan Chancellor , Nick Desaulniers , Tom Rix , Simon Horman , linux-kernel@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 08/14] net: ipa: Annotate struct ipa_power with __counted_by Date: Fri, 22 Sep 2023 10:28:50 -0700 Message-Id: <20230922172858.3822653-8-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1399; i=keescook@chromium.org; h=from:subject; bh=ZVNa42RINhV0v/Ht3T7iUT3nE/j+aJWcJU1ourfEiHs=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7Xrsd3u3GIIaa0RoAqhrB+eBWXpaTGMEQ/u 44xb3Uo6V+JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A Ju/8D/sG14Nl2om0NTcT3T/FMCMrw5caewzWYYZZA5qGbOQyUerx5rGQueGAkyPPzVCA3z1X5Ei RAGkC4MQg8U6DuG+B6Y1GivTSRwcfrgH0NCU6rCO6TCwfwx3GMsNvAVp1J0YiNbBKcGq0C1Pwn3 tOg+us9yQCjqWWxhOxxt+uFv25NxnxjZjDDqxtYh6SYPQRwSw49hCykEDOott+K24NhX8NPAYaz jcD8tBJDS2QTRtd56RnyfIIeDq7ekRHm7ECmBw7eXdLbD1D1jzGncRJuupIgENxJO55A1F/abO2 rp7ZAzuNHsSIezVTtETCcKaGUBAx7qAE2T5yIZT+yed0mwppMzZm79vOzVq9N6hVgyw3lKWllRx 42WAgbPQ4Etr9HIBG3IkmYAyAvxu6db3KV9eDsWJ+49A2sbLor6jbJmppVskRGaBKsq1jm54hAK DtyjOKF2noGlhzLtQU3xpPVLiyizpXlHiGphYq+WC+nuXS7ILP2asn0W0c2Ip9uX1sml99XYNbj L9MR+41qLcYAX5yN6Jd+WAlhJO2SVaZHdWsr5FDN80BNIQO3kRKYVc4rzv4J4ZiBpukNZ7gqU2H tmh0agc3IN/G2PWAx2O6+YIDCIdoGDabLbVvGpLrI2tAQfg5cIYqgJoQMkstH5cn9Zy8t+JEv2d c8jebhrkUEu4ufQ== 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:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777780899152453804 X-GMAIL-MSGID: 1777780899152453804 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 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 for struct ipa_power. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Alex Elder Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Reviewed-by: Alex Elder --- drivers/net/ipa/ipa_power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c index 0eaa7a7f3343..e223886123ce 100644 --- a/drivers/net/ipa/ipa_power.c +++ b/drivers/net/ipa/ipa_power.c @@ -67,7 +67,7 @@ struct ipa_power { spinlock_t spinlock; /* used with STOPPED/STARTED power flags */ DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT); u32 interconnect_count; - struct icc_bulk_data interconnect[]; + struct icc_bulk_data interconnect[] __counted_by(interconnect_count); }; /* Initialize interconnects required for IPA operation */ From patchwork Fri Sep 22 17:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5823811vqi; Fri, 22 Sep 2023 12:39:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/Rb4LClGIPM6F7geL0AjHxP/5lKKxhtJjlek+lOdQDtqLxuhMhF1XcTGkxpz+7O8Et3SD X-Received: by 2002:a9d:6457:0:b0:6b9:e35e:8dd with SMTP id m23-20020a9d6457000000b006b9e35e08ddmr653903otl.2.1695411550106; Fri, 22 Sep 2023 12:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695411550; cv=none; d=google.com; s=arc-20160816; b=xZh7Lc3MyTK7YwxyB3hi1Knhay50S8nyEXvnGR+QhNXmxNCcC8lhuBf8mfXR0gpl6i 45dtunDn5403711iyI3lrv0lNlMcYT7lm4MY7K7SdVau4ms9lUnjiHb8Sb1fpB0i+vbD mIjRDvIz7aIr4h2pttsLXYhhq+mVjdjqY7UXRUu8JY9ZQK/08F38Pf5PzYFeSmJZel3e xp9xriz+boeiruIk74nzmZS++oxZElVXWJekXlkJXRvrNwCDGEnb5mu+qKbemo3azHyb HKv5dnRVNTANCBKUew9Jd4mGWnjf6Bnc0rizNcsHRI8PTmoOt9mm43eN0bcpSKn3MeR4 wHvw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cr7VMeXLJH8XwB+zD35GqBQrsMI4YcQcUPdvZ9TWxzo=; fh=NyVbK1FHDxjMHl2Fn+k0Xq0/TI89glhDD15IcUhy8Pc=; b=SWH3tgTliEVNaJyLN/jBkD1f1wgq2ZR5ma/EnI+hJbNIV736BUeZqFuRYRzy+qMX22 exYgc+5h91pGUHZE8Ei0ZwYcaxSkM7CO/hatj0CO6u6ZqjUebuv2HdxZapS4X68TN5hm BNvfx0eclzakITkWJE0lbiKiVUoV0JB6lQMx8kZs8q3Lx7WZuErXbKEWHJsZhKsfnAPC 0rDAX2uhgGxsbFI7VvC/9uTEcrXGcAafW1svlL7aG8to2ACr3SXmL19TzYv4F68Hqkaj Cw08/7WEZ31c2WXw2gjuapVvhGe4Fa8mmF2vfNS1JFAjOcvGitawCPt5DQ+33j+pY73z oJOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ETuYqYjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id m1-20020a656a01000000b0055379a7131csi4674398pgu.721.2023.09.22.12.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 12:39:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ETuYqYjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 7E299860AD25; Fri, 22 Sep 2023 10:29:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233084AbjIVR3r (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233025AbjIVR3R (ORCPT ); Fri, 22 Sep 2023 13:29:17 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC99E1BE for ; Fri, 22 Sep 2023 10:29:07 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-690bf8fdd1aso2212609b3a.2 for ; Fri, 22 Sep 2023 10:29:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403747; x=1696008547; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cr7VMeXLJH8XwB+zD35GqBQrsMI4YcQcUPdvZ9TWxzo=; b=ETuYqYjpeAxjrAEL1zRFWt/PP3eZI9SgqafdsGPe0j/d0XtACtcZDgyPnDXrcT9zpg SRLDJsQMgIu0JAf9ZzHaEFFQcg3D365AXbC8M+qMbbwRlzYFNz7JaxM09Eqa6sXf848/ PKgIcPnFEOyPaZzEsqh5JXlQ5MB3W96RKtJm0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403747; x=1696008547; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cr7VMeXLJH8XwB+zD35GqBQrsMI4YcQcUPdvZ9TWxzo=; b=GBs3K2NtAbFnvWDIrKJDk/+DPIf8j/ox4xi8rZtlR4tD+jkuy84tLUCaOLiemse3Nt VlEU/TzM0/6lsaBbyF1SQknKGBUd355Dw5eG2/iOqrvctZ95KK/LJl3+TYz4C7rjlLh0 wFKHQjfiS1YG3y75G9K7ETS5hqM5+OM/bhlz5h4gwDbyoOryOs+psFSQVnZCMAOm1nrn 5cbB5poMkDHs7EMep1cdbWDNs/boRRNOr8GmXC/NqyTKUeIDYP75L/tqHGsXfpNbjyfM 5ZD1/SttT65O6jdGKRYtw/gRBD27M7N1MGIHwPv1Tat8Zjzr3eUHttSRIyX2jmJXJDGm 8XLw== X-Gm-Message-State: AOJu0Yw7ap/Y/s+terw+eJ8Y6v6GKzdct11Ms0CwcTPFfRvdMY2YePmS 3FI7+Z4BlF4PoXghVRACY70xCQ== X-Received: by 2002:a05:6a20:1049:b0:155:1a5a:9e31 with SMTP id gt9-20020a056a20104900b001551a5a9e31mr230381pzc.16.1695403747014; Fri, 22 Sep 2023 10:29:07 -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 j5-20020aa78d05000000b0068fe7e07190sm3461673pfe.3.2023.09.22.10.29.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:03 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Long Li , Ajay Sharma , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , "David S. Miller" , Eric Dumazet , Paolo Abeni , linux-rdma@vger.kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, Jamal Hadi Salim , David Ahern , Martin KaFai Lau , "Gustavo A. R. Silva" , Alexei Starovoitov , Yisen Zhuang , Salil Mehta , Claudiu Manoil , Vladimir Oltean , Alex Elder , Pravin B Shelar , Shaokun Zhang , Cong Wang , Jiri Pirko , Nathan Chancellor , Nick Desaulniers , Tom Rix , Simon Horman , linux-kernel@vger.kernel.org, dev@openvswitch.org, linux-parisc@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH 09/14] net: mana: Annotate struct hwc_dma_buf with __counted_by Date: Fri, 22 Sep 2023 10:28:51 -0700 Message-Id: <20230922172858.3822653-9-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1566; i=keescook@chromium.org; h=from:subject; bh=jNN2Wh5TqbkzFZoQFHMYTzfDn0UF7zrm9adldOZuxp8=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7XoLVZdYuePM97S+7MA9i5iH3sxyTfQSS08 LJB65B+ZZSJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A JrxWEACNSgzg8Ycl9Qe1Mp2gIHHXFmJMIrT0z4cUhu6hZZXHD244HpZ8X+SYVMS9HS5syB/r5ZI 2kNn5pZePHECZBA8CM4/TjgpQPlFRdgxHFFqBbfsYgAQnBkEMCTkFfCaKwzzmXVjLJfnpfOortM FaMeXJbItFRrX0Jwcv9cj9UC0k0zGIxwDvhCTpWO0IfrCOoDrV1VzDNtTUJ+XVL78kI1f2l75Ay 34ksMU9kJrH5ASYCmmlwAZNT7ObZi26q0SKJgrSLWhqtq9swbQKnxy3Ask714ZdqhUI+l79qL6z eVDkoz7xmTG/GwFi1Gm0f3aQ4nmQiaJS/EKoN/Moy4R9Pj4PcoP9A6a9JAnbXFsCyfcURk+Xeiu 7d8SiKimBQYQu1t6iC0rdtnDx9AUg+PH6cO3/7ARrrFcYoi21yLy5erMFvLZ/GdTEGrwiQFoiQ+ gGAv4IONo4YXXQlC/z8es5uxwPk+UXJ+bvwe+PL8WnXGdKs8QMRXslYTUSIaEP+9YNvPuIawQRM erGitteR+N7KlsLaWaaq/z9LavLhnOua7sOCJQ7cDMa/pNWZDzckInyzoUg8Skf4gmjH2fNF9O7 3+n1k69unddP2rtknBF6q49u18qdd9qXinwaYwqeXq9tyopeLUrF/KsAn9ZP752xrkkWBf6pYiW ZuZJGJuFzQpQdlQ== 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 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:29:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777767861326517582 X-GMAIL-MSGID: 1777767861326517582 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 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 for struct hwc_dma_buf. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Long Li Cc: Ajay Sharma Cc: "K. Y. Srinivasan" Cc: Haiyang Zhang Cc: Wei Liu Cc: Dexuan Cui Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: linux-rdma@vger.kernel.org Cc: linux-hyperv@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- include/net/mana/hw_channel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/mana/hw_channel.h b/include/net/mana/hw_channel.h index 3d3b5c881bc1..158b125692c2 100644 --- a/include/net/mana/hw_channel.h +++ b/include/net/mana/hw_channel.h @@ -121,7 +121,7 @@ struct hwc_dma_buf { u32 gpa_mkey; u32 num_reqs; - struct hwc_work_request reqs[]; + struct hwc_work_request reqs[] __counted_by(num_reqs); }; typedef void hwc_rx_event_handler_t(void *ctx, u32 gdma_rxq_id, From patchwork Fri Sep 22 17:28:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143583 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5791229vqi; Fri, 22 Sep 2023 11:37:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiaAbz1gjoZen/NYEuRrE51fCpiE9730qqXJT8zmdKFQhpbRqqlr7l5Pieh479j3V1Dtio X-Received: by 2002:a17:902:e887:b0:1c5:59dc:6e93 with SMTP id w7-20020a170902e88700b001c559dc6e93mr670064plg.3.1695407866696; Fri, 22 Sep 2023 11:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695407866; cv=none; d=google.com; s=arc-20160816; b=hJ9FRVEYuruJzFlvlTeBMfJNNlI98/WQ/KqmKpXUHFwd1JHD030V9t//pbILilxn8K IBxUrpnshMUuzI3lOqFL5vgsfM7tTcQOHfpRKOI87sebQjsRaUsckSD80gIGaqaI23M8 BHH4N1/1oQcomQyqVYC9g2QRpN6fXtasmjms7KCQAWMu6Ft6Jj3Lu+w3mBn2cIwZv67l LxOUtJ8j45ieUxHy97Z3IwHdckEiFyn1eaDU0Opl+No3PI+pPKT1PMvaL50nQ6gldKYo tRcaO12L0AMXVQoM90+wQ0pZ8lIhi7idRVEXo9DGR+L+LWoHZt/IX7nDmqZLGcOLYG78 z7RA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FUKfzJFWh6q0Ek+m1dIo2wKPPT8An6wcKPyi6NfdY3U=; fh=FxvdypqymM+gM1J8n8VHYkXTj1sj72973FDmPWVFP+4=; b=KeZ0x76rHTSf1W8QOvGlAVWzcv1V3iF6vjWKorhpOMTR2ov0hZMiWDQTkZ4xzEBjn/ YeruVXBXCP1vnboL4KqbKSjhy03ALxL1sQMlgoCIXMdlDU6ZNBSDPPGSF/qVSOrvT4RI nmLGJInW4YqJJEb+TCbFr+XW28lup8IyXIORJ0ljNMfAOr+64WyEVCxYhU+kITv/0OYt 5/NsWzwgROTQrDP7Xc2DHBw5Xv6aBryBrvAgLvktl5LZMzKVj3TG1QGfFO+0qmbuxTLx CZMwNzBDr+PKZ8ATFIjBQ1h2AT6THmeVrvkMPVv61C6GCgttYpJ6b1opsJVKufXdLIKS gFiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="F6KsGT/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id ij30-20020a170902ab5e00b001b3c7e6a8c0si4127319plb.531.2023.09.22.11.37.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 11:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="F6KsGT/H"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 39C63809FA67; Fri, 22 Sep 2023 10:30:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233185AbjIVR3k (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232948AbjIVR3Q (ORCPT ); Fri, 22 Sep 2023 13:29:16 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01A38CD8 for ; Fri, 22 Sep 2023 10:29:08 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c5db4925f9so17392305ad.1 for ; Fri, 22 Sep 2023 10:29:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403748; x=1696008548; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FUKfzJFWh6q0Ek+m1dIo2wKPPT8An6wcKPyi6NfdY3U=; b=F6KsGT/HRj8jgKrpamLsL/JJCdHQJ9PFMm4dMQKPJrZ5EAXXmUuzXDK2gcfX4pBAM6 r30AqeC0Qs9awrlE/XrmMbt272Z8nfd10dbNVmACToKhxicSMGeM7xxX26D694/C044E RjvqiBso+J0c/GsXJHGmEzGuwpvqET1cvb8Ao= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403748; x=1696008548; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FUKfzJFWh6q0Ek+m1dIo2wKPPT8An6wcKPyi6NfdY3U=; b=eLkwiaPUy+c1EyH1gJZUOLAGTpXBJVkoDsSYAyQX+WPqoKewT8drScyamswbkpxmGs 7Lfrl6rxBL0zJqveBFU89pQ/nJA9O0Ax2JOhAwQM7J8HcKdZ8Zn4lrF5pTwOdh/eVMjr 8yFW78vFU6CdZ+u0Tb5dumTGkNbpAkogGHsC+lvTSt+cerpdOvLpWesDge3SYTEtd8M4 NnU4s5A0AB6Ky2kySjthJWtsKW0LEkYuP7IE+RvxfHnfJPStQwVFaCeHg9Xmwjln8/sn LaxXrZA0ryt7BKdKTC4I5w1QpZUPgaUPz3dERJI59mQ4hUAHumP+iWgNSN0sibj4E5yE cN0g== X-Gm-Message-State: AOJu0Yy0tQlJUjFnjGfIWGqm9jX+t+awjB840rhjaJvpQ62CQGlR++s9 ljSjxT5seBFs6c8OA6AlqGTxKg== X-Received: by 2002:a17:902:d2cc:b0:1b8:8682:62fb with SMTP id n12-20020a170902d2cc00b001b8868262fbmr4313476plc.4.1695403748467; Fri, 22 Sep 2023 10:29:08 -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 s10-20020a170902ea0a00b001c5ddd7279csm2886559plg.102.2023.09.22.10.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:03 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Pravin B Shelar , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, dev@openvswitch.org, Jamal Hadi Salim , David Ahern , 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 , Shaokun Zhang , Cong Wang , Jiri Pirko , Nathan Chancellor , Nick Desaulniers , Tom Rix , Simon Horman , linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, linux-parisc@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH 10/14] net: openvswitch: Annotate struct dp_meter_instance with __counted_by Date: Fri, 22 Sep 2023 10:28:52 -0700 Message-Id: <20230922172858.3822653-10-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1296; i=keescook@chromium.org; h=from:subject; bh=yVCt/dKz5BWMUw1ro5PJjnSBgByAWbtJBqaTXA0zDOM=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7X+PfBo/CFrx9CIslwRNLq1g/T6iItdTZ0m uEPDF7T57qJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A JllhD/4/Z02Qh5E1AsWcUQYDgQrJV6EJStKbe3xKeX36WGu7kXLK3ZJpKuVtrBGmuaqCoRuQH0Y LIDC+A9fXchOa0+EkyNUrqD3waosen08sYK8DAq7cJKQzorMGHPrYlgpzu0GyVOlgpPrkCkWL25 ZyGk2egRIlyhXnaIb9K1978aJd4/LRJvbp2eLEs9xM6SR/NhLDTWD5jJuaULAbbDTiZQtQZqlKd oMtqMKn3383ruJsFnfdUK6VHz2jwI0d3rX+mqjkfAYYiIXS/pBIA0HndsmNB+moDTpUU/kv9xSr 7wt89fwD6XfKHZwQrgW7+R473TTXac+28WJVt5R4u+4/JefIjhkKO8bFjpZcn5HQkYA2FqPvgh3 OnDSqlYgciPAAOYwv/ykxV2mLrT3Kt/1+2yDR5LN0Zo8mPZZwf86knd1fjfedMPIzIg3obs5qbs WgVULRJhQzpFo95wfMxZPVrCcC1Zz573EBChjwmvWVfkemiY4pfTusbJe2538Ss+WPKUET1u/WX wX+COzhQrmQWby0lKx/Lv8/sfv2es2q4rH13ArqpkAdZzq2EE9DtWh2IFSr6C4MhFofvJTfXkrY Y1xMbqGyeFlydg5fHBFEmudern74i1KV4fukhn1fxCHiV49w+Sa2xr5JjnAoCiyw7PzomqYdi+i LVA2tNrfMOr6QdQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:30:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777763999160340414 X-GMAIL-MSGID: 1777763999160340414 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 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 for struct dp_meter_instance. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Pravin B Shelar Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Cc: dev@openvswitch.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- net/openvswitch/meter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/openvswitch/meter.h b/net/openvswitch/meter.h index 0c33889a8515..013de694221f 100644 --- a/net/openvswitch/meter.h +++ b/net/openvswitch/meter.h @@ -45,7 +45,7 @@ struct dp_meter { struct dp_meter_instance { struct rcu_head rcu; u32 n_meters; - struct dp_meter __rcu *dp_meters[]; + struct dp_meter __rcu *dp_meters[] __counted_by(n_meters); }; struct dp_meter_table { From patchwork Fri Sep 22 17:28:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:910f:0:b0:403:3b70:6f57 with SMTP id r15csp35146vqg; Fri, 22 Sep 2023 19:06:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7wt511Kja1tcqWze5mrz6KgNEFSZdqFjvgQZa/DkpYZShRXPWuvXbuxkL3bV3zNzM5sA5 X-Received: by 2002:a17:903:443:b0:1c3:19d6:3559 with SMTP id iw3-20020a170903044300b001c319d63559mr1529462plb.1.1695434760790; Fri, 22 Sep 2023 19:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695434760; cv=none; d=google.com; s=arc-20160816; b=nPNCySHmtUHpoZFNpH60s8UAn66ya5BymVrvbMNvA1yS4vi+sjCqnpxM7jaIPTlXMT zqqHJ8C71t4y9Vdoccgugf6wlahr/efKsIT3eRzHjBL/eJYhdTFXBBHtn9jrS2HPmqhb fIekRK3sE33nQnOUiYlcSLZiE6qp3uxViHAU+2dyFJB7kojHgldZTIGxeaCNXMm6DuTj LOkI3rS9VMghT8UQuYmN546Q9GXz+83QGwiaDA1Yv87la9cjhwSJEhv1jNGcv9ZD0jP6 aeToxoh2Ese4AlioOL4hh2xmlyy8DPpi9xQkDJVMlB/j9BEDsEyzYfFTFVStompeE4Bm 7Vvg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aHy2jcM546mf5Nw3NjJJcdsZQ6G2F/rbr9BMeebO220=; fh=udbq/ASM5GPloArVnDry5+1gGOZpGHNygw7ly8CtxKA=; b=PpUb+b3+YJccrhgDfqOLuN3Qd+chkEXXl1/oEbJFSSnYlKEqr/JDdDNaCbJfw7YMW6 rhvOnXZsE6cdN2HpiVbKpAb0YuM5nUOuoS+2MPyD/VfInhxvn8jQliEmmRMW4LFYCNJg Mn7qDp3vxxfI4D/o6uyYJoKbAUs32jyrjoZOft3vFboHTh7XQbCdQne3ppW1cbT5rP8Q XQBEDx1zEV6EWG0opPRj7CA3+Bvox/dI2/JLi1cDNdws79LaPa2roxqlC7CJwHfTDx3D fJTkv2U2MI4scPcWSevAPhrtJOjxsOVgQrdWrOnhNz7rbndD6uDvrgouQB5wgXqHUreP eyuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=O5SzPZzR; 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 n13-20020a170902d2cd00b001bc553d16e0si5183398plc.507.2023.09.22.19.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 19:06:00 -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=O5SzPZzR; 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 B6CB180A73E8; Fri, 22 Sep 2023 10:37:21 -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 S231214AbjIVRhX (ORCPT + 28 others); Fri, 22 Sep 2023 13:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjIVRhV (ORCPT ); Fri, 22 Sep 2023 13:37:21 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32432197 for ; Fri, 22 Sep 2023 10:37:15 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c44a25bd0bso28586155ad.0 for ; Fri, 22 Sep 2023 10:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695404234; x=1696009034; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aHy2jcM546mf5Nw3NjJJcdsZQ6G2F/rbr9BMeebO220=; b=O5SzPZzR+6krEZXkmLIZZTVGxbfzwGuhhb08vBfcktRzZgV0OhjSFUeS0eNJO58Za8 5N2zT2pbwLPH6hOkI/uctlcBJBVMrN7HhBgSjMZpbt2EyzJWaVA97YWO/q//rd7zJGMe SwlHcfYj/6zlOKAkCMq3llOQu8AA/HYzpgc2E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695404234; x=1696009034; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aHy2jcM546mf5Nw3NjJJcdsZQ6G2F/rbr9BMeebO220=; b=nlyshh2+uIHBUJA2p7FUHUoEXbpUsiz++vVysKVN7R0lXELJoDYYrCJy2uqo87AtOt WY95Vl7pfaAlXbfO6LlvFtUklaFVeG/EJKAoBKvJJSy5UESQgDQWQ2C6bjaAipgknDt/ ccBbLF5sdqUCBSTnyAlw3oy8V+RJAG+bN3Cdknr7TG6Zq3aZeTuNjeRjuFGVO+TMn3L1 5/ZStAtkvg24h35+1x4ujw6NX+1ZMgOiyGCFTvIVTI7qMb3WyL/sGhwtZ2HZFZatcBym h+o0uSI9ce5OcKDgeb5qzgDUA18b8Zw9CSITfUZ0S+99/tnTXBzdH3/GnIdpVPlW9FDO pTcg== X-Gm-Message-State: AOJu0YzwwvR88oeSHHN5PQRL/E9q2m3fO4dbxQO7oiQ+CyAIloZcAlAb /+z+O5LqjzJkHPkK8AViU6sJNg== X-Received: by 2002:a17:902:dac1:b0:1c3:e4b8:701f with SMTP id q1-20020a170902dac100b001c3e4b8701fmr479521plx.19.1695404234658; Fri, 22 Sep 2023 10:37:14 -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 g7-20020a1709029f8700b001b694140d96sm3771126plq.170.2023.09.22.10.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:37:14 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Claudiu Manoil , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, Jamal Hadi Salim , David Ahern , Martin KaFai Lau , "Gustavo A. R. Silva" , Alexei Starovoitov , Yisen Zhuang , Salil Mehta , "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, 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 11/14] net: enetc: Annotate struct enetc_psfp_gate with __counted_by Date: Fri, 22 Sep 2023 10:28:53 -0700 Message-Id: <20230922172858.3822653-11-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1477; i=keescook@chromium.org; h=from:subject; bh=UT1ZdosG6thsQKbZuWlvvKtNoMV5v4P0vRQDHVv6AlQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7XSQgN5HFuzDmTQh0kuKGN8VvhxLvLNcFeh bt51QZ4mKKJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A JqYjD/9GzxaHc4IrVjUkBj5/d8FeY4MZoAp8KPJKCM4E/stoQ89RWnkxPvXs2ub51LtTAM7Q8Nq 952ZRLOpGoccIMFSjcVlpFYlDEZRIMMkg06PGDQs8BLBgRp2Xbo/GI6r0attHGC5ruXY6R1djKy TJbXDQFFgVuUfCE3ZiMZG1SgrWkLCsxTlZFBeXY5+pEEWOp6EaAQULbpmh8/N9D4gZE1/vQgF0E 0nrtThbucWqOv2lWVWoESP8KBQ2hbiP04yjKp5QhnvG9ai5TJ7czKEGFFzfw+6WlMuj3ohAC+V8 eRoArmKj5/q8DXUTMOGzNsFBobqrSbgfMk+Fu+dvyK+gxTw1urL7a54Rms23bLytd1W3qsH4TdV MjqSkdW0hShdhKqJxvRMw9H0OSSv2T/191tK8eFarSmolgQCBqQkjQN3HORH8VsB7NK8Rls+AZZ ZNO99qTOvddCRUmOlsJli6YplJtOWudvU5OVaGivwWMqWzCqGnASdsSFHSQlyO0vGgy05UCTaTk OlgQNwhDSjtZX7ZovqyZY56wRJXHkVTd8P76Qi0s1d5yI9hxyzGrFnUmCrlF0P8oGHQIJh9h+HQ 9WKEJyCgyiKmb4+eBOVQnfxP063FQtmEVJl/nVl8B4+NKlYVWjZ0PUztJwDm4Ir6xg+DibLIp2O wM3jkIQFKhrIJvA== 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=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 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:37:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777791293916563347 X-GMAIL-MSGID: 1777792199938818665 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 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 for struct enetc_psfp_gate. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Claudiu Manoil Cc: Vladimir Oltean Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- drivers/net/ethernet/freescale/enetc/enetc_qos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index 2513b44056c1..b65da49dd926 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -443,7 +443,7 @@ struct enetc_psfp_gate { u32 num_entries; refcount_t refcount; struct hlist_node node; - struct action_gate_entry entries[]; + struct action_gate_entry entries[] __counted_by(num_entries); }; /* Only enable the green color frame now From patchwork Fri Sep 22 17:28:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5898399vqi; Fri, 22 Sep 2023 15:20:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsZx/BNyBoPdUI+LJmBboPpM+MEfi1F0057J4LEiLIcgaetnS0ru71hK6e5tZHaslNaRf/ X-Received: by 2002:a05:6a20:9152:b0:15e:2d9f:cae0 with SMTP id x18-20020a056a20915200b0015e2d9fcae0mr254570pzc.10.1695421236776; Fri, 22 Sep 2023 15:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695421236; cv=none; d=google.com; s=arc-20160816; b=IOfsHmYH6aYy6tztYssldBxZOthpZR6PKpOh9jM1k4ehZFg30ZbvmmhFj16bf4EaRD ak/JM9XuYVxMDbnw3fo0p0Olw7K4D7XxaIEzYWJVG+nGakdeBoBO6yp3iUAsxgDKgNm5 6AGgOKlek0Db5X+NkPk3rccT06WwUEiovDB6CcnCmjx1TmqcbL4Wsmx201IhgFd5pnpc xwTJGH9i9rT69NdsWyhrUIahqmwh5lNglJnevLOB5aI/3C94rPjIqggQ0FHoOo9chal+ gUujONES9cfVRMLTnC2iz1gT8SML3amjV/Pabhm+RxlP1dqIk4p/9fT59keTQrwi7Rsn XCxw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IMdpD2QebNkOsgnE+B1fw20Xf2QOBM+P6FhfFtclzIg=; fh=FxvdypqymM+gM1J8n8VHYkXTj1sj72973FDmPWVFP+4=; b=kGJHiDOKvkywxSDdJ/GaqOO5An+ldWQbQzLe6vqUVNJD/Ec/TpxrTUVsUkBMj3HQW7 y3c49g4mzkHzJRLfNOP8dOzr1WaVOrNyNjBVQRjb0fEnkd3u6nonbNSUqgLPAUDnb4eq KMxY9zt5BZDwBVIxPsKEE/6sDlflq9IYsPLK6+QDTjzPzSj96Qet/aj3VNUfF9Adp9lM FrebGthbn+fkPfo9nb2IYf2tEzn6f9O+1lg0iFI7FbGvFwHRLn7p+b/5PRe1Udgn8Dd7 4AN/InxbrgTPVEuEAwMun3MDXtFZJYxHoYdcAyGtfisKrYyv36eCt9TxoLUqaUJQDc+u 9f0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="BB/I1Q48"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id j4-20020a17090a2a8400b0027681e3a57fsi7023380pjd.162.2023.09.22.15.20.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 15:20:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="BB/I1Q48"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 7BF0D829D269; Fri, 22 Sep 2023 10:30:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231191AbjIVR3d (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232815AbjIVR3M (ORCPT ); Fri, 22 Sep 2023 13:29:12 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A2B5CC2 for ; Fri, 22 Sep 2023 10:29:05 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-690f9c787baso2126335b3a.1 for ; Fri, 22 Sep 2023 10:29:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403744; x=1696008544; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IMdpD2QebNkOsgnE+B1fw20Xf2QOBM+P6FhfFtclzIg=; b=BB/I1Q483yevgKb8WaZQteCVUrqAF5hbtfEQvNG3tzr88AvV1Y9i0Lwv1fnsn7tWHT /FsF83Xy9hAAZxfHWyLdkx3GS8GLXkD3BvfHaZBlrPmEXdg4tAWdo9Y664sH/deKzSox lhJRawa1np+IXCRxUSlYPuapCOdz8lDqtBHHQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403744; x=1696008544; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IMdpD2QebNkOsgnE+B1fw20Xf2QOBM+P6FhfFtclzIg=; b=fKQqDzl6v+BoFXHUZHl9pqn9LONpC9VVZnjaQu5WzvEvX+f4GsbqbrvBHcAO+jugpo dMii/cUEUM7jxuOJKk64lg1hs5hPzY/zkEr4mHafrvy20CdKZ/TkA630gwCTWD+PTSKV omBkk/kkw42gLSsJX99+kgPAjXOloprwOpI5Cso+cHkKYShL+DuxfRMukX3LJphal4eI zCzHt+TQYwgRNONxx8BWjaqXUwLuthfMVlYgetf6+jOSYneEOewt5R7VLk/aUrr+P3CC tzaWp1QiWbduYGtu9YdNt7p94Gzdt41ejqHzfB9Q5FcszFDwG/VzqffiLZgIbA+9PUDb 905Q== X-Gm-Message-State: AOJu0YzHRnR3qBPkF1cOF0L+sL0OpSv1p1iFL2OKIRK7OOBZDaBaMeV9 A886Ea18bG44UPBptag5RtSzew== X-Received: by 2002:a05:6a00:1a0e:b0:692:822a:2250 with SMTP id g14-20020a056a001a0e00b00692822a2250mr28989pfv.17.1695403744255; Fri, 22 Sep 2023 10:29:04 -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 x17-20020aa793b1000000b0068fb43a72c3sm3467049pff.20.2023.09.22.10.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:03 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Pravin B Shelar , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, dev@openvswitch.org, Jamal Hadi Salim , David Ahern , 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 , Shaokun Zhang , Cong Wang , Jiri Pirko , Nathan Chancellor , Nick Desaulniers , Tom Rix , Simon Horman , linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, linux-parisc@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH 12/14] net: openvswitch: Annotate struct dp_meter with __counted_by Date: Fri, 22 Sep 2023 10:28:54 -0700 Message-Id: <20230922172858.3822653-12-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1272; i=keescook@chromium.org; h=from:subject; bh=BiU4XzbiAmb0MDODFTqS+z9raCbhz1/gL/I9iNWiJeo=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7XW5+OhlRV9ltztIVdWSZfQphqd+6c9qMdL 7vc0r03kUuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A Jo45EACgakJgI+sZnaQ9PKs7A9coyV/LfTrR7Tn0iFc54pO3XUL1r/z9PwrqOMnwgg56WgY+x/A 6wFtA4SvikdsEw+xxq96vPUVGo15juErm8BPenaa6w7xcVox6lBW3DHkk6dKBlnngG/e/l5dzFX b9M05s5ZS1B4lBNxV3ahit+iBwnkpz5YJ8yqXyzRSXafim1Yze4lLaYBb814XrbLfGFD8vKvK5B zJtL0DY0TP92fqKFSbxZUhgUj4gnHDyn42YLSh6fpDiX102rTfPlTwL9GdrVCY/S8v6iMch83ev h3fqxds51Iz0pQoMO1yA7cjhwvntVVp8f+0u9ZpNiGv9ABUD53tLaooQiqGxCsUieaH8pKCX3Pe ZvbmdRRr64tiiwGpP7qpIJhpd0x0o3tBG+KW/6VpsGTUi8WO0e2/naRltFUeYszXsrfaox0Lmx/ 0g+KLMPDqCrPljPQX1rq/q0g0O3YvtBRFf6n0Vj1BGXjiPFDnDZTMBbmROt6gmu02tH3QmI10KT SKkI5QfmIvHyeZlB1c5uxIXSgrcW6W2LX/N+L8zKFpsuAfpqLQzRv7eL2TrstY6mOzOLjCekBP9 wTZVKBfYr3rKfwrThTcEzg4kju0sWqQXCmWR2DFa0SBDvCWjr5+FL24z85HcEv9ne8TmjWy3eXc LALPKshX4VtbROA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:30:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777778019184204549 X-GMAIL-MSGID: 1777778019184204549 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 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 for struct dp_meter. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Pravin B Shelar Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Cc: dev@openvswitch.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- net/openvswitch/meter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/openvswitch/meter.h b/net/openvswitch/meter.h index 013de694221f..ed11cd12b512 100644 --- a/net/openvswitch/meter.h +++ b/net/openvswitch/meter.h @@ -39,7 +39,7 @@ struct dp_meter { u32 max_delta_t; u64 used; struct ovs_flow_stats stats; - struct dp_meter_band bands[]; + struct dp_meter_band bands[] __counted_by(n_bands); }; struct dp_meter_instance { From patchwork Fri Sep 22 17:28:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5852555vqi; Fri, 22 Sep 2023 13:37:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/wPPMSNX7v4yF6eW40t1traiIXtwEQkqhdD/9p5fG0MLFRvc8e839WEz58CwbO8TfP3fj X-Received: by 2002:a05:6808:18a1:b0:3a7:83a7:ae71 with SMTP id bi33-20020a05680818a100b003a783a7ae71mr1025821oib.54.1695415052560; Fri, 22 Sep 2023 13:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695415052; cv=none; d=google.com; s=arc-20160816; b=l+61E5DdAfIIA3dsqAkS/2AQ80rSfJ/7p5iGoRlTPfIb5Lz87Ll6f15Opam35DOiUp eDwimcM6To60i5RntJMOinx1VydliBbJUhnEVEADAzDyEBrYshi9Fd5v69XuHDzU75oG j146+ujrdNGoCYCEUCzcOYupWZjfZY5Xp+71VobC6stWKCBStRM1vo6nZvqKU7J93v3Y MxhXxKdf16tdrRqFPAKnzCNzACxhz4fHKlceJHtH+v7bU/wXlux5iB3Y8BWG4ASv/9sA xQfnfJEPhBiCMhazF8RQ7O1Utp85JZ4Y0ezJmhHhBJpZfWMXZ9QN+k9/0Ye1Z1b82iOE 5JkA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gSa6oULDCwttnYj/UXkUGWzp9s7+1yQ+R9ugGfGb1B4=; fh=+gjaOjUtCM2frIORyjUO4we5AR3ByLkf2z3mugthF4Q=; b=UMRbEvkATXksfEnT5EBYyoy4vChbIZc57utMA0wnGHCXUQo6uSFp1uST8Mwe0bpIKt z/W+KsTyUxdQgYa1Pxu4y+7UqdjSuanBCHNIgk6Ro/GY7ShkrCFRG24hq5GEAbBeZBLO ezdVeoLeNb6vOFizjeRQsCp+njSVVMMWJwyH0mV2DEG+L56xOPXXB/qFvdRpvwrhxuOI H3Dp9WfQwH8XYUYaSy/QVMnbQnGnlVqBRi2u9PbafEY3rCeDL9MmR54twIFmiJ5of51L MDRGp1rb+8DWIXJGToLvDqz11R1Aftt1tiinNvZX6m0mirTmfETXWVUVt3TZrO4ttcvg l93Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W12qSJ2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h2-20020a056a00230200b0068e390d86b4si4829321pfh.133.2023.09.22.13.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 13:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W12qSJ2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id ADBDC860AD33; Fri, 22 Sep 2023 10:29:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233293AbjIVR3y (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233041AbjIVR3S (ORCPT ); Fri, 22 Sep 2023 13:29:18 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2BCDCE5 for ; Fri, 22 Sep 2023 10:29:10 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2765c9f2a39so1764923a91.0 for ; Fri, 22 Sep 2023 10:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403749; x=1696008549; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gSa6oULDCwttnYj/UXkUGWzp9s7+1yQ+R9ugGfGb1B4=; b=W12qSJ2a5KmiFisUjHH7hkoQcfR59dH5U/g5DqfnK1X8qgWD7FJWHpvRjlyO3L06wD etWMl21Qgyl4m2ghvH16fNsvkac2IlGdqgg0iM/ab+qHVxMkbqYgbuJ+tjrVxBZ9Qede QVQcA9jLn2YqAKcTCwMx6gNG1lG2eObrAU6Sc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403749; x=1696008549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gSa6oULDCwttnYj/UXkUGWzp9s7+1yQ+R9ugGfGb1B4=; b=O+YQvBIn7W3Arq6RTjNzzLb6uV0d3y4wz6srq+tyIo6SfxJI87yClaw5olj6N/Unjo fxFxkTDqsWpbLlY8hD7ftIqXQFdD48yriixicrgQz3AmW3Mrpge+dK9ef4B5SxWjyFT7 HuCYsa/i9Q64xci5ucLIiNo9M1ni4NzVgNeqvIDumY3BBbKAiKIr8GKDiNG/ofn1bCi5 FXKIUXbdKtsXU+laYjt67Lopz+Kp0HrsK88MBwZpSyaY+E7lLpuWJPphXw/5Fs1KIcS7 oIy3dQev9NagOYF8pFm6y+GowJ4FnKP8NCmGO5+1kZ5I8t+enuLpvBblFOa1H55Y3ct6 9Nmg== X-Gm-Message-State: AOJu0YwUbE1b/Hkk/qbKC6oLNE3V+s5l+DGw+kVsF+PUZqjNHcpMElcM zrFW1Lgd8XXoDrj1aZP/snvfPA== X-Received: by 2002:a17:90b:1bc5:b0:277:1bd8:abe1 with SMTP id oa5-20020a17090b1bc500b002771bd8abe1mr303008pjb.30.1695403749534; Fri, 22 Sep 2023 10:29:09 -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 26-20020a17090a1a1a00b00276fc32c0dasm3068784pjk.4.2023.09.22.10.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:04 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , "David S. Miller" , Eric Dumazet , Paolo Abeni , Shaokun Zhang , netdev@vger.kernel.org, linux-parisc@vger.kernel.org, Jamal Hadi Salim , David Ahern , 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 , Cong Wang , Jiri Pirko , Nathan Chancellor , Nick Desaulniers , Tom Rix , Simon Horman , linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, dev@openvswitch.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH 13/14] net: tulip: Annotate struct mediatable with __counted_by Date: Fri, 22 Sep 2023 10:28:55 -0700 Message-Id: <20230922172858.3822653-13-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1360; i=keescook@chromium.org; h=from:subject; bh=pEQ6m/Ojl8iZZMdU3eWLn6pX8bV9cI5eUZQsnPhAnjQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7XkbXKZplSh9lbnY+7Kzc2rn8+8PrOJtg7N VYk6XUim8qJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A JlK4D/0a5nvQxsfMMYe9Iz6FtaE4ytVsQDcsZFdGmgQChSwGLCdG1Sa3F9I/G5YpqxGxJ9MNkss +nBxQtIkxud0XXfvo7iopnxIgD4mvFFE82jWjI5l+YqV7TCu70N8lRiKrnPnHt7F4pX/YBRSzP4 Z4CSFFVLw4aHwapWBtYrbzgkkkOcawEXJ9SwIe5uQjCSi5cTm3Fhxi1Y3b3gnLG2UE19n3AAvV1 MELt6/MIMajh61Zk7bylLfR1U9tDOz34sjH3t6DRsGC34XAypF/4EZFJ3HpQHdnPPo0b1WJN+R9 I4X59+l8NGkwQHFOzJZS/jHa/7YBQAkymun70pKFQv4oEGS5anucsYwBt8F9W+lQ6it5Z8PWv4g nlHRBeEueC6LuAI+hB7sF6dD3LB/xaawEDJKiHZaHoG9CwxgxtXI+s9GBsAhetoUmE2b5GNdoEW Ix5esRXBd3MxDY2qQKgBHpxzkJCjVcBkSIDPfB+6QbvXKiugSApEqCw52zAoL4vZ1DIYTX+eULT aFDnk/QcBxCFto/Y/DDesSQa/0VZ+AkYXsY2Wo+QpAFR7HYoGmEub0VuATWQu8NsBJEZDh1tQ5N 1uU8WV2UjWnZfw75hLVF3Biggl8OKiurzRsCNrHh5yDeGQp0hufJgv+TSoR9JC2NZtc69JniRcJ Urav/CBb855RzPA== 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:29:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777771534393677725 X-GMAIL-MSGID: 1777771534393677725 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 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 for struct mediatable. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Shaokun Zhang Cc: netdev@vger.kernel.org Cc: linux-parisc@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/net/ethernet/dec/tulip/tulip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/dec/tulip/tulip.h b/drivers/net/ethernet/dec/tulip/tulip.h index 0ed598dc7569..bd786dfbc066 100644 --- a/drivers/net/ethernet/dec/tulip/tulip.h +++ b/drivers/net/ethernet/dec/tulip/tulip.h @@ -381,7 +381,7 @@ struct mediatable { unsigned has_reset:6; u32 csr15dir; u32 csr15val; /* 21143 NWay setting. */ - struct medialeaf mleaf[]; + struct medialeaf mleaf[] __counted_by(leafcount); }; From patchwork Fri Sep 22 17:28:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:910f:0:b0:403:3b70:6f57 with SMTP id r15csp28822vqg; Fri, 22 Sep 2023 18:45:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQ9SqpQa48l4NrehzfM4TvkQwzVnRvmTSy81kz52ZIod24IMwOwoee8J8adKoP0uOINcXI X-Received: by 2002:a05:6358:2822:b0:143:5d3f:f397 with SMTP id k34-20020a056358282200b001435d3ff397mr1449257rwb.16.1695433544357; Fri, 22 Sep 2023 18:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695433544; cv=none; d=google.com; s=arc-20160816; b=ne2au+4ELuMPOMEDS4PuTCIlKSkX9Mh/K67rgukxNMRBhmNUkpFNhKvyT4EH1qE1Rb F9L8rTm4zwSZU+ZzNrKVXq56IRBKe1gKN/T9kjbAruA092ASGsYwWOpDWEF+99bp+E6O QVQVuXBtrjZ2B9jBCAOlYWKTNyVmlppIZ1LUqc+X0x5Ulhs1RjQ1Lddj9bYkWLsp227I pO8IsP985AHsTbzWR4TfHVxnouXxD+eYGc9q3vjnrIrsI5QDnDwzf4huLbwYbgcZr5E6 zEaod9yvYrquMkP9sceWzrXJAYdBF3150eDVSFi0mXod8Pl25YJQbfWPJQ8XFnJviXfy Obuw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4qbLpDWUwgzzYPCRaxCJqmb/nv0TKtcjFS6rBqkmcgY=; fh=TFdx85WNDn26cN2UpQ/oRcnMpzOZHXVPBKkf6MO6Zbo=; b=Wxm0NbXlwaPKpRqnipKioWigOWF2jmJKh+S5jnCkh+Hm56BJKIZGwlG//EbXbD7DD+ YhKUcCiW5D90ik06dyL+Ns2ot66GrXJNAZ8dDEMSVMwIYa0F9yoOg0HvRL/uf8j6xFzj KgXv+CQIi1MUoD758qr7Hu7ILTS6FX+S2wansOAsawVsweyh7+5b4jOxKClK31Gz/wRi Bki2oD13dGiY647LUhMuhHqsxqBG4W+i23LTPBnaDJmGagMyHU/xOwRID3Zf3tsBZ57a PV7rR1WBePfpPJ/bYizeueo4KiO888WvwyDNG578SIr3S/9S67fH0TFD2NN/IXiuyxne CaHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Rmhof9VC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bf13-20020a17090b0b0d00b00274b668b762si5011021pjb.172.2023.09.22.18.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 18:45:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Rmhof9VC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id A2C22860AD28; Fri, 22 Sep 2023 10:29:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233228AbjIVR3u (ORCPT + 28 others); Fri, 22 Sep 2023 13:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233050AbjIVR3S (ORCPT ); Fri, 22 Sep 2023 13:29:18 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA3C4CE9 for ; Fri, 22 Sep 2023 10:29:10 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1bdf4752c3cso19960355ad.2 for ; Fri, 22 Sep 2023 10:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403750; x=1696008550; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4qbLpDWUwgzzYPCRaxCJqmb/nv0TKtcjFS6rBqkmcgY=; b=Rmhof9VCSONI8qKtDgVkygB/9N3WKOhTVZNbN1IpQGHyy1Cm/rnPQH4RrzAL29vhf3 3xaySxt4zTIVA2CfdsC4DkiOuyIczVoCn/OER7DaWq8UELh5Vzs+H4OBEVxC8Vc/SX5h bIHZ4J+TKjAavKK3Ucs071KIMcDVhPmOY1RbU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403750; x=1696008550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4qbLpDWUwgzzYPCRaxCJqmb/nv0TKtcjFS6rBqkmcgY=; b=Pg5fh3Zcfw6jZBggqXFELpoWe/f/lpComerTlk2eAVVfUo6cjon+QLvuxp82rhogeN p99R8K98/4ahoWqx/8ZNGK7m1YxykiJcjd2QNokMiDILMHqaGucsAcsUPt2fkM/u8Tu7 DABUMO92Iu+wjjZrWfH/pvB0BqtiAGfcdYq11xIeIPK0WdkmUmV42DdPfuK8SjaAKnaM +J3j9y59tBpRoUyrP5ezbmibSvkbpuWx9GKwwIqaFXgZ4FD1QVH92AvO6/34ZaOUkpcu bAi00wKjfcDuDozmkXulCXdGmMjSh+MYPliBBxC+GV5sGOs96+MLMhxHv/m3oUE55LRt LWoQ== X-Gm-Message-State: AOJu0Ywh0ZQe+D/h2Jdv09CCRjtGPtmdlNo+241dJzn6Td8Hr/EgSSKw znDBi2bh5IoGZB1tuxlJb9mhjg== X-Received: by 2002:a17:903:1109:b0:1bb:d59d:8c57 with SMTP id n9-20020a170903110900b001bbd59d8c57mr130556plh.18.1695403750017; Fri, 22 Sep 2023 10:29:10 -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 a2-20020a170902ee8200b001b66a71a4a0sm3749961pld.32.2023.09.22.10.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:04 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Cc: Kees Cook , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, David Ahern , 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 , Nathan Chancellor , Nick Desaulniers , Tom Rix , Simon Horman , linux-kernel@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 14/14] net: sched: Annotate struct tc_pedit with __counted_by Date: Fri, 22 Sep 2023 10:28:56 -0700 Message-Id: <20230922172858.3822653-14-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1707; i=keescook@chromium.org; h=from:subject; bh=2t/ZxOWEU2viROo1UvEVFxKv5vcCA9cvfvIY7AUZekI=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7XaxqapjSBY/SPBC/x04RSUHK/UIttRsNmQ BtJyGkw5WiJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A Jh2RD/0dUjACoTlVEZR/rUTfjAaXcRrjdWj/jRwZhzM+BFjVVrkW2WL4vF8f3OtpT1D37kVC6yt 5krc2k1SgI9i4EIbbTCTHDKmLHFMdeNJj5yXkZqGe2kQocQH6O2t4MI9L3hpREI1/FZbqJdfIhP O0VkQhiYhU7Nivmec62bTZvgzPCuVjj1QbCRx64McRRzIsCOrxiOJVxaLRn8MXUoag8JHHVtq8N C0GRweTtJdTEnvySnkIRdOv1aQSe9bmyu3n6UfeVSb99zjCgoSq6MzdIJIykmvV+ipPWiTOAHXF hgcx6Nj7vOyb/udVU8Sy2EyA+QKSJGjs4xelXxxAAt5eYBvynuKGDPq+5enCP676vNeK5lYIcdM tjR9wL1D90SxMp0k31niGjQQfhd2hZX207yL3hWHrAmFhKgGM58T6wcW6TJM3kyVNhw0Rsgw57I 3Qs/3XpeZD+0L6Yz/nZiIjHP5q0ZEHd8RaV5+RBsuMFOD4sSxoz2dpbIgFlMC5M6rSM3HYp9QRu 8bWPWgo4YgaynOSa3gYtVwkMV4winLmyJPRJ1RnvUXpyMWvyDnfoH38MZwyqVEnPdIXXbXejgny eDjoni1yyVaDXPOQYroF9Gf+NTE14pE11tfkIsS5+ql+igraxVPAXLcoQzTe5Q1j/7N7pAMKrKE ckNAllL+gDJgldQ== 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 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:29:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777781276427591484 X-GMAIL-MSGID: 1777790924086805265 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 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 for struct tc_pedit. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Jamal Hadi Salim Cc: Cong Wang Cc: Jiri Pirko Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- net/sched/act_pedit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index 1ef8fcfa9997..77c407eff3b0 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -515,11 +515,11 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a, spin_unlock_bh(&p->tcf_lock); return -ENOBUFS; } + opt->nkeys = parms->tcfp_nkeys; memcpy(opt->keys, parms->tcfp_keys, flex_array_size(opt, keys, parms->tcfp_nkeys)); opt->index = p->tcf_index; - opt->nkeys = parms->tcfp_nkeys; opt->flags = parms->tcfp_flags; opt->action = p->tcf_action; opt->refcnt = refcount_read(&p->tcf_refcnt) - ref;