Received: by 2002:a05:7412:1703:b0:e2:908c:2ebd with SMTP id dm3csp1391455rdb; Sat, 26 Aug 2023 00:01:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFBY/p8ig8dzSUDV6XLN8pxWuVAw7qkjGN0FPD9K6IH5SXJGnsL695dJahfMxy8oSbqs3nq X-Received: by 2002:a9d:7d98:0:b0:6b9:1af3:3307 with SMTP id j24-20020a9d7d98000000b006b91af33307mr8067450otn.17.1693033280023; Sat, 26 Aug 2023 00:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693033279; cv=none; d=google.com; s=arc-20160816; b=i94etOLQseg0hjZEbXwdqze+ixPZJ91mMJB5M5dOJeeriS6fu7R58p9L3CMOhZf2Ys gftJ2oke4XyCpWoIkxkT3dzvAMjjxi/fTMDmfLfDGd3F7MnL96pOBxHeCOnq2/ZXQ6DG 7F1ddRsI3cBC2mo8QrOUCiqDXoje4wZK/KZhZmi1HVMaTtPKhoAiaxN4RfFHBKJA2CDx WXWolYdMBL6G4xGcXjogVzKEUdWgBY8GRgHJlCW3/wxFCYZ4L0k3LCKqcODpJZVKTInU 9R9p9AIKMJyZtkVoXnIzDVZChYzmECxmdXg0N6aimNJjQmzMsO9PZydJIZBUyRqUjLHm FHZA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=l/Bq9V5UQsgr3PwgKilwe5Nqwpg2esjzaMDOKzsNJV0=; fh=XtaiP+uMUYLMWYxaz7H2cZT4fc1IbsQhMOwDP9kXotU=; b=PHyhv6O2lctSSBDUcZRCslcygMFUjj9D6AI7qmkjji7luiTqYGo9JozYZJUBF8+IXh szXdEVRDbfHSrBQt1vRuAAH5WebngrXB68zGrHF31q0AJ2co/lX54+Le0vbliW9YS87C snGnwENxNK7ujUZktwJ3xrtmxm1fksFzY0tiRcsP8PZDrikLhz+tRbhLTo2iphmcx5zg s8eeVXsoBfkb8+v5tNJj+OyTFL+/ykVu1AADckaSGpdRa86ybPmV3IcZW6p0VzMWhsDX 6sJadFs5r30ecrfGeuAB04HHRWGqDAKs/EkOUTDiombaF3vl3f5GSaz3To3Gn7R4cw7h EDsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FSgNX7cY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a637e4f000000b005654b3ead4bsi3154495pgn.402.2023.08.26.00.00.51; Sat, 26 Aug 2023 00:01:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FSgNX7cY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231488AbjHZAzK (ORCPT + 99 others); Fri, 25 Aug 2023 20:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231493AbjHZAyw (ORCPT ); Fri, 25 Aug 2023 20:54:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 211E826B8; Fri, 25 Aug 2023 17:54:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A776C62E76; Sat, 26 Aug 2023 00:54:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 761E1C433C8; Sat, 26 Aug 2023 00:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1693011289; bh=KunlMoFaeB09wWpK/chJYbgKS5tfp+/UPw8r6E8VtDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FSgNX7cYWf2qXdMFCXD0W7Ors9olo5dw9e/ubec5mBKB8+DJR3PCWeflqAWBrUYb0 X2o1UjfBWV5qTqbf0R8Lyfjk7WbHr6/e9tZbXrkfFpeHMJIEbFRzSPg/1k6AtNDdPQ sZjVeIQtT4GkUioINsligfhNom5WIP9u9+YfPIfsmYXUjEyvo2EUYYVv3xuLnNyk21 hgqTssuXFfgYZNLh61C4bGjExZxsLv6euZ2K/V3DTMdq5nJlvnxrW1MfQtt3V59Tf6 k+j1ErQANSDNyg6LyJNEEX4Nd5fsU4uYXW/KhjIVrr6PExmaSUoyfC1xPXi15w2pPR P/ZFZ5u2L4xiQ== From: SeongJae Park To: Kees Cook Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qing Zhao , linux-hardening@vger.kernel.org Subject: Re: [RFC PATCH] mm/damon/sysfs: add __counted_by() annotation Date: Sat, 26 Aug 2023 00:54:47 +0000 Message-Id: <20230826005447.109776-1-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <202308251426.94092475C3@keescook> References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,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 Hi Kees, On Fri, 25 Aug 2023 14:32:34 -0700 Kees Cook wrote: > On Fri, Aug 25, 2023 at 02:04:41AM +0000, SeongJae Park wrote: > > Commit dd06e72e68bc ("Compiler Attributes: Add __counted_by macro") > > added __counted_by() annotation. The underlying attribute for the > > feature is still under development, but adopting it can improve the > > readability of the code. Apply it to four dynamic arrays in DAMON sysfs > > code. > > > > Signed-off-by: SeongJae Park > > --- > > mm/damon/sysfs.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c > > index 808a8efe0523..36a176f38726 100644 > > --- a/mm/damon/sysfs.c > > +++ b/mm/damon/sysfs.c > > @@ -93,7 +93,7 @@ static const struct kobj_type damon_sysfs_region_ktype = { > > > > struct damon_sysfs_regions { > > struct kobject kobj; > > - struct damon_sysfs_region **regions_arr; > > + struct damon_sysfs_region **regions_arr __counted_by(nr); > > int nr; > > }; > > Unfortunately this isn't supported yet for non-flexible-array-members: > > mm/damon/sysfs.c:96:14: error: 'counted_by' attribute may not be specified for a non-array field > 96 | struct damon_sysfs_region **regions_arr __counted_by(nr); > | ^~~~~ > > We'll have to wait a bit before we can add this patch. Thank you for checking this and let me know. Ok, I will wait. > Thank you for > getting it ready, though! Owing to your previous contributions. Thank you for helping me make DAMON code better to read :) > This support is next in line. :) > > The FAM support is likely ready to land, though[1]. I just tested it > today. > > -Kees > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628459.html > > -- > Kees Cook > Thanks, SJ