Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2271669rdb; Tue, 3 Oct 2023 16:19:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8aN/Bd5FVuMGDKqXYn+gleVlifMfsa0DhaWhKeK6SgUjgCK6HCg10OOtLIOnTlmL+6GJW X-Received: by 2002:a05:6358:2813:b0:143:5fd5:b826 with SMTP id k19-20020a056358281300b001435fd5b826mr837036rwb.24.1696375198707; Tue, 03 Oct 2023 16:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696375198; cv=none; d=google.com; s=arc-20160816; b=iN+ADEx91fyO1jzorbLJUEAATEeMgRuiVuSu4xMwp2UPpZQExaiV9MaObY/OT+Irq6 v6JTSz5Gb0QZVA+845pLbuE4/ymKYa2eDzDn6UYWIo6ziq0+owUuCC2RzSShowzXCzAK Py1QUGDTuzCiabvQ51L0r35e/bzDSEAT3ktD9NoCU/jytTEGg+S4Re1+9s4QUSomzY2t b1pHKGRNM6banVApjtMK/HRmpc5P2zyIG0l0KUsmDjMr1BBpXfSnxWDhDc9COXUYQeSt Ijhf/54UnRrkEVOkBishbA7I8ikCDkI+pM0DXpMDzXAkNcIs6GHVYCEwIXTEPmc4FMl0 YaEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Fgl9vQEJJbjNo7nW0Wg2fi9SpTiuajLNVx4n3kKMxac=; fh=k8TeglK2ykGRgQZlu7j9qYqQ+NBjwSc7+9TfdDAJBG0=; b=ZqpmTM4iBL+jtDgAbYNVhEFxGtkwflDwYBl9Lmtnm6Z6sVDGYqmFMJo6VR7D3hhOGt fkwYQGtkHDssJYfe5ems8ztA4scrVzyvZlR+DVNLJxm+4KRQyP/NKjUVmMPmaHhek8uI imA8BkC7kS2HmdW7GjxDxTbnzi6GKfRk6OmQjoaSEz9iNiSfqyB3jSlqlXYzp/PU6QY4 1LT93kr4jgwCN84DDSE8uM5NG+TEtNiUlWRaFpLXEZbbjYaPEd9wEJOxhYpCGoprt7uR O1diyxZZ1qIVLMUHN/QhCaKCI1kIKJ1UcVE+fMJgj5IPNWHoDGmliNZz//DmMD8os43S 5FEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AcEAfpih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id n34-20020a17090a5aa500b0026b42961a4asi280413pji.38.2023.10.03.16.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:19:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AcEAfpih; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 4FEBA812673B; Tue, 3 Oct 2023 16:19:52 -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 S234508AbjJCXSf (ORCPT + 99 others); Tue, 3 Oct 2023 19:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234908AbjJCXSd (ORCPT ); Tue, 3 Oct 2023 19:18:33 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD236D8 for ; Tue, 3 Oct 2023 16:18:28 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c3d6d88231so11484925ad.0 for ; Tue, 03 Oct 2023 16:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696375108; x=1696979908; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Fgl9vQEJJbjNo7nW0Wg2fi9SpTiuajLNVx4n3kKMxac=; b=AcEAfpihltU5ZDG2QebOjn0wc1RP5vw72GSbjzHmeVUUo4G0OmFLLxzb2ghokaI9N0 +6NzfjHeajIrURTttNCqsoOq4Q5WDaC9PmyzuIfFWJWLGGvra1ONcjiyyjnS3t0R9JM5 zuLQ31FbzTa6TlgRwhzQ4sP0YTVIx8rRJ947o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696375108; x=1696979908; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Fgl9vQEJJbjNo7nW0Wg2fi9SpTiuajLNVx4n3kKMxac=; b=HwL4vE4ZWj7OqtPubgP+DOYvnxMcaItKictoChRGy+MwVGh0osEsLe5WtQulCm57di cuwrNxA88e3nLmemDKAmupxYZVUPQmFi1MZoCTCs//1WnyHZoxyLIzOL2DJKkJJienXW aV6aD9PiCdp80+9yUyWG0grxhmr2Aqi5M+CCIu8ZxQFMSbj3GOMT/GcRVQe4G3I3f2M7 xIDJRlV7SMr39uWOR8YO8l6PQ946yUZdcKBGUgkny6JhsymW30K/yUekVhpiBrBDUBZH aYBJ052fuJGsn0Vj0dQbF9yHDxdO+nTFpgr/eY2enVm8LF4hQh+dRFBoZoXxBab6s2qj FzLg== X-Gm-Message-State: AOJu0YwzfzX2mlcmSTJevw8hOqWhu/J9hqBIFNPj/jeK0S2r5hb1arka LK+ziomnCbB1rDylsZjMG0c+QA== X-Received: by 2002:a17:902:8f97:b0:1c7:4973:7b34 with SMTP id z23-20020a1709028f9700b001c749737b34mr847042plo.50.1696375108193; Tue, 03 Oct 2023 16:18:28 -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 j6-20020a170902c3c600b001c55e13bf2asm2164183plj.283.2023.10.03.16.18.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:18:27 -0700 (PDT) From: Kees Cook To: Stephen Hemminger Cc: Kees Cook , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] netem: Annotate struct disttable with __counted_by Date: Tue, 3 Oct 2023 16:18:23 -0700 Message-Id: <20231003231823.work.684-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1281; i=keescook@chromium.org; h=from:subject:message-id; bh=QpdV3D/pVMVweNA2oq+ijy0Ps1fXCHwUqT0dHu1y9HI=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlHKE/cn0ZGSBlVX+YLyS7A9haLOLgFWp/l+KGJ DE5lp8PcbuJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRyhPwAKCRCJcvTf3G3A JhyLD/4vRULjUhoTz+b+8DrLZnXEOUIpFIYJ+0ej73zTgRl+SU0hEtcV/IhKk4IxNZLKfg0zx3s sJ8zaDIZY/OuFu+YH5xbTOwAugAftkAjY+ZqN0XPxmkxOYjrx8zgEveE8iuwf2zxAL3xt9JDcQ/ O1Wvsi3uEUzLs1QIrtaki9tOYku41VrQNQlOcpZjcyMh4DLPMBBVTejrG+8nyYlOOkmlwgjEMLz C158/Q8P5Be9//NQP1XZdULie/GNiaQZ7T4bQreXvgpQ0tr1lrQDbF6/8Q1gtWA1qAOIxqtkifw cXxGIe2woegB1Do1RgBumq0NIqYJRFl84RGqT0G5JuEzM0wecHS5QhEyObBw0vIYu6CV9NuAybw sZ7LAHZSSfP/+ZdIiaPsKV54lYYw56/txl25EgaxYjjZfRrPeNzjdjEAMXEvJKUXLSrGlqbnpwy IlG7RtvhLYPyIvOf4RrB/DoGUXO/JO18rAY8+spUsW4qU7M+F1ZvQNM5uqBF+PQSmCIEyM25wY5 M/dKWVd7aB9oVyVBpNes2MNIglyizhxXKKMPwzXAeR5Ya0MOm1NsiJbRvV/7fJSfVJi0O7T9ZSA G4KV9HyfnLV8D0BhDlslXUjwAwImcRCCChBdzFfz+tx30E0nB3LsPPzZB8EgtetyzHqaMCBJNvL 1JWISSN X18Ox4Ag== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 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]); Tue, 03 Oct 2023 16:19:52 -0700 (PDT) Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). As found with Coccinelle[1], add __counted_by for struct disttable. Cc: Stephen Hemminger 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 Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1] Signed-off-by: Kees Cook --- net/sched/sch_netem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 4ad39a4a3cf5..6ba2dc191ed9 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -67,7 +67,7 @@ struct disttable { u32 size; - s16 table[]; + s16 table[] __counted_by(size); }; struct netem_sched_data { -- 2.34.1