Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp201813rdb; Sat, 30 Sep 2023 00:41:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/3CB669pbieSGYaGTVjiomvt/VsSUVsKffVod6Txv0ukyZHEY+I9nCcHOcXFHvojbneHC X-Received: by 2002:a17:902:c081:b0:1c6:1611:e540 with SMTP id j1-20020a170902c08100b001c61611e540mr5964916pld.25.1696059696239; Sat, 30 Sep 2023 00:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696059696; cv=none; d=google.com; s=arc-20160816; b=nAmYgkpxfaddU1Czv1rrLj9AuYghpug+WOItpWMuG45f+dlObOzDHWA3s901qF/YZZ J26+5wy6N3oU/0+Lq9vp3UiPYCXoXqowrbtCKAJJZoK2tUBAIs2mMaxsKnzf6Aoxych7 2aITaeVoo2tRy3e7LNKtZGc7x/EGWD/JxXOlhB6aWuADg68hzVnchLZVetF3sw3WJ2WP Vo5Tg2ZhJuOhgq9f1fQq/J+qgmW8CooOrFsCF7y+2/by6KUJp+b6qwndYSu9KSLuWI4U 8DjdoYMV6lrjBaW5n+bNVRN4qXNeo5aTR2lMF9qgxIskapD18qd0/Kgs63OaAM+Oo9DL biyQ== 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=bQWutlCB4bHLvq/a2I2458S6BRe72rUYx34sxiTinJw=; fh=zbo21H4lIEWks/RKHf+lKrKgyYDfhQ4hUdWYS86850w=; b=Fk3Ur5vtgUaiGOWTCRQ1XoBriAI6H+DeCwbTVjDFrYfqaUBnAB/xAisuZKwlZAcL6w i418CneiLVPVkD4ko7hVGXVbu+4smqLBISG8xaC3yvB4QjOSBsFCcZtZM+asyYqxrEob zgRXgZ06gWOlmBgXF6/XwgK3gUJICVTho60XePT5P1DsKeJh25IWz78NZYZoSXIaTLkQ IGHl16Buwc1KvRMnEPKdb48i5jHSddM+8FVrc9RI9FoICHV2WXgvfYw+QEHMCYEkACHH VM0pHLDdac5OVxm42PJDKg2VVL2B4Tk4fsvC/GvJX0NFuPGRqsgWn2OluxAX+UqOdlLh pgJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eApxWndl; 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 Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q15-20020a170902dacf00b001c434b3659bsi24458594plx.354.2023.09.30.00.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 00:41:36 -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=eApxWndl; 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 0972C801BFDE; Fri, 29 Sep 2023 11:05:44 -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 S233807AbjI2SFZ (ORCPT + 99 others); Fri, 29 Sep 2023 14:05:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233835AbjI2SFG (ORCPT ); Fri, 29 Sep 2023 14:05:06 -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 BF798CF1 for ; Fri, 29 Sep 2023 11:04:35 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-68c576d35feso12742043b3a.2 for ; Fri, 29 Sep 2023 11:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696010675; x=1696615475; 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=bQWutlCB4bHLvq/a2I2458S6BRe72rUYx34sxiTinJw=; b=eApxWndlLNXcLGDI7qdNZZXvHgci1hddOTLOhu2ZPumPdirclzCbXrx/UzYxxuK0eD p2z0XYHuVas4oelrIZMhfDyeUFbXATdjTD9Ogue+SYg/G1AyWb11seS0QDRvbzupQZX1 zELlgXbgnnC0U5dllKFjhO7JuB9eI0OPI1Qpc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696010675; x=1696615475; 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=bQWutlCB4bHLvq/a2I2458S6BRe72rUYx34sxiTinJw=; b=ESwJNCEZ/D3X/qZo8MzAqC29ZS8OQ9/QCEzuMIUwT7VPsZdIJHpXhniDTdMBdKTJw6 kHXN7ZCZAKRMI98giKMqEIlLQGdBG2ugXUe3VCgCqqvXj2phlekGE8z4qjfhzDEMtVJM dXWEaNcE7ZBD+1He4lsnUXzNN5diej0BO8LnU0U4D/1IB8IADsilehwSWT0RUcLbmNRQ JzIbeNflUG/ST6k4y5MOf9gL9dp7a/bo86GVO17Eh+6ELdL9cNb0Jna8xmghRFRNuc4H wTt96D321NNG5kiqSrojSXRKq/3qDXebrvWAU0pQWKLgZ4iY1IGebUADR4lvy2KJ2qES xR+g== X-Gm-Message-State: AOJu0Yx6grKdwOZOZzGiemfXa6KjVWD6LLR6eIaM3PfhFWBCIHLO/2Y/ sErb6qC2G3whCDOIDXmtfg3L5g== X-Received: by 2002:a05:6a20:8e12:b0:161:28dd:c09d with SMTP id y18-20020a056a208e1200b0016128ddc09dmr5598820pzj.15.1696010675201; Fri, 29 Sep 2023 11:04:35 -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 c16-20020aa78e10000000b0068c61848785sm15228538pfr.208.2023.09.29.11.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:04:34 -0700 (PDT) From: Kees Cook To: Jason Gunthorpe Cc: Kees Cook , Bart Van Assche , 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 , Bernard Metzler , "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 5/7] IB/srp: Annotate struct srp_fr_pool with __counted_by Date: Fri, 29 Sep 2023 11:04:28 -0700 Message-Id: <20230929180431.3005464-5-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=1220; i=keescook@chromium.org; h=from:subject; bh=f7YIXZ1Qz/PkvmeFE/JHjleuWcRLUOMOaQc0DRTvzX0=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlFxGu9/IB5ROJ/iD1IoxO8XdZ0HuofI5lXB9aL 4bAV2SnX/yJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRcRrgAKCRCJcvTf3G3A JoxWD/0ZjY+XrVB7gRnT53mKtziWVn+VsfedclKqQTgWGlk9obHRRC5h+bABdwKSf2M/x0wCQFH mVEbvAQDpHgR+Dff6jNIv+1QcHHO5DEpLiYDrFKCu1/+V+cLcW3uIl03j4j6xaJezo6eOsw7zsV qHzukxETpc8mlb33IZR04S4xPeQwpdejzndnDFde/ViDV8t7iidPzE4mWvdYon1+2aPCgI7eBj7 bDR2OEb2yciSxCKdenFa3rByvJjqQPe6KHlxylQVLI29zQl5R+r/Sj4Z8gKsqvOBTRFFL8iQkdf TGtYluwh/Ok9tXHWmhOgxLEGkSuf3GZXYI+1zMXmpbcd1EOuD6WN0sZs5M2+FWQS/ZkTn7pzuR3 Qqc3lS05bvXdyE+BCBVWVGygCQvfDP5e2QbVTnBFC5yP9AzrhU9jErH+oUyQu+gLRyZGKGudIo6 ZhmGK2XtDlfZi0gaOKPQBdxkczkTLGAZ5NOKJQ+3k3WAfZ/7Xgg7NYu7Jdp2BudK2CvN5uRrond /rlpeDTxx2K62/qlY2LI7OmJWB7Px2i5bSW5g77AzDdVNvqzIRyg4mgIKNvjaYTCoeRWVCGCb9X cfBJppmtpmPQhtwSnT8SALM8cw5PP2q7Rci6HUL9dTUXHDHKCIQW1muP+rHVMhXbvap6GSo1vMt 1AjoxAt0tusmfDA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit 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 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, 29 Sep 2023 11:05:44 -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 srp_fr_pool. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Bart Van Assche Cc: Jason Gunthorpe Cc: Leon Romanovsky Cc: linux-rdma@vger.kernel.org Signed-off-by: Kees Cook --- drivers/infiniband/ulp/srp/ib_srp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index 5d94db453df3..349576ff3845 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.h +++ b/drivers/infiniband/ulp/srp/ib_srp.h @@ -306,7 +306,7 @@ struct srp_fr_pool { int max_page_list_len; spinlock_t lock; struct list_head free_list; - struct srp_fr_desc desc[]; + struct srp_fr_desc desc[] __counted_by(size); }; /** -- 2.34.1