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 9561ECD37B4 for ; Sun, 17 Sep 2023 15:04:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235959AbjIQPDu (ORCPT ); Sun, 17 Sep 2023 11:03:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235063AbjIQPDP (ORCPT ); Sun, 17 Sep 2023 11:03:15 -0400 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CAD8138; Sun, 17 Sep 2023 08:03:08 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0VsCgFuq_1694962983; Received: from 30.32.84.199(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0VsCgFuq_1694962983) by smtp.aliyun-inc.com; Sun, 17 Sep 2023 23:03:04 +0800 Message-ID: <30e6453f-95cc-05fa-9582-6b7447d8e2e6@linux.alibaba.com> Date: Sun, 17 Sep 2023 23:03:03 +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_slot_info with __counted_by To: Kees Cook , Mark Fasheh , akpm Cc: Joel Becker , ocfs2-devel@lists.linux.dev, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org References: <20230915201522.never.979-kees@kernel.org> Content-Language: en-US From: Joseph Qi In-Reply-To: <20230915201522.never.979-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/16/23 4:15 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_slot_info. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Mark Fasheh > Cc: Joel Becker > Cc: Joseph Qi > Cc: ocfs2-devel@lists.linux.dev > Signed-off-by: Kees Cook Reviewed-by: Joseph Qi > --- > fs/ocfs2/slot_map.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c > index da7718cef735..e544c704b583 100644 > --- a/fs/ocfs2/slot_map.c > +++ b/fs/ocfs2/slot_map.c > @@ -37,7 +37,7 @@ struct ocfs2_slot_info { > unsigned int si_blocks; > struct buffer_head **si_bh; > unsigned int si_num_slots; > - struct ocfs2_slot si_slots[]; > + struct ocfs2_slot si_slots[] __counted_by(si_num_slots); > }; > >