Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp73473rdh; Sat, 23 Sep 2023 01:56:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEo7F3kKQrM1y2Qqkl5sw0xlei/0fXYrjfIEdeERsE0KOfjtfq32PuWx0BrqrBZotJ1QfRP X-Received: by 2002:a0d:e249:0:b0:58a:1326:cb85 with SMTP id l70-20020a0de249000000b0058a1326cb85mr2415067ywe.40.1695459414024; Sat, 23 Sep 2023 01:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695459413; cv=none; d=google.com; s=arc-20160816; b=NIh+XYa2WAy4PMihb4x/PBZUvzBwGwt31L4eGwNv05nb/HchU/vip/lxeE1auAH9F0 mo2ouZoapTzaMgFRniOTcwY3lCjqaE0vUXzLP2oYbqCNkD0KvoP4PAAuSbXgrx0QQXcC Wayq0oMD/begTWc1X+VkjGv6h8uBYpXIzCEuvV8Dh39g4nCzi9qdlMy+W0D9xwMIDgKK dZvnOhN7FhnyBu/Qa6vDpd2A1+9j7QyG2jh7fZkd4OSyUtVQSAC+B/HP4iG6357M0e8A HOLk+01lUtBGUfeSZWOULxepwSeSC6dmI+aG/dpPktbQjvRzu463F5oeXbXIDDsWjaTY wTqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=D/lRQ0WXVvSz+v7TZKaFc3NIx9+fUCClDrP0kWfeqvo=; fh=ulUh/QS0r3jrxON+cEp+z1/oq1RKk+qF6kM6zJTo64M=; b=otyls//DYihmPm1vthCjITri+8ywVPFUuMRc0AEK/V7R8ycFtoHA6OozdxRUS5AzZX WEUbL7MjiUg/TGH9vam434nvTQiA9yUDTPyU2UxW02ENxQngzYPKH9aQlk6ZFgV46CdK EgunfK2LNoS8UT6Cl5gTuMKDGRe9+y1pi59lEPQ14DlYlWy3+T5vFvRYuoASBQ4C7W6j qJd7U6qz3xG5ruOWWU9YRz9o5A6XHadWSdjjr+jHxT8dEThQtbvx4xQPHx7u6iUt5cnp TWSih088gjuY4FYyhz1KF3Cf3LCO42T02G9gqr9Nnim/6Iuejt7dRozNtVFSyun8Y/5i +SAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n2YDs08U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id t1-20020a17090aba8100b00268278c51e3si7564111pjr.49.2023.09.23.01.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 01:56:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n2YDs08U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 912D380978AB; Sat, 23 Sep 2023 01:56:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230479AbjIWI4x (ORCPT + 99 others); Sat, 23 Sep 2023 04:56:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230204AbjIWI4w (ORCPT ); Sat, 23 Sep 2023 04:56:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59862136; Sat, 23 Sep 2023 01:56:46 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52DD3C433C9; Sat, 23 Sep 2023 08:56:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695459406; bh=j34XWsRtTEQvDT8yovbT5KAH8v3D0pMnExUnWFgILrA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n2YDs08UwYjWsRIIMNaAGfvG3tdOpu+9bTHEAg95idaYKlyqUX9yDMZZqX6eQlT2K nKXw0Ndwku3LoOTSS3AJXXnoVQY7jz7TjSzlHykwqQs7jMWu1yKlOHXMkU5xUBSKDq 21PmLUMcz+D6gvKD8bTZkccUvW1VvnxdqvqbSSq7tbon0qV+L26ywHwSRyT7ShQcvl r8sLgAwxc5Cac8zzm3J1SOovzMLUlaC4TvmWoYicjswSVJZIdxrW5CcR2kPrUrjM96 rsSQac5U7YsTlC+xIsriw/hNbwvBsmh8cZ+lkayBXtcmwptNMKwrHxPRoS9/ntWYYr 5uJDhbw8C+8zQ== Date: Sat, 23 Sep 2023 10:57:47 -0600 From: "Gustavo A. R. Silva" To: Kees Cook Cc: Maximilian Luz , platform-driver-x86@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] platform/surface: aggregator: Annotate struct ssam_event with __counted_by Message-ID: References: <20230922175436.work.031-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230922175436.work.031-kees@kernel.org> X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sat, 23 Sep 2023 01:56:52 -0700 (PDT) On Fri, Sep 22, 2023 at 10:54:37AM -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 ssam_event. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Maximilian Luz > Cc: platform-driver-x86@vger.kernel.org > Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > include/linux/surface_aggregator/controller.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h > index cb7980805920..5b67f0f47d80 100644 > --- a/include/linux/surface_aggregator/controller.h > +++ b/include/linux/surface_aggregator/controller.h > @@ -44,7 +44,7 @@ struct ssam_event { > u8 command_id; > u8 instance_id; > u16 length; > - u8 data[]; > + u8 data[] __counted_by(length); > }; > > /** > -- > 2.34.1 > >