Message ID | 20230918091553.1103567-1-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2939778vqi; Mon, 18 Sep 2023 13:40:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOWQjFjjdOwc2CWXD/CE+7Fh927yEjHNc7JPFGUW1I4fNp6Wgk4TEHehhpP2zlWI4cfNl/ X-Received: by 2002:a17:902:ed54:b0:1c4:6ca6:35b3 with SMTP id y20-20020a170902ed5400b001c46ca635b3mr4649402plb.44.1695069644628; Mon, 18 Sep 2023 13:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695069644; cv=none; d=google.com; s=arc-20160816; b=Il2UbPWgrJaxU7zEBqd4Zaf9IW4diX7m51e9sV/W3fbNYKtUnc6EBzAR2M1fVr6pox u0+KqXliTWwpuM95w3nNgM2MtqrOLHiKLoS5pj5iMBfhETEKw8jWPzYScy62JNOG2JKY pNwgqqdgqSK9S8zr/lkdVzsYQ5+dKMKoUMW13/67ksN3z2kL9IGwFDZjq+ZKW4aYXlcP tXiMSAibqRUpLkHaiEoMKPa2Lh6zem1Cmf3s28KwSmUUbgpdHwFnF/LmwPhfQecTKGcR GI/pNMjhYV51WBAHAfyHAPiyrM3+BcN9q49qwifJOBxPIXhau9030jX8ZgthAlDc7DYT wi+w== 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=EbtElBeNsbE4GMIml3vOc6qFz4synkMKkX+l0Phr2SY=; fh=x0hge2vW9GltvbojcRZHmoxNFjuXRZ1UwvGsDK7VfP4=; b=cWdZf+NkMnqbthCetrEm0L9RHoOMyyMNSo5tK8nhwrkQ1h5NaTAVNGNbSubxnYau9J ajxC1A5VQCbNXVI482rjD3GQfp9C95XEk+qy2KjOinHCy4mDlsliY8nwTMwwFtiAvXh/ SikAvjt3UpD35DbLcie7k/kgFp251qV13x9WZms3chX/0bSk+bkr4U67bOaTHlQdGRTE XzWE6pzEn8Px11qImUkT+dBg8YQj8ZO1V/SsiXuZ5apYBZof59SqW2sktvNUefP5k9uE 3RR1lNWMmZ+EIdjDopHEyyqazj3iR1lFbg5CUROxkeYS3nUqBolejnDqcPY8YBzEQnR+ cf9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="IP/9MHh1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id h11-20020a170902f54b00b001bdad5f0f0bsi8867114plf.543.2023.09.18.13.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 13:40:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="IP/9MHh1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id A68598093414; Mon, 18 Sep 2023 02:17:04 -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 S238676AbjIRJQ3 (ORCPT <rfc822;kernel.ruili@gmail.com> + 27 others); Mon, 18 Sep 2023 05:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240956AbjIRJQM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 18 Sep 2023 05:16:12 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C3EA115; Mon, 18 Sep 2023 02:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695028560; x=1726564560; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=HODBa9dvinX682mpZpv2Ai5XBCfJ9WWcaCt3+KCr9MA=; b=IP/9MHh1rjBlQRZIaHpSyD/hlfzkk7ULJGQwmPiYj4M3beR1z78F0KqW YqgAOTpSqqcFofsnwCC3/PLYaBjzJo486zaleoPcWZsSapDmJSWorelMQ C5NXnZmeGUNgbR42yuZqxTj5ufroE7Y4wP37/nrBjQRhsq1mviFCv6CUH 5aNCViR4RtvFEKymtldl4Y2DOpKFdcO1tUIWvQMonDnsrcQc9HrnklfyX /2QLioDZ58evPyxyNlfJhnzRGcLZLsinzd1hukJ7dF7kV44n7hGeJtqSz YJC+d5BlIN2ICYKQjbwyoJ7s8x8pg4qWZcZSpZj+iP3jdpw+M8VxX6C6n w==; X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="382350896" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="382350896" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 02:15:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10836"; a="695455798" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="695455798" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 18 Sep 2023 02:15:56 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 584F118E; Mon, 18 Sep 2023 12:15:55 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Cc: Linus Walleij <linus.walleij@linaro.org>, Bartosz Golaszewski <brgl@bgdev.pl>, Andy Shevchenko <andy@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com> Subject: [PATCH v1 1/1] gpiolib: cdev: Annotate struct linereq with __counted_by() Date: Mon, 18 Sep 2023 12:15:53 +0300 Message-Id: <20230918091553.1103567-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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: <linux-kernel.vger.kernel.org> 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]); Mon, 18 Sep 2023 02:17:04 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777409347523828979 X-GMAIL-MSGID: 1777409347523828979 |
Series |
[v1,1/1] gpiolib: cdev: Annotate struct linereq with __counted_by()
|
|
Commit Message
Andy Shevchenko
Sept. 18, 2023, 9:15 a.m. UTC
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).
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpiolib-cdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Mon, Sep 18, 2023 at 12:15:53PM +0300, Andy Shevchenko wrote: > 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). Kees' patch is better, please ignore this one.
On Mon, Sep 25, 2023 at 09:54:34AM +0300, Andy Shevchenko wrote: > On Mon, Sep 18, 2023 at 12:15:53PM +0300, Andy Shevchenko wrote: > > 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). > > Kees' patch is better, please ignore this one. Oh! I didn't get CCed so I didn't know you'd sent this. :) Thanks for taking the initiative on this, though! (But, yes, initialization order matters.)
diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index a5bbbd44531f..e23f06f58234 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -572,7 +572,7 @@ struct linereq { DECLARE_KFIFO_PTR(events, struct gpio_v2_line_event); atomic_t seqno; struct mutex config_mutex; - struct line lines[]; + struct line lines[] __counted_by(num_lines); }; #define GPIO_V2_LINE_BIAS_FLAGS \