From patchwork Fri Sep 22 17:53:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13396292 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C6F9CD4847 for ; Fri, 22 Sep 2023 17:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=5DjQwsp5Gqctf/ZGjvzo2PkXasQNR3EMPTCxykQ1jg4=; b=Q5V6QEwMYwOxQk MxujOlFai3ajuJwHh/GCcPt2jG1Id7Acar4REOVUbWpb622eh6an5jRUM4X33qMzlbFnBBbhBAKGU noXTpjyDw1btguLE6cbbY/n8SW9JhHXJmyzYv1zl0afp+dOjJr5qsIlSnwaC8V056prBJwLiVylDu DX/QAYdlEfWlF/cHNpOv8UNkgP4iTLMrmtqCWnmLl4eAxAGKRcQIA7ST9bSSpzYm4cylXUWFMn6Gb GjFiPB+EASt+AlRrg3gzy1kfVf9iX2MVCsrgYBCYi+B4bMlFH/12FR1IQ4A+xxQzN/ZMIAyqb3E0g 5IOPcRGKcXqr2TPuJ6Xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjkLl-009ZPH-2X; Fri, 22 Sep 2023 17:53:57 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjkLi-009ZOE-30 for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:53:56 +0000 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-578af21ff50so1804202a12.1 for ; Fri, 22 Sep 2023 10:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695405233; x=1696010033; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=C/sXEbgxXtNKYo/L4/vhLbpgVFK4H06rEANzOjtTwNM=; b=Byh7GwELm4Uns2PEv55iZwzEuyVmhSsWzg7C0TDAIU8l7TCheiCmg/odW92q0JyD0P tKeGgpTt9vH0O3Up/MD3u/1C+ObOezdPuHQNl2JGyzjRITkr3LrKc3xJ7iK/TcaN0xj1 ovawyXkb+wnaJ483mE+Bn0ZPHybCPyB7LYCXw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695405233; x=1696010033; 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=C/sXEbgxXtNKYo/L4/vhLbpgVFK4H06rEANzOjtTwNM=; b=cx/f7quLybsNuJtxKceYT5sEUPxLX2SF/lOZVjj7hlEgpKP83adqKBe9wu6LUW6ggZ shDMUQfFenymQG81Ftvg14r89ap4W0gLmTbX0Rc8B4kqNfGEltthiWHYE9LvxFKrxyG0 airXzZAhv268Ab0Yuzz6zf2a6G9Fn+DlIkkRRl+Ne217u0uEXuS1drr/9QUgsHXpH1JH YCZRua8vxusAoxnJprhVJMw+ArFStyu1/Q4g5FjhXUAmVyhOm43coZ1g4zSlT1e1cZ1k UsOTf/tAeLvTkH8tWVR1CJc8vSUf/i7pNpnVo3bSILlwxn3IzL+mtfbHT6M+f8hOs6eF tfPA== X-Gm-Message-State: AOJu0YzW+AHJMlORBISydvN3cKiQraV6pglj6sWsxQc4hWzpX25t+G7q S7Zbi+lITd5y+KKi6++CtU4iHQ== X-Google-Smtp-Source: AGHT+IHjmTLQbm2SiN3w8uyT78a+4tZ23kPyNdMBOXmx6iaVEN70LQnN88b589oOJikCMvI5LcWmIw== X-Received: by 2002:a17:90b:1e4a:b0:274:5e18:851c with SMTP id pi10-20020a17090b1e4a00b002745e18851cmr438131pjb.4.1695405233436; Fri, 22 Sep 2023 10:53:53 -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 15-20020a17090a1a0f00b00263dfe9b972sm5559788pjk.0.2023.09.22.10.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:53:53 -0700 (PDT) From: Kees Cook To: Jassi Brar Cc: Kees Cook , Michal Simek , linux-arm-kernel@lists.infradead.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] mailbox: zynqmp: Annotate struct zynqmp_ipi_pdata with __counted_by Date: Fri, 22 Sep 2023 10:53:51 -0700 Message-Id: <20230922175351.work.018-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1269; i=keescook@chromium.org; h=from:subject:message-id; bh=1poq85ba9j+7J1PLFH3/OUdUEKILRF+ZhAzDjq4Mb1A=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDdSv0B0ZAwn8thcnEoGKGRm6tzJNHNC4p1SKM twNnK6o/LyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3UrwAKCRCJcvTf3G3A JpICD/4s9t+i2GRgZhTVaFg+1WEWAK9XubwciA/mVOtx0WxFwtlB9FKhov7qaG3t9gZ4lzoMrMK 4xct4DPrkm3EJX4D71EADhTvPbCzsPcJVxqrxLdUptg/nCgNrvKVRvigyvw8dJN7CEMKtohXO3p 7+nD+RxwWorUc5zOaJhIUX+OtZN1MgqqXNHH3XlSPRglnMIiCg9uL12FUXGQ9huF9W2+CBdC5/G 2hjhh2JfjT+ZkxCYjfsgakw3gz/B6lNH9B4ESOTQ+JDFCovfy8npuG/lnEPWVl1t3aQDTw+Ggvg Bm2VYWACynNShZlEisvshdeozocThIzZnp5388I/hjsfO3dGJ9NkEg3pYxIvaj3ZXmZZHb5n03c BKxHbmk84rHGRDfnv1JshClFI4fUy+QU4s7tTsjmYwvwvuPat04djCAB27Rmu7eKPVknR5U7Ygm F7Xk8GmbeNyOB8r3/b0z47UjjXri8DcBUSRJ7T5I0bci5BacG0974PRqG302aV0mNoOhysxe2rA vZWNpKUYK81yZ9Tsp6Jo+6YD9HH0bNEwmG81K2w6zbCDokfK2+Bz4UZ0OKcF2YRdqOtvdCWi9gy hbceAJvcoBvTaOPPT8bPQO7sA6TSJxF1xrFLNO+WzUCykLJ1nPq8GXQUBWK44XyhikDJI4Qe+hK FTeA9y1 2E9MSx2A== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230922_105354_970555_46C327EB X-CRM114-Status: GOOD ( 12.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 zynqmp_ipi_pdata. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Jassi Brar Cc: Michal Simek Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Acked-by: Michal Simek Reviewed-by: Justin Stitt --- drivers/mailbox/zynqmp-ipi-mailbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mailbox/zynqmp-ipi-mailbox.c b/drivers/mailbox/zynqmp-ipi-mailbox.c index e4fcac97dbfa..7fa533e80dd9 100644 --- a/drivers/mailbox/zynqmp-ipi-mailbox.c +++ b/drivers/mailbox/zynqmp-ipi-mailbox.c @@ -108,7 +108,7 @@ struct zynqmp_ipi_pdata { unsigned int method; u32 local_id; int num_mboxes; - struct zynqmp_ipi_mbox ipi_mboxes[]; + struct zynqmp_ipi_mbox ipi_mboxes[] __counted_by(num_mboxes); }; static struct device_driver zynqmp_ipi_mbox_driver = {