Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4988744rdb; Fri, 15 Sep 2023 20:55:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7JksWZjrLyZ31EPNUmNN4DZoNuXid00UPHpkLTaB4M7T0iMDp71bVykNiBFOEOGssbJWY X-Received: by 2002:a05:6a00:1490:b0:68f:bb02:fdf with SMTP id v16-20020a056a00149000b0068fbb020fdfmr4112424pfu.27.1694836552955; Fri, 15 Sep 2023 20:55:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694836552; cv=none; d=google.com; s=arc-20160816; b=vqJmwaY5jpuqs4V5HQqGs0OUs9GxqWVQIQq39kFf5fxGn2NfFiuQTI4tvPQshch9NA THE/O+Pp3PQFW6PFH6539u1c4M7kfGcqb5Rqr97c0oGiKtec/1yhZMZWRpJfAwAyq3XW GHdgcJHlAjeBwZu7piqRkjiqBTzP9dQjVP3YotYy2YYQVIDEcx9x5iUMvnrRPibnZ3sQ RAJiJosdCnZbY4ybuq2l7QhW39uCU2p4+repGZ0cUuFPmbxwJgT9sjc2Na8IQNHbb4me zEMuZ2pJEy3JVM9SvDP7aT80WyxrjrsIErKz/FTyIJj2DmPSa48EaOMnKHGnzu40l7qS 1Wbg== 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=WQVzGWkf7HVCqp2OLBRlKNzMbLz4neMZQx2JbqpcRaM=; fh=r+hzNCJNjZBhBnwT56Rr+FsW7xZvUmXrASgy00ukr78=; b=NoU+ca0Le6OtVF5Ltin9pZ5FcerQNTt7cSujsj2IOk14fzE4ZUwuN9Tknxv6pfp0bt y5raihRwdEkTbkpxKeYtmDPkdcYuK+tWCaLWmWiFUeRShtM0GFqZ4N7ylKg6jP9mmUGz ocsfOJ7jCnHzRvtdDQ11RDSQfQlMKH0JTr7WSdYjXQcnp9Korx8Ek2zSCjHSVKGNfsQ5 rj/lc9rQ7/gUvCjjq8nk8+MLFcxpW8GFh8svz3gKiDrkL7OPaKCTYUOhHNqJC9cPI4um p8Db3BZuTBaQMRPReC0ZinhJtxju2t+z74FRwEZtzKwvjeO5MN/i4m3oSXhr087SSWnM qDtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lt+q7GPx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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. [23.128.96.35]) by mx.google.com with ESMTPS id ca21-20020a056a00419500b0068e2c357ca4si4302092pfb.217.2023.09.15.20.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 20:55:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lt+q7GPx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 2E2FF8073219; Fri, 15 Sep 2023 13:11:00 -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 S237190AbjIOUKX (ORCPT + 99 others); Fri, 15 Sep 2023 16:10:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237290AbjIOUKL (ORCPT ); Fri, 15 Sep 2023 16:10:11 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B202130 for ; Fri, 15 Sep 2023 13:10:06 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-68fbd5cd0ceso2213954b3a.1 for ; Fri, 15 Sep 2023 13:10:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808605; x=1695413405; 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=WQVzGWkf7HVCqp2OLBRlKNzMbLz4neMZQx2JbqpcRaM=; b=lt+q7GPxpB921tTwWGcrV8LRA9Ayx0aYOCsXDLxt9nzla3GPsHC+H393rGekTWjsgv tAmGJgXqXoHiX1NRI/O0TJ/hnS0Uk1TH3+F5ZrqRocr6HcyaUE2V5bN4ffTBmWsVvf0C ZSipyrvv0A5HaWm43QY9jx1ywKKHTr3zcZPEI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808605; x=1695413405; 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=WQVzGWkf7HVCqp2OLBRlKNzMbLz4neMZQx2JbqpcRaM=; b=ErMen2VHpHWtadARD3/+xZjEQIc1/Qxdq3dxIXFTK14ucV8ixn2tAK59swfdC5A0X5 sxSeYZE4ZU44bJwxZaaHOJrtbPP4Qvc48vBpSXt78elmjWZDDwcQBKxI+DXq1K3AX16v uDwHQRECzoUTapvb7//dsOIUHwScv0GV95CH0pzRsdlIj1weCBIiP+TaxxR3SJrpDbeE 6pHsvor5U3PuJ/nqsayLLXv4CBA65r0g8NfZM0JMXH7vrBEMYKz928S5R+nQ30/32PDF al+dLYdKeCwrycLI/5dq+EyL+5suz5YQVgF53fL10gYuh2StRojH/1tT4CMGDmf5w2GR msyw== X-Gm-Message-State: AOJu0Yxdg68w/0VIYn5J5sAq36hKLQlEuVtvHtko0mF17i0iAhEaenuf ZVG89dgFdR5yEF2VZY1g8p/b1A== X-Received: by 2002:a05:6a00:2386:b0:68f:edfd:2ac6 with SMTP id f6-20020a056a00238600b0068fedfd2ac6mr3092215pfc.0.1694808605765; Fri, 15 Sep 2023 13:10:05 -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 v2-20020a62a502000000b0066a2e8431a0sm3327325pfm.183.2023.09.15.13.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:10:05 -0700 (PDT) From: Kees Cook To: Pavel Machek Cc: Kees Cook , Lee Jones , linux-leds@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] leds: gpio: Annotate struct gpio_leds_priv with __counted_by Date: Fri, 15 Sep 2023 13:10:04 -0700 Message-Id: <20230915201003.never.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=1202; i=keescook@chromium.org; h=from:subject:message-id; bh=g02eNjr5fSoURtZM+k1a/ubK96yp9CuHHEf8Va6oCXs=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLoc1T3DPO/feL5xYpcIAm3aABR+QIrhafXXM d7a0I9P3G6JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS6HAAKCRCJcvTf3G3A JgF0D/0dSbBzS492RBJC5to7Z7xpPsdhDREw7ReyYb514AFImFYtfefyrXtgazrHIHNZn4m7Az8 FgRcUDkK3CTgj+V3JKf0wDPP4C/d8PCw+xH7XqaBEW941EUScRUWE2SqLw3gAOc4Aj3IsQJX8Wx gtdUmH0UVn3q5MryLs2McFw1Mq30XRTKc/6Q7uHQmbVC4QCRfzQrtCrM1jDpboifV06dq14KF6l oEr0YDZ0k3Yeou6mJn/tuI572iYKNb8qB7hDVGmwSg02fz7UiXvg7aphfoNO0ryeNiNiSSTzu+M QwKDfckpPlBKFUf6qeZPmQ/Q8bBNMmoADkm4hD3EfjaawXW2FnImRi0badqtgZxk2Xih+NncdqX X4MtYVyYMLdV1NCWkISWWNXMdbThdueTVadzPDZW92YPXEsAL6L0nUH5q/ze5r6ioJ2KdWrrQdB vzkHeQFOeoCSgE9sVl8DKWCb3ZDTD6CSLyTVJ/OJizlcer9Jw0/Xdn3YRlsAd9hvGuF+oupTKV5 YcZ6Q1c8U47QRaqFHPP/dhTiLwlA40dJ0mEMg8nl73LW70H11mjwx92hSY1txdMa10UCv+kb8mQ UjF1ot4h8AOLsczLvc0cp1Uzxv4ncZryevLgmxtwaewWy/o0g8kZ6dCEc3Ga+/7DhGHPSYRBg8K J4iPM9i JX2KsxXA== 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 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, 15 Sep 2023 13:11:00 -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 gpio_leds_priv. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Pavel Machek Cc: Lee Jones Cc: linux-leds@vger.kernel.org Signed-off-by: Kees Cook --- drivers/leds/leds-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 7bfe40a6bfdd..a6597f0f3eb4 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -142,7 +142,7 @@ static int create_gpio_led(const struct gpio_led *template, struct gpio_leds_priv { int num_leds; - struct gpio_led_data leds[]; + struct gpio_led_data leds[] __counted_by(num_leds); }; static struct gpio_leds_priv *gpio_leds_create(struct platform_device *pdev) -- 2.34.1