Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1018177rdh; Mon, 25 Sep 2023 00:03:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0kE4eAhmCcgYMvnmsy3Ed4kbMggCgBob2od6epYMjeEpTfcgv09I3Bi66+JZnIi6ReAZZ X-Received: by 2002:a05:6a00:1d0c:b0:691:2d4:23b5 with SMTP id a12-20020a056a001d0c00b0069102d423b5mr5822470pfx.31.1695625413680; Mon, 25 Sep 2023 00:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695625413; cv=none; d=google.com; s=arc-20160816; b=iJznUH0jXumkVUghIZCHNfOSOW7ivFrosUgWRuRSXurQIviU5K8s7kvsbuBjpk6GuY 0BqNbgNA8ZAMN0hToYeAt880jP+plkG44U1r1jaJjGztrlxL0Y6DWE2BtG6wDyx1/9rl Jed4ZTTr7q5/F7wCme7hPj1gpFUMM6BSMZWXKAgWTGbIJP7UegmCcfSD/wJvhRvA+pR0 58hQ5WVNJdk7X0ZgFvs3+KDyG0dFzWnXWSudOhWK+O1rrdmFyPoEb+T02yrOga8wI0k6 u5j6dchQG/EFQS0DZL+vFYkqelNh1IvaoL3ccn60fzl32AStycnJVcW0DYCvEhAMkPmG Ijzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=lTOoGUCw3uWyjmNW8EoGz1vCVAx8CcvEB9FrSMMOXh0=; fh=cp21a0AR+/DoSHvj/h0L5nQH3Li1mUQZf3JMlPBiP2c=; b=jF7Egek3maOg3IDAvQd4XCQ4L/dUk7xoHSEBiSAar2D7w7AXKozQWkjVbazDtigUFK JYLUzFhzXqE+mdKN+jd7Z7LxQds8jaFzzqZpAeiUaBCcgR66BTzb1X57cINNpNlT8sjk JFxRqVhxP+amNNV5+34Mnk88U6iWZ+ADCVHBGJNJ+O5lKvXJrezrU6tlauC/p+iv+lO0 2C7lIn2zNaKGIo4R874PzUm1fjN9D4rVUh0B8AxW94ak0qvxqbL86wQOE1UBZzq6Tnm/ d0gaNRHXdLAebBoJoAlzRBoqS5Qd3Hkg7kzjRKExWKm6nU6J6K5ZgK4m8OSKFpFGDJMd Y/RQ== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id t185-20020a6381c2000000b00563de35d397si9058707pgd.487.2023.09.25.00.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 00:03:33 -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; 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=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id F14018042C2D; Sun, 24 Sep 2023 23:54:43 -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 S232214AbjIYGyQ (ORCPT + 99 others); Mon, 25 Sep 2023 02:54:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232142AbjIYGyO (ORCPT ); Mon, 25 Sep 2023 02:54:14 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72B45FC; Sun, 24 Sep 2023 23:54:08 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="412113817" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="412113817" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 23:54:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="777559513" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="777559513" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga008.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 23:54:04 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97-RC0) (envelope-from ) id 1qkfTk-00000000Gvy-13tj; Mon, 25 Sep 2023 09:54:00 +0300 Date: Mon, 25 Sep 2023 09:53:59 +0300 From: Andy Shevchenko To: Kees Cook Cc: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] gpiolib: cdev: Annotate struct linereq with __counted_by Message-ID: References: <20230922175203.work.760-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230922175203.work.760-kees@kernel.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-1.0 required=5.0 tests=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]); Sun, 24 Sep 2023 23:54:44 -0700 (PDT) On Fri, Sep 22, 2023 at 10:52:03AM -0700, Kees Cook 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). > > As found with Coccinelle[1], add __counted_by for struct linereq. > Additionally, since the element count member must be set before accessing > the annotated flexible array member, move its initialization earlier. Ah, hadn't taken into account in my patch, so, Bart, feel free to ignore mine and apply this one. Reviewed-by: Andy Shevchenko -- With Best Regards, Andy Shevchenko