From patchwork Fri Sep 22 17:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13396290 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 AD510CD484A for ; Fri, 22 Sep 2023 17:53:04 +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=87IDP7WvDjWcf+YTM1eWeUXuwY/JfW6opzQn6pctp4k=; b=hhM6KPg0jrZFrH SzdinwmTEIoSCxVN7UytNOx0S+qG48Pmv9qvCMP4FZceoo/Rs2cDA0fckTJ1N+oH9GoxwfSekLiDW ie0KjjAw3NR1Dfc2h52uO33UxeNIBClKPJ9pkUReQkYQIgnBomH0jlpLFcAHJ6hShe1T51ACGUDA7 H1KGCdVkyuyVdVXy+hu9TGpCzQXnU2aRstcg2yo4wReHqIFj7Ft2GmW+ynBx255Fq2KXkhFTzidSw HEd6g9ZNq3rj9O05EejaZQQG8Go9wj4jgsjJzglB6jXYxyi1TBPhbsqC+7LkBXfF43IbMpVQVp5mA W6r3zmfhsMb58k91Vq6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qjkKX-009Ysz-2E; Fri, 22 Sep 2023 17:52:41 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qjkKT-009Ypj-2o for linux-arm-kernel@lists.infradead.org; Fri, 22 Sep 2023 17:52:39 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68c576d35feso2262675b3a.2 for ; Fri, 22 Sep 2023 10:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695405156; x=1696009956; 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=ZJdLYVSWRxq3AIlS4Kyz9YBlE5nYYkWXarwNDO1ghNY=; b=Ijd90M8Vf6ZEK8hMtMhlDiQKVH7uJwcHWQZtspTXsCmn7i/zwADUnf/SYxew3xbUbT aNpfQ8ajxI5pOrnS7Thp4En1KgAmfredvbROhG4wyG5CRQZkCmZi5+EZA2KTzu1oa/7O 3PjlxhhSB7DJDJXXulJZaAmc0fVe5pXdWnsUQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695405156; x=1696009956; 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=ZJdLYVSWRxq3AIlS4Kyz9YBlE5nYYkWXarwNDO1ghNY=; b=I2j+BrUFehjCyBAAeiFAuECQMA3eJ8T4xT+oNMgHqqH/LUR8I5w0oR6SDdbdHbjKz6 EZDHfKbirPneHPbHySu+6kytgH+zVC0cKO71U2sJT2oqeJBZ/FKFccQS+dTI+9RStfnl R5S0jDUnlZHpGGxqRyKgY2urQpH1MaRl/yuNNvUc0/G1gTUAoQcpkTs9O1enbWtcCzth GapNQ7GCub9AN5vkiEWdi9QKGTeXD2Sf3wcz5ZnZGeAamSJ9Nl4Q+IYvSPWKt+yO2+CG U7UJkZ/EzwVZpGRxqgZZkI6UQ5qkexTj+v92iO2hXQs0XHw/MMzxdINZE4H3hRxDg3EY +iPg== X-Gm-Message-State: AOJu0Yw92B7j4X13jyJs9RpJdmr6W/8rDgeg7+ToWuPuN3XQWtrLnUPh xHSBR6UAoVqFxFQU/Sd+jdgsgg== X-Google-Smtp-Source: AGHT+IFoQrSp0SiFF6qLCBvHgOfTOrpApeeY7D6DEhe0wY4aS5rS++y/hvFvRE1hRHq+xbkNHBtrKg== X-Received: by 2002:a05:6a21:3392:b0:15d:6ea0:82da with SMTP id yy18-20020a056a21339200b0015d6ea082damr339756pzb.33.1695405156459; Fri, 22 Sep 2023 10:52:36 -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 s24-20020aa78298000000b00687a4b70d1esm3453975pfm.218.2023.09.22.10.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:52:36 -0700 (PDT) From: Kees Cook To: Liviu Dudau Cc: Kees Cook , Sudeep Holla , Lorenzo Pieralisi , Rob Herring , Yangtao Li , 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] bus: vexpress-config: Annotate struct vexpress_syscfg_func with __counted_by Date: Fri, 22 Sep 2023 10:52:35 -0700 Message-Id: <20230922175234.work.134-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1359; i=keescook@chromium.org; h=from:subject:message-id; bh=3PVI9STddT1UYeIAqa7UhvgteCrsOUq0jUn/ld5S1vw=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDdRiLsX/0CwUbyt/VlYPcyGDAI+9ukcXqigL5 VN0fQ0VpkqJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3UYgAKCRCJcvTf3G3A JkGEEACWR8ueSvd6K6fybEhvi0LAyEorYYtD45WON1Xxm4nFzcoie++vcc65U3s2vBo2Q+Ca6Hv 3ZlC4gOLONusN/ab1KT6HRYpnvJ3kav1cG92LF06cpQ1sJM6wmecTH9Z/tS/SycFLTUsIiR+fRx VYnTm5uuM8vTCvMMXoiJkxhwIWd5huI93hNq/4b/1hrZiKkAFxT9fQV1bTpNpzze1+0V6hrdHbX pZHHEP4xCGvwBY1r50vXi5jevgIbjCNQ9ZDO3HM2o4FOVVmsudLOzt0DO4EQZYPBeGfKzRA1dDm 46X09cXsawNxRUH9HeOn8+g+A1+QGMy4embVLeal2qjyAve/vCfwlr9PUlRYdcgVDsuPD1SLK8O YNO4CerpAmMXWOQqCxOnk98lIz6diCC7o25PAmFbqg9O/7GMYymae6IbxT92aTG9xxtmFs+NL0P 67f6B8yIoj4ViQNWe4c6XqTiMxlAsWuELYoSodTUiuA7yqXjwvFOtw1iOpyPogRQ7mAxjVMxYlN Wkmhjs3gY00bdzo7/b6dZ9vCmHH8xxnvDWNqtcr8TOt0bJUNv0ZtzRK2F0DrgUrtcfY1cv92fAe j28xJqCPhn9eeB0YArMpn7Z8rk6viQHx2tOeW59Cc8rUZc5r+NplUk4pxad20p/nYkd8v4n93u7 rwdVR3q sgzoqcAQ== 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_105237_939975_F89C8A6D X-CRM114-Status: GOOD ( 12.43 ) 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 vexpress_syscfg_func. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Liviu Dudau Cc: Sudeep Holla Cc: Lorenzo Pieralisi Cc: Rob Herring Cc: Yangtao Li Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/bus/vexpress-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/vexpress-config.c b/drivers/bus/vexpress-config.c index c4e1becbb2d2..d2c7ada90186 100644 --- a/drivers/bus/vexpress-config.c +++ b/drivers/bus/vexpress-config.c @@ -54,7 +54,7 @@ struct vexpress_syscfg_func { struct vexpress_syscfg *syscfg; struct regmap *regmap; int num_templates; - u32 template[]; /* Keep it last! */ + u32 template[] __counted_by(num_templates); /* Keep it last! */ }; struct vexpress_config_bridge_ops {