Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5018137rdb; Fri, 15 Sep 2023 22:40:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEilOz0YKQX7qvOZAskJNffbd8lFum2GLPT7Mb1hVomI/ol7UiJkvmnpJfeV83Hqll4JKdD X-Received: by 2002:a05:6871:706:b0:1c4:ee87:d3ea with SMTP id f6-20020a056871070600b001c4ee87d3eamr4191601oap.36.1694842848768; Fri, 15 Sep 2023 22:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694842848; cv=none; d=google.com; s=arc-20160816; b=CfB6GpAHLGqEZbhsCLBn2X4iAVYpsgromfnn797BL6LQK/fNiY1KiiHV+9i7E5299b rJY0UXKQdS+0u5GdLcW+DpjKUkbCaGBfCrvJ8fYxmjwDOc6YlZAqgcrd2JG2gfk892Yi zyPrEhI0nf8heEBZdHFpvCTIiIgm3XHe27SC7VtGO1AKwv0M3QiBdG735Nz+SXc8Yc0j jX/aPCF6mnNjz+M+xj5ml4J9F/wAv1t9njf5ETSAwLaZunJFiAtMGcCzCCLfkWU3Z3/W gGAYuEvtNIyeHsy6P82SGh0Z7EnCGA5DMq6g2kUQrPuSzQCvWjnGGomspIrm//L7kwtD bM6w== 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=Nk/nOdWGEwQoqrorI1M5M4fwyDhM0MyESikBhRPJynY=; fh=r+hzNCJNjZBhBnwT56Rr+FsW7xZvUmXrASgy00ukr78=; b=wOfxwP0n0cs5qg72rdQ+q+t8nOyciJvCN8E87r6OSidQ6BYqAy7vjM/z266+l4p07o MB1E/S3VsU03HH15uL7ELspu+AcedTmTKQiB7DHH4EidqWh1Bc/Svv09GeE5cIPQxQ45 cvtz7mygYUESIy+VaT2HCnPGvh+ZLN0XHk3z1L7iFvouGq06+PYeH5YN4E3JB1zt/MpK Rvy85ghh3TxxtCoxR6ONwfnRBHYtlQGOCTQ3SC3KRT6tkxDm3wH6uY+j2KyttW9MCVvv mGIoATRxkO04H4Gwt9oU/vO4wjyE00kSH6byKMWQN/1SRBlSiOwP0wo89RRpaMx0CowF hfDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GoXo+IQu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id z2-20020a656102000000b0056f7592d732si4294616pgu.424.2023.09.15.22.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 22:40:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GoXo+IQu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 248C9809925C; Fri, 15 Sep 2023 13:10:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237172AbjIOUKV (ORCPT + 99 others); Fri, 15 Sep 2023 16:10:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237295AbjIOUKJ (ORCPT ); Fri, 15 Sep 2023 16:10:09 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFBD610C3 for ; Fri, 15 Sep 2023 13:10:00 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68fbd31d9ddso2138857b3a.0 for ; Fri, 15 Sep 2023 13:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694808600; x=1695413400; 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=Nk/nOdWGEwQoqrorI1M5M4fwyDhM0MyESikBhRPJynY=; b=GoXo+IQumbCh93lMrBeK1O7HBstJmd6H2DeRANwWPg2DLSCVbkK0gy5yFtTg95KYAg pMZXG8lSp4/RaWR7OQH/CW5NMO7ogkaRm7zZfoFIYXO/UlVv76MWHShxPn2846QbNmQw zzyYtesLZ7KqU7cov2metdcauBd9/3pM8Sr5w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694808600; x=1695413400; 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=Nk/nOdWGEwQoqrorI1M5M4fwyDhM0MyESikBhRPJynY=; b=rnthfYDZavQCHEZcLssMJrZ4Z01egyydHdkH/MHVakwVcuiTLRUCTbrlcnFiCDQ3BD nE8dfgCZw1nsMXqTRPWTE74OKVDRTIErAqAVBV1wVFnhxgfliE45ZbgaZl2xkXZZNwJ4 jMZO2nAj9feP3eNj5p+gQvB0nMpXXBVqoKI7DYnhlxtc846wQZMvuCb70LdtiySuWMfb JisAoTRHuUu7OGBdrVMeVjNSrjZdxEGmQgSzP/3+mjq/rsfDd1ZpQJn2hf9wH9sSa5Am M2k31uzA0jSuJojf0+/NmVRYYgIC5J08DmTCGKRsiY1c8pvAT7RZz+XzJjR3cw2lSvbl Reyw== X-Gm-Message-State: AOJu0Yx6Gjoy8etovuRKv5Pn0NyNAsGWPnmR9BKpDXmx8KehUxwJJc8c cZi5tmBYJYYl8l0T6KxfP5vmkMiKZyBw/Qxj+8M= X-Received: by 2002:a05:6a20:9193:b0:130:7803:57bd with SMTP id v19-20020a056a20919300b00130780357bdmr3001465pzd.3.1694808600453; Fri, 15 Sep 2023 13:10:00 -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 j26-20020aa783da000000b006883561b421sm3321766pfn.162.2023.09.15.13.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 13:09:59 -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: el15203000: Annotate struct el15203000 with __counted_by Date: Fri, 15 Sep 2023 13:09:56 -0700 Message-Id: <20230915200955.never.871-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1207; i=keescook@chromium.org; h=from:subject:message-id; bh=AuQmhyKilUvoXwglsma/MaTlIjm+821tEBgc3NFI2G0=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlBLoTgbluNuEb1ppIxCDVPhVSRR03x+HRH+wGk TRaulMR7I2JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQS6EwAKCRCJcvTf3G3A JmYoEACdL3vVF2NKECABdmlrHoQg7GoQpORVNGSD7el8DAMl2SBhoB09PyPXllokTqK9Wdil8zV zZPIhIGvvUg5oG9N/OMZs9AwUK+CMQNWBG1YsP6za4n0V2TaobBHGIJmhYbBfcYx8ZgAp/bSWN+ TvG9AQpwF5p5NuHck+/CfHURygXTJpYCHco/6y8qBEuIttCFIsytyfX2AQPbQuSvDyoVXAcfxjb iaKhvLFCMqVMnBmihmv6mFyiLZfARMGlfrvAAO642M46+/rMmAx0Fg0TCkLZDrmOwoOXUqiV4kj BJSWoBKjM0hUxo0fXw/Ha5n6uDjLsZ9uXNh6cszZO9Dx1z1bCrAWDkyIKpryVLX4ZF0Xn2MZSD9 y2tF1ooPUPeZHIFOy+ZdXVrUI5Hrcgq6J/85H2zltLR30GOyvTV0cl4wD6vz7T1xZz6JT0jN//L tBY+QCaBMaB2e7UPPX6ivy4npGZRvC93WHEHwYZ7pRXA6aDkDEL91tLzVdMdPeGvNvybrASe8sN vwcfhZhL+89ozR+go0DF8VBaeAuHatpbKYiUM39R3IB+Lvn5c3v8fUxPUHvkZDJEvD0R7u8gsqi tFykTaw5+cMlZFoLrXywMsHcXVrOccqZEt+dOi9SCZnr7CvdKlmoHc+hTlyIOli3HNATBr5UqqP pJ1mVkd qJDn93uQ== 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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 13:10:51 -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 el15203000. [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-el15203000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c index 7e7b617bcd56..d40194a3029f 100644 --- a/drivers/leds/leds-el15203000.c +++ b/drivers/leds/leds-el15203000.c @@ -80,7 +80,7 @@ struct el15203000 { struct spi_device *spi; unsigned long delay; size_t count; - struct el15203000_led leds[]; + struct el15203000_led leds[] __counted_by(count); }; #define to_el15203000_led(d) container_of(d, struct el15203000_led, ldev) -- 2.34.1