Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp77030rdh; Sat, 23 Sep 2023 02:05:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCHK0Ahu6phvPrT/szdUYOp+kLYueMQeUP3AKmWZ2wEJGJp6/VMbuD0PTsICzQPi8oBGlU X-Received: by 2002:a05:6358:724a:b0:143:9dcb:2 with SMTP id i10-20020a056358724a00b001439dcb0002mr2660324rwa.24.1695459939111; Sat, 23 Sep 2023 02:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695459939; cv=none; d=google.com; s=arc-20160816; b=h866koNwdUfZIZy4Rj0o6x6rpuf2X+Pc845v+zL+xs8YSpN7AgBVJlweUeaVEFFXGl rB0IvQrK8OM1Kf39NK2BK7bi+7NktJGlfR49KUhMHzEaF79cbTrh3Hyv95WWGK0a1gT/ OJn0HW+O1ZcwkE0T7wwdzhCFtwZN0pbPpKpN6xqNSpC18zyxceTSEQ294AsydiI5jnAG 66SQjeQPGPQrg2NgRdMnSqSJxWVcdbpIFmeSUom0lxE037LOijQbOO/ai3uksQCZLfus bh5vB1vi2w+VVwFsfVrCO8b7Lm9mmIHFlPYEow53WNYnPplFFjIjDuyBrP3eICNR9P2V ygag== 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=twzNnpjpVDzT3zmN855OFJXITvGH4u3X/0VNOr/L5iU=; fh=tlhtVMA851O/MH+4zh5bR1jXyZgBSrdLMBSNmTvKnbs=; b=dp2BcUVoUnZ4aTurT2P/CflU9AVYqpB5LYimSwO2zztf4d2hQMc1LcKvoXTD1YW5/g UZHGvxF6ub+ZlQM7eioRs75jfBiHTd3tvfmH2+6JDT+BVUrSTI2GOlf4acMq2YUv097Z yxGU7VZznaniwcwGpXaeSsAF+ZlA4jXXaj1dfvym5QRWtxPvUX3KIk7+lqmIQDOgirZL P3AEPD2OIGV6EQL87gUzwGztkrm7N6VKzCptafwFDoOdU7kOFo++tNwCgKL/aH5RuNvL Hu2YLBe9nQBb2dchUAO3R9TLJhChPmOBvIbIfq7t2y92c6DBT1txrfqERoTNAqik9z0x WZXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RVwSdE+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s17-20020a656911000000b00578c4e244easi5683470pgq.791.2023.09.23.02.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 02:05:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RVwSdE+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 7DF8485BF609; Sat, 23 Sep 2023 02:03:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231281AbjIWJDM (ORCPT + 99 others); Sat, 23 Sep 2023 05:03:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231259AbjIWJDJ (ORCPT ); Sat, 23 Sep 2023 05:03:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DE29CC1 for ; Sat, 23 Sep 2023 02:02:04 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A854C433C9; Sat, 23 Sep 2023 09:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695459723; bh=1wubkG7ScgzJloOTfB6qo/zH9IOKqKxVD813hWAMOMk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RVwSdE+tm0lpxlsWqXhaGtF2ducIVr9x3cxZz3wj1JpSqVnElQJ2JluT7yRQq72qC In/LR+xCLTgdJ7GVOXWdq0pPVjp4DmxNLYW1wQ8rXMY+aBQfN8EHTTBo6pENBRU24u IyT8bUspR70T26/FHiAbnuSW7wRsQoOE1/CfjUbuMhSmuH+xwLZWpzjX7NB37uIkuI 29zgjWACFqp9ruPRugwyqA882HiME30/Payb0oZ0dyImZg2xupSPlOA5UAhg6iot38 m/uoO6xmxETVcYUx9nEywcM4pX1yGrx7+XVj1kP9dIhweVDWLxmYmab/kS+E8y8Pts 6nsleciA65S8g== Date: Sat, 23 Sep 2023 11:03:04 -0600 From: "Gustavo A. R. Silva" To: Kees Cook Cc: Andrew Morton , Shakeel Butt , Roman Gushchin , Johannes Weiner , Michal Hocko , "Matthew Wilcox (Oracle)" , Nathan Chancellor , Nick Desaulniers , Tom Rix , Yosry Ahmed , Yu Zhao , Miaohe Lin , Yafang Shao , Kefeng Wang , Qi Zheng , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] mm/memcg: Annotate struct mem_cgroup_threshold_ary with __counted_by Message-ID: References: <20230922175327.work.985-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230922175327.work.985-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 (howler.vger.email [0.0.0.0]); Sat, 23 Sep 2023 02:03:18 -0700 (PDT) On Fri, Sep 22, 2023 at 10:53:28AM -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 mem_cgroup_threshold_ary. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Andrew Morton > Cc: Shakeel Butt > Cc: Roman Gushchin > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: "Matthew Wilcox (Oracle)" > Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > include/linux/memcontrol.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index 45d0c10e86cc..e0cfab58ab71 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -143,7 +143,7 @@ struct mem_cgroup_threshold_ary { > /* Size of entries[] */ > unsigned int size; > /* Array of thresholds */ > - struct mem_cgroup_threshold entries[]; > + struct mem_cgroup_threshold entries[] __counted_by(size); > }; > > struct mem_cgroup_thresholds { > -- > 2.34.1 > >