From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9243CE7A91 for ; Mon, 25 Sep 2023 02:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231659AbjIYCWn (ORCPT ); Sun, 24 Sep 2023 22:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjIYCWl (ORCPT ); Sun, 24 Sep 2023 22:22:41 -0400 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEB68CF; Sun, 24 Sep 2023 19:22:34 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R421e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0Vsjmorv_1695608551; Received: from 30.221.128.98(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0Vsjmorv_1695608551) by smtp.aliyun-inc.com; Mon, 25 Sep 2023 10:22:32 +0800 Message-ID: Date: Mon, 25 Sep 2023 10:22:31 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] ocfs2: Annotate struct ocfs2_replay_map with __counted_by To: Kees Cook , Mark Fasheh , akpm Cc: Joel Becker , Nathan Chancellor , Nick Desaulniers , Tom Rix , ocfs2-devel@lists.linux.dev, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20230922174925.work.293-kees@kernel.org> Content-Language: en-US From: Joseph Qi In-Reply-To: <20230922174925.work.293-kees@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/23/23 1:49 AM, 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 ocfs2_replay_map. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Mark Fasheh > Cc: Joel Becker > Cc: Joseph Qi > Cc: Nathan Chancellor > Cc: Nick Desaulniers > Cc: Tom Rix > Cc: ocfs2-devel@lists.linux.dev > Cc: llvm@lists.linux.dev > Signed-off-by: Kees Cook Reviewed-by: Joseph Qi > --- > fs/ocfs2/journal.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c > index ce215565d061..604fea3a26ff 100644 > --- a/fs/ocfs2/journal.c > +++ b/fs/ocfs2/journal.c > @@ -90,7 +90,7 @@ enum ocfs2_replay_state { > struct ocfs2_replay_map { > unsigned int rm_slots; > enum ocfs2_replay_state rm_state; > - unsigned char rm_replay_slots[]; > + unsigned char rm_replay_slots[] __counted_by(rm_slots); > }; > > static void ocfs2_replay_map_set_state(struct ocfs2_super *osb, int state)