Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2952573rdb; Fri, 22 Sep 2023 13:07:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6T72TylJTEXrsL/TIgtN5qlY5IAvQ+7VIQKNlIC41pkMwE4XoHSncO1Hqk/HZ429Q0SBD X-Received: by 2002:a17:903:187:b0:1c3:3347:996e with SMTP id z7-20020a170903018700b001c33347996emr500047plg.23.1695413265873; Fri, 22 Sep 2023 13:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695413265; cv=none; d=google.com; s=arc-20160816; b=WB6hZwa56BDsxoYHkpXkZiOtEaqjfJqGw3Nx4s1XxOgErYq9l05u7l8GYtNfzWBKHp iNdTR8WWud8Jjf5uHC0MUXR3ZjDBnDg+sMg8UWirMVDXm+Rt2Dj81QH6l4FIMngNqCgz JgZCHJj0h3+SP7Tvj/alGjTpbAfnNCpD9dPdmRubN8qrZzFN81pKaVxDVmTf5ox/22Yk EZNIedSauzRMxxpT9EUG5G7BFGGRXm9PcoRk5KMftm5IDVVqsfz0zh2hpgB29fRA/pNb kFqBoCrPnBmVMyyqIPRWG4fQuBo0zFI/9HabwW8BiwEMLvHLFDQ+K4sELPsbV7fDQqDn IYIQ== 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=35gtyXNkaxV1CbWW0mQ4JhX2sryrgmwmW4Qyfs+/hZM=; fh=/3XoOW3UoPyfYD3kmmXY8SGE8j4Y4YAmvvPxykTFKu8=; b=PNiqNNM4MiD5uqgUJIeriZ8ChBGflfGPlvXVAIeSy9jd6b5b4ZuGzvyaKLD9soSINx yEJR69nlhK7XNXZgkZzZNwUqeozPAfL0JhMGr3yHa3dF0BkNdmqsxkXk1U4VCCiXgauC +2xTBcBTU0QeHvjOZ2WhQHnSP9K9EPfUfNUNHvXXWS3HS44JG5HeDgWSQH4kfqpA5X9b LH0w2yslRiD/JAAmxtBd9jNrr+KU8qwrh9eARn4FhQ0YGsaGzZvCttjmokm1w4yIimP+ JyvLKNC25Cltkv7A5LX9KG0vJWDITWYI7JqDzNhXc1CnP0Vl6PoJ9/XCxrQ23C0f+Pc8 4LCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=O1LITAYt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id q18-20020a170902c9d200b001b892a54d89si4153238pld.629.2023.09.22.13.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 13:07:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=O1LITAYt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id C8D4280BD5C9; Fri, 22 Sep 2023 11:05:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233773AbjIVSFo (ORCPT + 99 others); Fri, 22 Sep 2023 14:05:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233855AbjIVSFZ (ORCPT ); Fri, 22 Sep 2023 14:05:25 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CA702D5D for ; Fri, 22 Sep 2023 10:53:40 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-68bed2c786eso2275875b3a.0 for ; Fri, 22 Sep 2023 10:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695405220; x=1696010020; 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=35gtyXNkaxV1CbWW0mQ4JhX2sryrgmwmW4Qyfs+/hZM=; b=O1LITAYt09swLRrJp8fve4IBMIdWFNCx9cj/PVDl+xTVKojkfdkar4gw2RNcJeg0AQ SLGJ7GkgN98SKzK/bT7hWDqC3ziLqT3SnA1Nn/T4aVxNYaPc6hcY7pRVwhmOYgakMvcS mhovKq7rDOgoZwOzpngygNSPNxWdb/o6CMgW4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695405220; x=1696010020; 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=35gtyXNkaxV1CbWW0mQ4JhX2sryrgmwmW4Qyfs+/hZM=; b=MJ00vwjUTnCPkjl2j4Srx8v9ou7DE9miopNKEozyLuozewTGXvVETFz1XBZ1cr47/H KPTHwpOmIXcB8ZCVJIVU78mBsyzMBRyG/D8QDzVSMQpdvWYWaPoElmxdSJOcbx1w6cwA kw++VnlmyN+Gfog9E2YE+AOSnx+D9FZIdOmJBHyiR0/IPualPQ/si16cBQFwM0ngyDZn l31RLjPHuEX0gAO/c+rxT3rEzaddpOtVBYl8FNUW6pCvPF25l1GExXJQffMNwGMwkbMj A4vkSj4pjwtICm9ZwyixyxgJ55taU4xO9myvakh59BeLVdmXQZwRhtKhH0hcA7VtMt8E 0FWg== X-Gm-Message-State: AOJu0YwM9Vx+zoDR8Dn4Gb8danam++EZq/W8R5aLkVYPBwE9T1kNDt9g qKz2nITZgzGF6Sd6GkpPG/AaPA== X-Received: by 2002:a05:6a00:987:b0:690:41a1:9b64 with SMTP id u7-20020a056a00098700b0069041a19b64mr90043pfg.1.1695405219712; Fri, 22 Sep 2023 10:53:39 -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 k130-20020a636f88000000b00563c1aa277asm3380555pgc.6.2023.09.22.10.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:53:39 -0700 (PDT) From: Kees Cook To: Lee Jones Cc: Kees Cook , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] mfd: iqs62x: Annotate struct iqs62x_fw_blk with __counted_by Date: Fri, 22 Sep 2023 10:53:38 -0700 Message-Id: <20230922175337.work.150-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=969; i=keescook@chromium.org; h=from:subject:message-id; bh=40smk5nu73u0vfTxfrOWAC2AnRabVPFAKtr9H6m06to=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDdSierso3cLUCkrGkR7SzFR8Eef9SkFGVBB++ YGtQ3yHy4yJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3UogAKCRCJcvTf3G3A JjquEACNQ40A/dsuVWJtubBKqSUsV0RJy532o2a7KjsWRrhyAnUAyi95GcYxhpG1L2yeF3MdMBy thxxRTReJNGXfQwmqfsJQ1QMrDTWiVR7zXFq5mo7Uo/enLd1chriGNT+rMx1UvBuwOLj05zOchw MSpEKITLwGLx+YA0K02TZ9/3rt1ErYIX0xbTAPHcD+EP+T9uzKev2zNvbMj+kEmK0/Lkh1PVktA zHTyOqFn3coTptKLxDpkMJyWSlBeXb/lrvFYjaa3H45C3osBppBcKPGod9MMJAM/x73a6J5RzZc JfO5z5UsvwydKhrtUS+uoO+uEnIm7d7kYexmfe4FXQvJTMudNyH2MI8q2mXBo378A5PDkKLYeYF Ri2c4Ja+5VeIqpcCaxVGKngmTnT0Omlv6wHBT3zl1sCiRvqdEHf5lxIh+US/TTK+9F1l9ZdKnYv wQcUkUsep2ZxvWKHD/M1kQaxEzuEsA0oyGgO7iXmIW8HySZDT+Ii74EgmLDg+UxG+2xH2uZ09rp 07Qqy8qtTiZdDo7eAptBkGmie70Sn4C2VdJl3XVF31DeU3ZKLNEQwbF1J73d4L61K3oeEtz0x7R IYmgjByteN3WXc4sxL30VJTXfnaZOz56zFsyPX5CmOPfIGOPu1q1pZrn9wEco3Clbbj8y4I0omy GNCQZNPa TRkH0iQ== 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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 22 Sep 2023 11:05:49 -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 iqs62x_fw_blk. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Lee Jones Signed-off-by: Kees Cook --- drivers/mfd/iqs62x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/iqs62x.c b/drivers/mfd/iqs62x.c index e03b4d38fbb0..1b465590567c 100644 --- a/drivers/mfd/iqs62x.c +++ b/drivers/mfd/iqs62x.c @@ -96,7 +96,7 @@ struct iqs62x_fw_blk { u8 addr; u8 mask; u8 len; - u8 data[]; + u8 data[] __counted_by(len); }; struct iqs62x_info { -- 2.34.1