Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5908893rdb; Sun, 17 Sep 2023 19:07:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENMAaVfCXyoqJCpsuHF5PTDDGUJ1Ji1n0eTzDotnIrTxYu8tz36sLkXVRlZ4bw6VNTNh2e X-Received: by 2002:a05:6a20:4304:b0:145:6857:457a with SMTP id h4-20020a056a20430400b001456857457amr7718508pzk.4.1695002839414; Sun, 17 Sep 2023 19:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695002839; cv=none; d=google.com; s=arc-20160816; b=waIdNsqOgNLZRESXQyD4TQfBDRxLnu1Nw8Hzuxfm6JBMWQSiGrK4RRW7FgCGDzqxd7 dA523nAusR+30qQadR8+mob+8nsTNpIYoEpf1b+T4PslRj93HkQFYnmCpMPG5Jj9e1om 5f0AI7JlvE32eIq0JpXC0C+PnRcgwCEO05vU6ulduB/p0Syl8UvAENwRGvNedTFyzT/o 2Zahi1XcfCn37C8Ot4uSbzOPKuE8nWxus+QGs6fxMAmVsdDeNIozdwwhaErCCCiaXX3i W2eFqu+2+OiMgBIPAUcAah+WtSkEk+PnsXpzrYYEjAnrLpfTPhwgvo0DXx+jR3fSoOGd kOCA== 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 :message-id:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature; bh=FexgrK1d3vcZEwM/YBQYeyTSrSI6pxZbfLCVl0sHv74=; fh=lg1U+8qVSToLC7U8g4h6ok+KScC7OyCFdY8EVv3fbB4=; b=zm3fjR6k7pKs8yZ0C7CKtIf2TRqUE5sGODN6ItgLlYAOWWMz4Nzn3lfvMYucqGbAg/ DBNVLECw2uFgBEPzedO1/Qpg/UEU/R1OS9az3nDU1pllTp0AW5MolYP43CzlaJtgXhqD K2RClKFwBssYso9+WK3GoHDuZz6nVUKa4Rsr8xriotD2P7gUGuQvc1wNzgwWWcOxAjhK LOmNSa+SO3vsallkHvLC4l6sQsyMFNJwM1hMQ8g14V7IZ//nOc6ACtoVu3Oe3z42Cn/+ gcUhQeV6tKXV8+LzPr9qS24MFGMuKMXRbLGpRJAQy6I+IBX8qHOYymrN4jx6gP9oXRf2 +TjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HUAbS/TC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id fa25-20020a056a002d1900b0068e2cf2161fsi7208361pfb.155.2023.09.17.19.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 19:07:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="HUAbS/TC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id BC04480DCCA3; Sun, 17 Sep 2023 19:07:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235059AbjIRCBU (ORCPT + 99 others); Sun, 17 Sep 2023 22:01:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236197AbjIRCBF (ORCPT ); Sun, 17 Sep 2023 22:01:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C04E97; Sun, 17 Sep 2023 19:01:00 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC020C433C8; Mon, 18 Sep 2023 02:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695002459; bh=P5kbmZu6oeMbM/PnhQwtSFCxSpJ/ktMepMBX4j4Jido=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=HUAbS/TCe7nPwq9iMY0e26ipjFoUiBffiD5fT7l2g3TaWQyMdO6TQtwxPrAL8OAyA tOx6KNswGmyoE1K3q4YUgvR/3c1Maio31BPI5X+1KK6j02difk4fccVLavTCwm7O8v VcwoQnPM1mbeLHUxZUmguNzib4JS8g9ky5cgwrcOL5tYfEo6buOuPJ8tvmkjwrLhgH f8OeEJfCCkwVsiSuHfZC3wWCcIWzkheG+zFPJ941VYLeKvHmvZhECqiX+rjG21HYbe asL6UhTSv7j2kSuOq8eAeFq+yXT2tqyWWUCBfECV951LtP9WzNMdeAvPSkMTbnTPnK zl3YvI+dQttEg== Date: Sun, 17 Sep 2023 19:00:58 -0700 From: Kees Cook To: Xiubo Li , Kees Cook , Ilya Dryomov CC: Jeff Layton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , ceph-devel@vger.kernel.org, netdev@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] ceph: Annotate struct ceph_monmap with __counted_by User-Agent: K-9 Mail for Android In-Reply-To: <3c4c7ca8-e1a2-fbb1-bda4-b7000eb9a8d9@redhat.com> References: <20230915201510.never.365-kees@kernel.org> <3c4c7ca8-e1a2-fbb1-bda4-b7000eb9a8d9@redhat.com> Message-ID: <6122C479-ADD9-43A8-8EB6-CF518F97F64C@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Sun, 17 Sep 2023 19:07:14 -0700 (PDT) On September 17, 2023 5:25:10 PM PDT, Xiubo Li wrote: > >On 9/16/23 04:15, Kees Cook wrote: > > [=2E=2E=2E] >> Additionally, since the element count member must be set before accessi= ng >> the annotated flexible array member, move its initialization earlier=2E >>=20 >> [=2E=2E=2E] >> diff --git a/net/ceph/mon_client=2Ec b/net/ceph/mon_client=2Ec >> index faabad6603db=2E=2Ef263f7e91a21 100644 >> --- a/net/ceph/mon_client=2Ec >> +++ b/net/ceph/mon_client=2Ec >> @@ -1136,6 +1136,7 @@ static int build_initial_monmap(struct ceph_mon_c= lient *monc) >> GFP_KERNEL); >> if (!monc->monmap) >> return -ENOMEM; >> + monc->monmap->num_mon =3D num_mon; >> for (i =3D 0; i < num_mon; i++) { >> struct ceph_entity_inst *inst =3D &monc->monmap->mon_inst[i]; >> @@ -1147,7 +1148,6 @@ static int build_initial_monmap(struct ceph_mon_c= lient *monc) >> inst->name=2Etype =3D CEPH_ENTITY_TYPE_MON; >> inst->name=2Enum =3D cpu_to_le64(i); >> } >> - monc->monmap->num_mon =3D num_mon; > >BTW, is this change related ? Yes, this is needed so that the __counted_by size is set before accessing = the flexible array=2E > >> return 0; >> } >> =20 > >Else LGTM=2E > >Reviewed-by: Xiubo Li Thanks! --=20 Kees Cook