Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3134508rdh; Thu, 28 Sep 2023 03:53:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+n/YBV9BSM7wVYPIP59eDPJqrN/slguprzLHbi+D+t+cpPajAkdwhM1rXDfemsMyB9187 X-Received: by 2002:a05:6870:b686:b0:1d5:a303:5f39 with SMTP id cy6-20020a056870b68600b001d5a3035f39mr795535oab.49.1695898396748; Thu, 28 Sep 2023 03:53:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695898396; cv=none; d=google.com; s=arc-20160816; b=VWz2HvwYCJgSooRWshdFtg5Vzh67REcKtW090ZieIZpDpeemGzGksP2x0Y4nd76cZk M4vQu0iAlAgN5xFq5YWjCwz9DxpmgQ7YJcbwi9EOsaTcGN3wGOR5f9QuIPU0CyzNnfM3 8CPWej832sd0j0nXKL/f+BfaQQNc/3ZmponUn8ZOCBlBMdwBccXRXyf7Cw2Cqp5yrsrp xpqYbYyUvh+NkTvMLTHowiLKoIogearjCGoYHtWsrvvFhI8ExmFLFL1er9wFa4EtFURF ZSyiD7I4wO8eU3MDxkDmxU+geCXEcda4NjA55OOaYEAXyh5UuRzc3WUA3kqBUr4g/XzB cXIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=mtW2DaDex4/qq5KYNshzbiXk1ZKdWPIH7i0eyiB1QPA=; fh=SG9DcOMOyMi0ah1Ta24uRwesXXBkfBPh4iDBXXitK4w=; b=jdwjvW9FysgDho63o6iwYToNPl27R3Xo4Toi1i1TywOFZ7QPPWVrls9J+xIHp5qr6r h2fGYUZVTIQ7yWBn27FUoIJHZsfdlZadPPpAKd1URrROuU7ZPc+7kgbwD0+cGipSazMs xXWHfveSt7XQbQUs3wSwQCZdXHBKICjEmcOwH/WzrouBnEIM+7t716yCTFHRqp6SXrTP 3ZbRFnzhgNqqjd6aGrN8ul8+XaCpCcyr5boe7lefsgqLe8k0illuscx8JNNDsD87m1WN zTCR8bf9YjzW6NmTJV0c1X/Btc0+g+QcTUQ5npcZyJmFxqPbZNHy3zVF74r4IwPPDZ6m Ferg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=i6y1Vu0s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w23-20020a639357000000b00584af3ee495si7550782pgm.623.2023.09.28.03.53.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 03:53:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=i6y1Vu0s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A6CAB80941C1; Wed, 27 Sep 2023 21:43:01 -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 S230163AbjI1Em5 (ORCPT + 99 others); Thu, 28 Sep 2023 00:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbjI1Emx (ORCPT ); Thu, 28 Sep 2023 00:42:53 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A31A19F for ; Wed, 27 Sep 2023 21:42:51 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-9a64619d8fbso1613542166b.0 for ; Wed, 27 Sep 2023 21:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695876170; x=1696480970; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mtW2DaDex4/qq5KYNshzbiXk1ZKdWPIH7i0eyiB1QPA=; b=i6y1Vu0sfJHLPXfDGY7n6wdXFNbO7UmkAyHcECjLix6U9u/lEnkbRJsaDQqVDc9da2 1JlcNfxTwVnct1seNlZ2w1MSd+ZpvW7VT4pXGlnUZ+7bDWQmcPZTfC3+5+syXO3lnXeC wzaa5BLaAkBuozg+9J5eWe3RIv9Q16nr933238SEFy++aJ2Ga/FgMabys9HN3vnU3E/j aal5HLei0ANKgQxpaQqM6BXC8i4qyFIZ3Bl7EfR4HR6C9iX+r6E4lyb266zTYkiNsEVy IcsGyNcv9lGKIxhaIXGV/p+KyOyISTFLZgZRlDirJ1lpWnF0meK8JoFXF9wRdB/tjYSg 0afg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695876170; x=1696480970; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mtW2DaDex4/qq5KYNshzbiXk1ZKdWPIH7i0eyiB1QPA=; b=O6cZLXoRpK2gWLOqH2p7/cBD7D5Cw7lyMzmMcA9rQr3877OhEOqGogBR5j60Gbri3y cL2DYFjCNW1sfOYedTOipSc//S7+1Ky3qgIJSM2tp3gjm42/TFcILpmQ/66VNXw+nSgn XHnHQJWK9upsXVzRisu20F8t0y+VqaRHZolCIj4jb+WgvlKd17CiSvzGSEBe4U4TTcSg ZNVE55P0V/P+VUe6UqRfW2YQtpjsMyGTtBzS21ciVW4O1OKrJonTXk5ovnlDsZO0kYpy aguFIh9t/Iv1MdsgxmgpbjF/zoQuTrukfHSWINUShZbViPr4VkvkCzidJpKwnnyeftgy ShOQ== X-Gm-Message-State: AOJu0Yw3L7KanBRXORMIE5Z64tvf6A8PdOVYySpZpV5m79QeyZHgTcgF 99FM/5df7qZCZh2JvlU115loH6MdQXNVAtS2P4rmBA== X-Received: by 2002:a17:907:78d4:b0:9ae:588e:cdde with SMTP id kv20-20020a17090778d400b009ae588ecddemr163330ejc.11.1695876169938; Wed, 27 Sep 2023 21:42:49 -0700 (PDT) MIME-Version: 1.0 References: <20230922175344.work.987-kees@kernel.org> In-Reply-To: <20230922175344.work.987-kees@kernel.org> From: Justin Stitt Date: Thu, 28 Sep 2023 13:42:39 +0900 Message-ID: Subject: Re: [PATCH] hte: Annotate struct hte_device with __counted_by To: Kees Cook Cc: Dipen Patel , timestamp@lists.linux.dev, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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]); Wed, 27 Sep 2023 21:43:01 -0700 (PDT) On Sat, Sep 23, 2023 at 2:54=E2=80=AFAM Kees Cook w= rote: > > Prepare for the coming implementation by GCC and Clang of the __counted_b= y > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUND= S > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct hte_device. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/c= ounted_by.cocci > > Cc: Dipen Patel > Cc: timestamp@lists.linux.dev > Signed-off-by: Kees Cook Yep, this flexible array member is counted by @nlines which is evident throughout hte.c: gdev =3D kzalloc(struct_size(gdev, ei, chip->nlines), GFP_KERNEL); ... gdev->nlines =3D chip->nlines; ... for (i =3D 0; i < chip->nlines; i++) { gdev->ei[i].gdev =3D gdev; ... Reviewed-by: Justin Stitt > --- > drivers/hte/hte.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hte/hte.c b/drivers/hte/hte.c > index 598a716b7364..1fd8d2d4528b 100644 > --- a/drivers/hte/hte.c > +++ b/drivers/hte/hte.c > @@ -88,7 +88,7 @@ struct hte_device { > struct list_head list; > struct hte_chip *chip; > struct module *owner; > - struct hte_ts_info ei[]; > + struct hte_ts_info ei[] __counted_by(nlines); > }; > > #ifdef CONFIG_DEBUG_FS > -- > 2.34.1 > >