Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5692809rdb; Sun, 17 Sep 2023 08:05:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwe/rFKsjibKpoXZYfOoG6UWIEHi0dAO3SkU/tvYqGZDy7pYoBKAUws+wh5grRzZmXNG+h X-Received: by 2002:a05:6e02:b42:b0:34d:ec9c:7321 with SMTP id f2-20020a056e020b4200b0034dec9c7321mr9129157ilu.3.1694963109666; Sun, 17 Sep 2023 08:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694963109; cv=none; d=google.com; s=arc-20160816; b=GwwdcNCR8QumFvidoKFjDKNR7hQXvBId/THBG7Bc417UliWc6At7XtB5ljnXGY1m1P 15Ost3TX8RAtlGk3W69vDlq6Js7I939UObRHF+E3YycE9TgYsmGT+S9IfYuSRJK+paES yi0duEQ9H+ndloZbzm5RlQPaRTqCkYb/ipXUKh3OelZY1kgbzjnxpheXqNJzv7b+yBdo mH3QgyOqO/MSCpkDZyH4M0DksRyOIlQzD1tpn5M/1WyYJPJTHEpR4JlXEIdKQqW+Q0Bq J3Q4KXseMWKddDFXBB03uZVQu8U++BLoLrd1dcSOBj5jUVB2iV29oevX7YgcjpkILc+g TVFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=8jxQHPKBRDtWTBk6GLjc3DCKW6Vg10j1VStPkXrSElw=; fh=9oBDKjd0RB5LapN47yJ0qQdMqq8rnQudMlmMbT5m0TM=; b=PVGO9tycaLsQ11POBXV+CG2wgr6i33l0wKA5uKBK+1UAJWqm35xv6fFyDtgnf7n0pp HHOTZmEVpZjDquWizBQ9J/iShAysNp7FX38PgG9BMQhpJqJIiNG68WrrbWP9AESjv6e5 vn7ofCzTGdgcbGQVIBexFPfLAaaBD87XZNqdQ4Hza9aA9NN4IrzcO5opaU73qm27HZg9 m/Rmnak/33IXi0xk2kHtdMn5zMis3qQ3Tuf01NXb7uKelb55BSueHFo7rL6PC2ugoeHJ OwYx3v8HxJGXYraVOV6ES4vpGoRg0RWrdPwGrp+C4IYHeLe76eahxTsepvXgufu1NJuY Yfrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id 131-20020a630289000000b00577f8bf64adsi6420899pgc.318.2023.09.17.08.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:05:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 49DB0820BDDF; Sun, 17 Sep 2023 08:05:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235663AbjIQPDs (ORCPT + 99 others); Sun, 17 Sep 2023 11:03:48 -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 X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:05:07 -0700 (PDT) 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); > }; > >