From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE680CE7A89 for ; Sat, 23 Sep 2023 12:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231392AbjIWMJa (ORCPT ); Sat, 23 Sep 2023 08:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231313AbjIWMJa (ORCPT ); Sat, 23 Sep 2023 08:09:30 -0400 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2F7C19F for ; Sat, 23 Sep 2023 05:09:23 -0700 (PDT) Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-79f9bad1a44so78971239f.2 for ; Sat, 23 Sep 2023 05:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ieee.org; s=google; t=1695470963; x=1696075763; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=XAvg21g6nbbw1h+/pTYxIjGaQhk7mPIWAIow3O+el8w=; b=DLxn7//6yHMxeoMVTrr0qYfohGScaeS52o7/UDk+9PW6VThFl68e7D6/DbtAvdd89d j4tPcCOJdhW7AV9sEMT1a9YVpIa+LScQn5xrcjXeP37Wdw/wFTi6kNGdSm+uvfNLea7h iXPnp5mpMKN8gLjueJl3kO8wLSx9cueoTjppc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695470963; x=1696075763; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XAvg21g6nbbw1h+/pTYxIjGaQhk7mPIWAIow3O+el8w=; b=D0CRO3J6S35UtiZpzK3Gs8bdEjmq4PgWriaf4YGXvMEMuepdYLFgV4Olw2u3asixe+ 4BANHhGC3vojoh4Ac8uPTmFZe+ZSsbgy/+YY+hWFyS3iJyiA4sT6IttIWkBUVTBKaJb5 mMQzGsJP5fMmzWPi5Ncz83UF+3Xy1H/p/pSBzIhHtNedrGH9f5FB5oFo6Lu3RDNQP1X0 DnPz1OXYv3WBxFi+tuOh5MTY3QUuSqdtS6xX6g5GleVZxU6x4ny+oUsHnFUw1UGXupvO MkUwFb2Xk5zYISEcjlo/4lZW5bYTtMGR6gJ31Nt9GmfkBZnF+T7M5kEXNSkOH67vqnvz aHVg== X-Gm-Message-State: AOJu0Yx4arUfHZa7FQr/O/mF97F93Grq6V2jP4Qi6so0d+X4Dv2Qhrh8 qE7f1VkcLjn9eIecySvlAr3dAA== X-Google-Smtp-Source: AGHT+IFsU/+zIHTFsRo6MskEzPa2bwVmahshwKY2z15uRkbrNeJwUhIadfi6G6UMDY5d9luXaBJ4hQ== X-Received: by 2002:a5e:8d0c:0:b0:790:f866:d71b with SMTP id m12-20020a5e8d0c000000b00790f866d71bmr2106815ioj.13.1695470963122; Sat, 23 Sep 2023 05:09:23 -0700 (PDT) Received: from [10.211.55.3] (c-98-61-227-136.hsd1.mn.comcast.net. [98.61.227.136]) by smtp.googlemail.com with ESMTPSA id ft16-20020a056638661000b0043a21abd491sm1610905jab.120.2023.09.23.05.09.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 23 Sep 2023 05:09:21 -0700 (PDT) Message-ID: <6f52f36c-be16-2427-c19f-0e8b3dd2ff5f@ieee.org> Date: Sat, 23 Sep 2023 07:09:19 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 08/14] net: ipa: Annotate struct ipa_power with __counted_by Content-Language: en-US To: Kees Cook , Jakub Kicinski Cc: 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 References: <20230922172449.work.906-kees@kernel.org> <20230922172858.3822653-8-keescook@chromium.org> From: Alex Elder In-Reply-To: <20230922172858.3822653-8-keescook@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org 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. -Alex > [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 > --- > 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 */