Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2961725rdb; Fri, 22 Sep 2023 13:26:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYYrSik8y3ZumBlLPejOUXk/0s+LaFplJjafwsfK+y9EMhhvhtq5UevEqD49/d/RnJAGpU X-Received: by 2002:a05:6a20:9499:b0:13b:a2c9:922e with SMTP id hs25-20020a056a20949900b0013ba2c9922emr586655pzb.27.1695414415520; Fri, 22 Sep 2023 13:26:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695414415; cv=none; d=google.com; s=arc-20160816; b=yUHpZWVdi8SYCpDsPK9APfLQZbGcDfMdwbNikpyLfiSlURPvkerI4lrFjzuSkg+Sqz Qj9buBPIM/G8d3OF1sFr3TfT6qUCO2A4SNum5FLRD3VrhA3N03yVJw0k17wM+ha+8QlQ blLrsvfUneLWzo9Ues+SM8xSMAIZ6SwRykUlUJDORLUoFFNB7fDi4U3qb00siYOyytuU Mh+7a69DHDYAvCucCncxdz9NBXQGa7IdFgfwcy3dHOqEKRCbaLVHnwWh5KhyGExNKViC eAnqNAoFLqwRgU9K4M1r4QjZaNwBfXKU6fH0GKAx0+l373RPjjNZCd5TBluA2fKpYrsn 8/Bg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=q9ccZOV4wJXlK1yFnxfHkMmpmm5GjHprdns1OiYQeHs=; fh=aDdnc+0M3i+VxkizuZqMBHAdCDhIv8hgsCHoxIGPxQQ=; b=DMPlT86lhviuGoLCDSUpQUhnhlH7a4GM6e26cKGhf5xB+B9JaA/54473aDcSEIaS+V v7Zf6s+ek9HuUkiTUxMIOW/zNxMkgvS8LCohFMOG2QM6MNKSqmuayDyArUgPCXahHMM3 hmaoaVB+87yYeeWH+Pw9NqgmtdY8U3s8xZbzOqUE+Kzz3Nl/ByC4S1Em4JjMBBRzVFd8 szXffC+LUgF5tA1WZ4NgCrQD9NJRBtVk6bD5UmXrbR9hALhk58PUePj8iV6RK/gpUds1 30P/tq65eqTSZs3AwoR6qcnfJ5ttmbspC2AT5AmtZzFPlclYUuAjboxeohtWVHOp0ImN lDhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mhDigjpM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bk21-20020a17090b081500b00274af8f26adsi2977081pjb.1.2023.09.22.13.26.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 13:26:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mhDigjpM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 719AF83A068B; Fri, 22 Sep 2023 10:55:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233938AbjIVRzX (ORCPT + 99 others); Fri, 22 Sep 2023 13:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233551AbjIVRyr (ORCPT ); Fri, 22 Sep 2023 13:54:47 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4095FE4A for ; Fri, 22 Sep 2023 10:53:03 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-692ada71d79so759049b3a.1 for ; Fri, 22 Sep 2023 10:53:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695405182; x=1696009982; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=q9ccZOV4wJXlK1yFnxfHkMmpmm5GjHprdns1OiYQeHs=; b=mhDigjpMnPomAqxSjmthdpH57fBDW9P1d28FRVYKrhsE9Fjf4rPFmSmAPpXpb7VNy+ rcomVXL1K8KQ4Cfbg1I0Ix6ytiNnv0AvuMhmPEdVrTxNNsfRN0/lLsfxZtlOeVe02qPF izoYuTErVI0eLJh6yS38YSJSU2Zo5YFyIt7LA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695405182; x=1696009982; 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=q9ccZOV4wJXlK1yFnxfHkMmpmm5GjHprdns1OiYQeHs=; b=FUvyuby+fi5M3KGyfpjCS+yrM4YISSru9cWOSDt8CXBprrAGhbhssfh0+KAE2jIwq7 AVK+3IYf4j+FynZ5R/z/UfGWdIfR8VaixQKcvA/At0fF5tKCYU62u9fm+cTrU+FZQaf5 QCExcxv6gEEypjgz8IYhGBYUKmA4S+g5YdtlZwc3BAO9iFSvw4VEffYJWn+vkfpzff3N QHtCkA8s9bTHp6iG5eIdGrSiDJgNJ3N7G/1M5Kxdh6/4O7Oz2rtKHxbBuwM1ixuBQcMS aLKyjlZcHDrgoaogeOAhiBqgRbrLkUkDU1jv27Ed4n0t5okadMzNy1hUGhIfhSWW9mKi NwVA== X-Gm-Message-State: AOJu0YzqyC1zuR7kfm0BI/ZzfRTFWQQVVdpbMd41820/7FRSvMWASi93 LAS/Odo7FhXd5TayO+gNplUOXg== X-Received: by 2002:a17:90b:4b41:b0:274:24e2:ae6d with SMTP id mi1-20020a17090b4b4100b0027424e2ae6dmr488925pjb.0.1695405182538; Fri, 22 Sep 2023 10:53:02 -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 n20-20020a17090ade9400b0026d214a2b33sm5282306pjv.7.2023.09.22.10.53.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:53:02 -0700 (PDT) From: Kees Cook To: Bodo Stroesser Cc: Kees Cook , "Martin K. Petersen" , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] scsi: target: tcmu: Annotate struct tcmu_tmr with __counted_by Date: Fri, 22 Sep 2023 10:53:01 -0700 Message-Id: <20230922175300.work.148-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1187; i=keescook@chromium.org; h=from:subject:message-id; bh=FcaqXSByARe51bzBFiEiVh2BnnpT/BBlX8W8UQ0HgHI=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDdR8Qv/J3bqK5P7cmRhrII3B2LZASbyQAyA/V nNid9mBmhqJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3UfAAKCRCJcvTf3G3A Jro0D/9SbPtkx/9xM7Efr9UP/3joE2Y0lZEmWygmLAqD2wmplBii27xBBzcka9Uvlq1eDy6NPZz 15amMxCkOxtoyTUxf2LYIBBwp8oQciqljhl1QavRXe6Kh7TQ5k3iicvPs6855GbkvKedFiZwwSj 8yVK+Kr6dThjxAuB13jJJiG4GSLwNNY+aR/xd8mO8IRggrA6HKthh87050we6/xUIirr4NrP/as mj0sWZWn23E+oyDlEqYo9LfcWXK5wF1fufUtJI7gM3HGbno23z3KZj40UinLjjpWr7/+X3cuKqi tl4tAkLR4l8pJkbeae3XBKfldgCSlup5ikSsrs64Q9vizG2VDolJqvqsEId2nRDMq/jOPOEDj5n wC5TsygAg+uTkNInLbH/YrYCiQxS8GfDi1meIX/9fP+QYrUJZK9VY1NyIYNf6NKbOIn9J8pH1Ck nK4NzEzQ2JQxslkNUbKHZh+yxC9Hh3zGUXQufo+VPvTcj12siRravIlT+3aBOptBWk1Q4EKButa t2HY95XpdBSlIKQlWz5RfDhuBaJ/xSvIp8f0PFiHikB1k/wnh44KD50Fg3P7KznK8wt2u4CUJ25 RU94tM9ytkUe0+jHbWeoNyE7yQF+VEqUGzugtV1DbEKOQj5A+P7rta6k/V+eddKflkPR4geULkM JLgPdRk HsTcVXeg== 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,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:55:38 -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 tcmu_tmr. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Bodo Stroesser Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org Cc: target-devel@vger.kernel.org Signed-off-by: Kees Cook --- drivers/target/target_core_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 22cc6cac0ba2..7eb94894bd68 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -201,7 +201,7 @@ struct tcmu_tmr { uint8_t tmr_type; uint32_t tmr_cmd_cnt; - int16_t tmr_cmd_ids[]; + int16_t tmr_cmd_ids[] __counted_by(tmr_cmd_cnt); }; /* -- 2.34.1