From patchwork Fri Sep 15 20:10:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 140661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1295229vqi; Fri, 15 Sep 2023 13:13:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZg/N6+ZwaWcN4+w4WgKJ6H/25nhTlT6ETcE4FagOBwAtr3APCBRkZwESwGNdylzjE8P3G X-Received: by 2002:a17:902:778d:b0:1bd:fa80:103d with SMTP id o13-20020a170902778d00b001bdfa80103dmr2282595pll.25.1694808837786; Fri, 15 Sep 2023 13:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694808837; cv=none; d=google.com; s=arc-20160816; b=qlNWJ9TtyB54LveJUQ4V9ku/vGP88QEPLakF1zyD6/Jfvd8fXBKazWkOCjtAwBf/2y TZ7Yqf91EEx3hJsqEYRMRkxaRueOxhtf9ijPLW54wj9k5xCCsq454xbuFW1zVjnnFzQg edu2ykmdfUXS4Sjs/+CCwg/KpRTfnFlZU3Lz/SIZcvSf63rM2keS8LwECkxMWZTHBvGV 7IqbqAqbOXGg4cPqPlXbfHeTcSZc+KTUFF0mefiTtlRCXRFgxWZoPYrs/cEaLCoXBNoK 2LGWOnMDqBNbmcEmDhpue8AXkJb/roFVLmlzNMaPgtPE+x4Tr5NHua9uMqTgSol7ywCH Fjfw== 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.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id a13-20020a170902eccd00b001bf0ad16519si4105908plh.513.2023.09.15.13.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:13:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; 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.36 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 pete.vger.email (Postfix) with ESMTP id 152108022C31; Fri, 15 Sep 2023 13:11:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237214AbjIOUK4 (ORCPT + 29 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 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 pete.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 (pete.vger.email [0.0.0.0]); Fri, 15 Sep 2023 13:11:37 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777135872137604839 X-GMAIL-MSGID: 1777135872137604839 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 Reviewed-by: Gustavo A. R. Silva Reviewed-by: AngeloGioacchino Del Regno --- 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,