Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp517057rdh; Sat, 23 Sep 2023 23:26:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGzMxHBU6eIf+iMLwQ1bYW27xCsI1R5eLER8DlSu982kj9jB2oHtMXvvfurBl20u+bq2Fz X-Received: by 2002:a05:6a20:7283:b0:134:73f6:5832 with SMTP id o3-20020a056a20728300b0013473f65832mr6437001pzk.16.1695536813282; Sat, 23 Sep 2023 23:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695536813; cv=none; d=google.com; s=arc-20160816; b=nZvv1sIvydjmYx22qr/hMozYaQPkQDH71h3Md/5BIU8dZS4LBKBJSOEHqj4WUWI6aY 8KNtOkkS2kaWHAN1gHH+ya+p1ZAUco62M2SSLh9czcyu6+hOroWY0xB6GziEE/n5jDdE qQbHupGKCzcPe8gX4T1G+8jzycmA6lrbd6yMluJx5Zt+GQOhtLqpemQK8Q/BD1C+kGbL ZSV3nZ+dnCDjEXa8dpedojMgCgkn2yxiiuctWTXnAjBAgWt51wIN4I7QxEH70wvb0fTk soltwbPu5BSaGn1ARMS8oiVtGXAxGkSw4rb1DkIf//xh+GXXhbjeyRgJVy5XVaEemXKS 4eZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vYVo5GdkTbBgfnivmVoW8KukwKTsj2A6u4CjQwQFBnw=; fh=xQ6d7f4z2zvMT1F41PfJdiF+i1Vc8BFbxAtE9n1GfYI=; b=yyczL71vmpnYCtvQohg3DLHwDsE8PiLNtRezBGDZyjJ5i0LjVCi5RdgL5RWW5PEaYT N+Z5FQ04m60f916TfRdi5buOM/3UGTom7R+3bB46ZUiw6ihE6GdbAyoQ87PhjDPfyvMQ 1LanpwRmJ0vOHHaBuNi1AIgQt0sKIZjfAG7ispwNVluBfp3D1M19nZf68LQzkVFBNcd7 TmKUPfXu7BYwYg0GJk790mmTav8p8z1EL3cC1S00RKXF2tX2ham3kS5Sqkk03ImtNIhy XaAWRD+Qj6mWNb44z9/B0Oqn3b/vU1G14EGhCIy8vGQiEUrhY5uYJsY4wb9eLaUdMZpN sGbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SGLLhABu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id s26-20020a63451a000000b00565701e9a36si7049283pga.752.2023.09.23.23.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 23:26:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SGLLhABu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 61F23819BB57; Sat, 23 Sep 2023 19:03:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229846AbjIXCDg (ORCPT + 99 others); Sat, 23 Sep 2023 22:03:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjIXCDe (ORCPT ); Sat, 23 Sep 2023 22:03:34 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 321E6A3 for ; Sat, 23 Sep 2023 19:03:28 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-578a62c088cso4130166a12.1 for ; Sat, 23 Sep 2023 19:03:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695521007; x=1696125807; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=vYVo5GdkTbBgfnivmVoW8KukwKTsj2A6u4CjQwQFBnw=; b=SGLLhABuwI73NA3/AHiKeurFZFCrtZ9/z8Ak3RS++VRDkQVMnDFnEOA9U/FpoOUOJH N4ab3hpVJ9odTyIIOSnLhEtH8al8lU+sASIYFOYEWniMI7Z33DLBGwR+YvI8GJKJc/DP zCPTX3B3mKKdk+gXhtXGAvbgtxQ2ocPZE86qQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695521007; x=1696125807; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vYVo5GdkTbBgfnivmVoW8KukwKTsj2A6u4CjQwQFBnw=; b=o2LrQcgq0FA+T11m/iiybYw9vzrmGsi4eb9IEw2tshWC1uFq9K6b1k25IZRyDlxq/g cXNmRVA0E/pEhHmx940bqGGnrtGU0ryBhdbkSOXz7srXRly7VCG4w/idegBkqzD6Z+8g m6UNcQKGPq96JGeiDJz4l3EhiJ1K14PxvgekEKwbbdVwDTPwl2dPhAer0IqGIlWFnI+d LmxEj1+hkesFeCFoMU7WXKrDG33IJd4RE38SmCOuekE+aT2BimWXOadEqRnSDrUxLNMo jXOsQkjDk9yeVtN4f/qT51js25rys1B3nc2trWl1KZLLoUIy7jzYbT9+rcnNkwIg4K8L TZ6w== X-Gm-Message-State: AOJu0YzXjGTlFEHwxde4LR/l9mpAyg1gEb1/VXHAondRdIil9icsuUTb DaIv9j3NHYaHhxfUsiZTp79AoQ== X-Received: by 2002:a17:90b:11d5:b0:274:ac60:1d57 with SMTP id gv21-20020a17090b11d500b00274ac601d57mr9710054pjb.16.1695521007664; Sat, 23 Sep 2023 19:03:27 -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 n6-20020a17090ade8600b002680dfd368dsm5521151pjv.51.2023.09.23.19.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 19:03:26 -0700 (PDT) Date: Sat, 23 Sep 2023 19:03:26 -0700 From: Kees Cook To: Alex Elder Cc: Jakub Kicinski , 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: Re: [PATCH 08/14] net: ipa: Annotate struct ipa_power with __counted_by Message-ID: <202309231859.D8467DB23@keescook> References: <20230922172449.work.906-kees@kernel.org> <20230922172858.3822653-8-keescook@chromium.org> <6f52f36c-be16-2427-c19f-0e8b3dd2ff5f@ieee.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f52f36c-be16-2427-c19f-0e8b3dd2ff5f@ieee.org> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 23 Sep 2023 19:03:36 -0700 (PDT) On Sat, Sep 23, 2023 at 07:09:19AM -0500, Alex Elder wrote: > On 9/22/23 12:28 PM, Kees Cook wrote: > > 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. > > Looks good, thanks. > > Reviewed-by: Alex Elder > > Note that there is some interaction between struct ipa_power_data > and struct ipa_power (the former is used to initialize the latter). > Both of these contain flexible arrays counted by another field in > the structure. It seems possible that the way these are initialized > might need slight modification to allow the compiler to do its > enforcement; if that's the case, please reach out to me. I think it's all okay: struct ipa_power_data { u32 core_clock_rate; u32 interconnect_count; /* # entries in interconnect_data[] */ const struct ipa_interconnect_data *interconnect_data; }; "interconnect_data" here is a pointer, not a flexible array. (Yes, __counted_by is expected to be expanded in the future for pointers, but not yet.) Looking at initializers, I didn't see any problems with how struct ipa_power is allocated. Thanks for the heads-up; I'm sure I'll look at this again when we can further expand __counted_by to pointers. :) -Kees -- Kees Cook