Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5007084rdb; Fri, 15 Sep 2023 22:02:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0vtELumFRmt4jVQKm3ri1vcGpdgYaVqg0/Vn5MY5Cu6DUSXeFH86fe9kGP6SobhJHTtdV X-Received: by 2002:a05:6a20:7faa:b0:140:324c:124c with SMTP id d42-20020a056a207faa00b00140324c124cmr4170906pzj.62.1694840541190; Fri, 15 Sep 2023 22:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694840541; cv=none; d=google.com; s=arc-20160816; b=LggfbMnAPo6WGci8dZEOO7RkVqHkqHYHntOTCYLyE3Vp+9cQtMB2D1lKfMEUaxRJcE +H2y9MkEPv5VQQ7Y7zPD1AthyUxtZhfe0YgsG1glJBU00dsN6g+x0wgWVK6UZvanTQM3 2EjhpdYbXcBPDxyJrgDQ22q+JUJ1DXIEVxJNJMmTE0wSV9PPJX7uVaqOxFK4IDsfxJnb eb+dGrsEzGgQsi4mgl7aooI6sIM7in2vqutbBhyjIf0ShXfNIE5bhyPMXfytKNsNhZTf qQytQv5nSFcg0YlvkbKNv4FcMCTSnWin6WjDYLRk4VilLJo7+rnJZ/aylOSsQqlDAQkB k2oQ== 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=HlByvIOdhm1BrLrYKlOSPCA/h/JQn1HfpIBfjQs7y9E=; fh=TWhb+Tpky/F1iiseEBLTFpP/iqA3+EQHRq2H08PZ9+A=; b=dl3Ob/okQRAQKA+dFqyWH0DZmxBogTSKARL0sg8ldWaeLJycQ3Kx7MA5u36LiKdF5g TNdlKElPQnoh7d73oVGb2RJEEqmH3H4RjUUxAO68m/MNP+GceW3jSTsrXKdBCsDj5X4w c8dr2ap2jCpFSBIwKD8HqtGNj5hPP1b3oTiTpW8M3Huhoeb36KUld3RJ1jEsyXwDuF+b 5BFCLDJXGtM8gy+iBSWekIXBsXK04cnGSqRVtndl8JjZ7u6eCYJVihh+Oe7ToHoSdvK6 v7feDVpLduPzssjRfCZhyFACpKMfZw7ajS80c0aqOxtpTq8GQyYbmYXLpBLJA3RIQGzv UIWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KO+C4w7k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id pg14-20020a17090b1e0e00b00263e1d9c4f2si4711230pjb.26.2023.09.15.22.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 22:02:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KO+C4w7k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 83E52804C6ED; Fri, 15 Sep 2023 13:11:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237212AbjIOUK4 (ORCPT + 99 others); Fri, 15 Sep 2023 16:10:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237221AbjIOUK1 (ORCPT ); Fri, 15 Sep 2023 16:10:27 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B63F110C3 for ; Fri, 15 Sep 2023 13:10:22 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-68fb46f38f9so2429637b3a.1 for ; Fri, 15 Sep 2023 13:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808622; x=1695413422; 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=HlByvIOdhm1BrLrYKlOSPCA/h/JQn1HfpIBfjQs7y9E=; b=KO+C4w7kTQ37/WFAtlhOF8VlCq/42oW1lbpwAkmDP/DsF48bMVHLQ3qyJegpelb0bK QdOPxw8izVt1lax+wWkhLI3jU/KNvAFZRyNiTkxhe4HDcQMtezTPYEWyRm1ekmvb2tL8 eWypQ/Ot8USDPPDVQ7Swv1ZHujuoo4GtT7tH0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808622; x=1695413422; 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=HlByvIOdhm1BrLrYKlOSPCA/h/JQn1HfpIBfjQs7y9E=; b=f5qGd03VU+5ZBIut/14k6I9fjzqT/eaco+zcuNKFsxPWZ2pU2UevScfi2lMgPcGswK fjy7TkcK6iYi8XB+aph6T62Q9sXBpkNuxYt/tVegsKJl1eFq1s+Koc39kGw6KfR0buHD JayZgBrrml0Qdw1GZM5acUxRhgYrJoSGV3G3DbOHMe7V55ydt8gUlVwOai/IsmdbyfE9 FpGDaMg/7GHGhmWur6UPj2/cUJCoxkJ3tAJ1Q1OvDPFuQrCQISSpKnE+hWkjqMyf8gaf z3FBPycvFSYoXjuSr7iFtFoyOO73D0rwP5bZ2cPPh7pdBpRtkEYC3yLdOWfxhYwKjUmC sRwg== X-Gm-Message-State: AOJu0YygYoOEVIGQso6vWEyqz3D4qHZiRUteTF7g4L9Q4ZPd6c6pRNi1 XGit4KznNasNFpohWxLuJqWFlw== X-Received: by 2002:a05:6a00:178c:b0:68f:ba5d:c7c8 with SMTP id s12-20020a056a00178c00b0068fba5dc7c8mr3263085pfg.10.1694808622247; Fri, 15 Sep 2023 13:10:22 -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 a27-20020a63705b000000b00565d82769d1sm3161179pgn.77.2023.09.15.13.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:10:21 -0700 (PDT) From: Kees Cook To: Pavel Machek Cc: Kees Cook , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Andy Shevchenko , linux-leds@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@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] leds: mt6360: Annotate struct mt6360_priv with __counted_by Date: Fri, 15 Sep 2023 13:10:20 -0700 Message-Id: <20230915201020.never.433-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1575; i=keescook@chromium.org; h=from:subject:message-id; bh=f+enA4agyImbFLGfdmWqtF1Ofn6ogLeO3YPTh9r2ypE=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLosMDTNT9zkGuuSS5/v5hvLo56PnCLrNsfhH 2XWrsY0ncyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS6LAAKCRCJcvTf3G3A JuiBD/9EbeiE4dzQvBsNU8W+Ygxow9+F+K+56pj+lkkL8YD7G9ZLxoEIDtbuf64kthZKeEvjo57 FTUv/48yOAUZDs2LU9/9qiFoSi8L0qj3gx/k1vcVDT/AYShIsS7MZ3/HQRvGeiiUbRHqAv034yb tDCakrDUzz+HFSbIBPQ3hTMf1LrLic/BS6/a9kR+7EerWW8Yc430bzBpznlnZvAvfyudwqApts0 SYDaEwQY3GFNuWa7oZAZBRMc0FKcTHCVkTcQ7+Sz5PQoXaajs2eVpYcNfSrKxHqBVoh74gB8wIS fDSrAqGXttPXJRT3nIVf/NjG12MZ1zW24/t4bDYie6kU2aTNGM/ijQHVjZLDcXTHJXJ/Kbx2dM/ 7gzMy2HDEtF5Vp2mJWeVCfNAS9V80eQ4DGU0TnnWEx4LaQgh0TjoJLRkmZLfonk/Jaf/QTEETCM cIvZM3qzHy85LPkBOxvCtHjO48zKpAuM720fZaw1E0W8xqbkW7VMzWw3m3X/f+rzniUmuJhfHuF pXCw7jO7QP8gNO3BKGOH5MLx0+LBqeE9a8QydO/pnK/gwVGqWfWiuV50WWXFEQvriun5eAgjO+Z UQVj4Ce2Ywi4w5VkhFcUUeepfhCVLdfZN9t9cUXFykt+XBm+eXZJtog2PNj/28wtP32yiyPdLtO wcq5HsY mHeihMBQ== 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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 15 Sep 2023 13:11:28 -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 mt6360_priv. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Pavel Machek Cc: Lee Jones Cc: Matthias Brugger Cc: AngeloGioacchino Del Regno Cc: Gene Chen Cc: Jacek Anaszewski Cc: Andy Shevchenko Cc: linux-leds@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Signed-off-by: Kees Cook --- drivers/leds/flash/leds-mt6360.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c index 1af6c5898343..b70dc689b33f 100644 --- a/drivers/leds/flash/leds-mt6360.c +++ b/drivers/leds/flash/leds-mt6360.c @@ -91,7 +91,7 @@ struct mt6360_priv { unsigned int fled_torch_used; unsigned int leds_active; unsigned int leds_count; - struct mt6360_led leds[]; + struct mt6360_led leds[] __counted_by(leds_count); }; static int mt6360_mc_brightness_set(struct led_classdev *lcdev, -- 2.34.1