Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp455152rdb; Thu, 5 Oct 2023 10:35:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6IwKMTmANvVfvmwi6Pyyu4lhbXqqEQAHvAEDhd9eYJmmyUlR+vjYU29RW73+/J4TlecmZ X-Received: by 2002:a17:902:f814:b0:1b3:d4ed:8306 with SMTP id ix20-20020a170902f81400b001b3d4ed8306mr5320949plb.19.1696527350707; Thu, 05 Oct 2023 10:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696527350; cv=none; d=google.com; s=arc-20160816; b=xrUbqxi9GjVjjH5DjeVUaluICKX2k1vfbnGWVR2rgtC5xrlXYRdePYnlzkhekpmq7L J5DsSHR5NyFdRuc1OBWoJWUtQdkMPs5n1114VjVAF9FVXBKEvg6t2tHFEuf/mtb0Lc4U MTHxFMgvER3QM8W1QoSFTtov5/dj9vY1PsPH5gp85bYCAYm9FMk5InegQrJjqHEVO7zw 1+jp1vkQoof1A7NuV/gJQWq3Qy4HTz2joxEoff2vZv8y5WjJiIIhrtpSClt3l0wJcXbg VNRIZ0lqkHBy+wmu8J8KWgC+faCuyYPwPl35oNgXzavYn/6W0SLBUkgs5tHYvzg0bbZH xZWg== 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=Sk2AIw2pt4hARdmfDz+pJbA65TQJu27TBdJQsR6YVso=; fh=UQMZd3CtO4Xf3sI8yabJ9qr7BkQcbJKuoSh1x8gl9S4=; b=H2vYpvr5bXp21/Ge5vf5qN6U5eOMFghhPOEDMmsyVxxxSl7U95yKzVoxZZMCtasrNq 2+ha2n7y4gWGiHUN430Jn7pTHt3kPyW7UecDOcNtcnGCJ6LHhOnY2b7+pyMgSyURDpTX CZOtiK2hfgqXd4Q+H6awsYEKWTQkX69WEPje/7NhvYxXI0XrK3GUjAdLNs6MmBAsqpvr 6rIq5wJVeNnS2cHrM37x9NFm9PMsfRP/bfHkiMxXFcyPJexedrIpQ3bpISUcxBsjOnSU Gi+xdYx04BBvpFx8OThu/lVJGWqogBUwYkKwAB+z2A5DhHhFyJOrNHpaXMtSol4zViQ2 MNdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jbPktZ7p; 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 Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id a10-20020a170902ecca00b001bdd35033efsi2035703plh.374.2023.10.05.10.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:35:50 -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=jbPktZ7p; 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 9C85E833D56D; Fri, 29 Sep 2023 11:05:53 -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 S233748AbjI2SFV (ORCPT + 99 others); Fri, 29 Sep 2023 14:05:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233804AbjI2SFF (ORCPT ); Fri, 29 Sep 2023 14:05:05 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BDADCEB for ; Fri, 29 Sep 2023 11:04:34 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-690bd8f89baso11679106b3a.2 for ; Fri, 29 Sep 2023 11:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696010674; x=1696615474; 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=Sk2AIw2pt4hARdmfDz+pJbA65TQJu27TBdJQsR6YVso=; b=jbPktZ7pq3R5vQZkDKPITPCb0VWyGBYip46/QkIIxuajAsGyY4AZapz/t64rlgA9VO 6ihBTOllHCUaBUnDzfPJY1Wc8Eh6FbTJBslHt+zm0OrmdLm7eYPgsVidUtJtQuWF80bY PXawxC1fIDXDuUyNyAf/SfByF0NaKGuoGce+k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696010674; x=1696615474; 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=Sk2AIw2pt4hARdmfDz+pJbA65TQJu27TBdJQsR6YVso=; b=xQ0ExKhUMJt0hlSsyURAKt4qLTPzoquUC32hiuP2/H2o+b6znkGAZHd8cnpQuFnjXo UuceVl+uBOoNmIggmkbh5o04NsC5NbFd0aVjPd8TgSAU1N0lQIkrrPEGUungTAM0WSRt vfSyfQjSGQTdo+FpL/ZJJIOJKbAPEI+YLmLT1XXV4neh3MGZSTNJrQoTYa/EMgcuImJY rgffmnlRSKn3xPK9BehYtLJhU6ePrkv5023YkrCO0GgnUvVOwmRInCUT9FYufMsFFwPn TmwBCkUk8hX10TZrzYLJ12RWNaZ/AZenXrOOUwQExnroVFPqSW3jUxVJFOh8Ddcr5JRo rojg== X-Gm-Message-State: AOJu0YyKGVR9tI8SN2UGs0jWsxBHNvR1iTAMsqtylZaHK4f7erltqa7G VEZ6ZpttjFxxkursVotaFNFg3A== X-Received: by 2002:a05:6a00:1589:b0:693:4a43:1c7e with SMTP id u9-20020a056a00158900b006934a431c7emr5259056pfk.29.1696010673936; Fri, 29 Sep 2023 11:04:33 -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 s196-20020a6377cd000000b005789cbd2cacsm14718511pgc.20.2023.09.29.11.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:04:32 -0700 (PDT) From: Kees Cook To: Jason Gunthorpe Cc: Kees Cook , Bernard Metzler , Leon Romanovsky , linux-rdma@vger.kernel.org, Dennis Dalessandro , =?UTF-8?q?H=C3=A5kon=20Bugge?= , Avihai Horon , Anand Khoje , Mark Bloch , Christian Benvenuti , Nelson Escobar , Bart Van Assche , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Tom Rix , Patrisious Haddad , Chuck Lever , Tom Talpey , wangjianli , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH 4/7] RDMA/siw: Annotate struct siw_pbl with __counted_by Date: Fri, 29 Sep 2023 11:04:27 -0700 Message-Id: <20230929180431.3005464-4-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929180305.work.590-kees@kernel.org> References: <20230929180305.work.590-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1176; i=keescook@chromium.org; h=from:subject; bh=8TFS+r6rwfEZHwFvOLksc3v8PZIOUrROKrYJlwQtijk=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlFxGu773COsQ9qpU+8QNaYwhfW/LhcAaSb6gVg FWhje/hPFOJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRcRrgAKCRCJcvTf3G3A JoKwD/98GIMcp1DtQPrGoXgjgRKK4LtdowIapfABsa34RZm6dmv5HgM9bCb+SlhpMQ0LbdOmLDi QpNAWZz/IIMNujaAkdZNQoGNvE4WXfkmDvsyLByCirVuOambsysBvy7ZxEKX78YWT4Fgr/BIkt7 YQTLgXeEGLUz3pXd5DV/UOkYEaiOocsWiEjNJgQezzsRjk080yecZE8Uuofk3lBnLmHXVVlezDE 1F14N790wyRyXR+1F2EnBtHDBb3SzKoTUm5ZzPfi8o3eZmhR+/Qgk8yqXcJuVQ1lGxbIkGZE4HQ k4FQSCvpLBWvQKmC9iS9CWs5w4uPGbAUgX2De3P5wtipK4ahcpgWianBFJ2lfoVUTX4QVWBGpqr NZ9XSnhMyXywgMW4Vn8fI8po9Bnrty6JCNekXPpquacZOz0arMq/32cCWmetdys0Qi6EODNhALD /ABu3vViC1ZK5pViwpHiK1JtFlum9I/mp4gUrbpn9VU8skPh3dyUH9VWlq2rAV4BK83IlPVw02P 4pmkldLl63CWi/d7mvhfPtgmc1Etz33xHDSk31DEEBvqh4AQ3kmn1G6+2RtoBsV9QPV3qkjhH9H V3wP50SqbitWnN107wLHRygD085ais4LIDR4xdFyC4K6FmyxVY1CJKjlPyiLCPKJVA8KV1TGqqz pSuxYgQ0Gj82THw== 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 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, 29 Sep 2023 11:05:58 -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 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 siw_pbl. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Bernard Metzler Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: linux-rdma@vger.kernel.org Signed-off-by: Kees Cook --- drivers/infiniband/sw/siw/siw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/sw/siw/siw.h b/drivers/infiniband/sw/siw/siw.h index 1c78c1ca7d7a..cec5cccd2e75 100644 --- a/drivers/infiniband/sw/siw/siw.h +++ b/drivers/infiniband/sw/siw/siw.h @@ -137,7 +137,7 @@ struct siw_pble { struct siw_pbl { unsigned int num_buf; unsigned int max_buf; - struct siw_pble pbe[]; + struct siw_pble pbe[] __counted_by(max_buf); }; /* -- 2.34.1