From: Nathan Chancellor <nathan@kernel.org>
To: James Smart <james.smart@broadcom.com>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Chaitanya Kulkarni <kch@nvidia.com>
Cc: Kees Cook <keescook@chromium.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Keith Busch <kbusch@kernel.org>,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org, llvm@lists.linux.dev,
patches@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH] nvmet-fc: Remove __counted_by from nvmet_fc_tgt_queue.fod[]
Date: Wed, 26 Jun 2024 10:06:05 -0700 [thread overview]
Message-ID: <20240626170605.GA66745@fedora-macbook-air-m2> (raw)
In-Reply-To: <20240529-drop-counted-by-fod-nvmet-fc-tgt-queue-v1-1-286adbc25943@kernel.org>
Ping? This is still relevant and I don't think this is a compiler bug
that would justify withholding this change.
On Wed, May 29, 2024 at 02:42:40PM -0700, Nathan Chancellor wrote:
> Work for __counted_by on generic pointers in structures (not just
> flexible array members) has started landing in Clang 19 (current tip of
> tree). During the development of this feature, a restriction was added
> to __counted_by to prevent the flexible array member's element type from
> including a flexible array member itself such as:
>
> struct foo {
> int count;
> char buf[];
> };
>
> struct bar {
> int count;
> struct foo data[] __counted_by(count);
> };
>
> because the size of data cannot be calculated with the standard array
> size formula:
>
> sizeof(struct foo) * count
>
> This restriction was downgraded to a warning but due to CONFIG_WERROR,
> it can still break the build. The application of __counted_by on the fod
> member of 'struct nvmet_fc_tgt_queue' triggers this restriction,
> resulting in:
>
> drivers/nvme/target/fc.c:151:2: error: 'counted_by' should not be applied to an array with element of unknown size because 'struct nvmet_fc_fcp_iod' is a struct type with a flexible array member. This will be an error in a future compiler version [-Werror,-Wbounds-safety-counted-by-elt-type-unknown-size]
> 151 | struct nvmet_fc_fcp_iod fod[] __counted_by(sqsize);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> Remove this use of __counted_by to fix the warning/error. However,
> rather than remove it altogether, leave it commented, as it may be
> possible to support this in future compiler releases.
>
> Cc: stable@vger.kernel.org
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2027
> Fixes: ccd3129aca28 ("nvmet-fc: Annotate struct nvmet_fc_tgt_queue with __counted_by")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/nvme/target/fc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
> index 337ee1cb09ae..381b4394731f 100644
> --- a/drivers/nvme/target/fc.c
> +++ b/drivers/nvme/target/fc.c
> @@ -148,7 +148,7 @@ struct nvmet_fc_tgt_queue {
> struct workqueue_struct *work_q;
> struct kref ref;
> /* array of fcp_iods */
> - struct nvmet_fc_fcp_iod fod[] __counted_by(sqsize);
> + struct nvmet_fc_fcp_iod fod[] /* __counted_by(sqsize) */;
> } __aligned(sizeof(unsigned long long));
>
> struct nvmet_fc_hostport {
>
> ---
> base-commit: c758b77d4a0a0ed3a1292b3fd7a2aeccd1a169a4
> change-id: 20240529-drop-counted-by-fod-nvmet-fc-tgt-queue-50edd2f8d60e
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
next prev parent reply other threads:[~2024-06-26 17:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-29 21:42 [PATCH] nvmet-fc: Remove __counted_by from nvmet_fc_tgt_queue.fod[] Nathan Chancellor
2024-05-30 6:41 ` Jiri Slaby
2024-05-30 17:23 ` Nathan Chancellor
2024-06-26 17:06 ` Nathan Chancellor [this message]
2024-06-26 17:19 ` Keith Busch
2024-06-26 17:23 ` Nathan Chancellor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240626170605.GA66745@fedora-macbook-air-m2 \
--to=nathan@kernel.org \
--cc=gustavoars@kernel.org \
--cc=hch@lst.de \
--cc=james.smart@broadcom.com \
--cc=justinstitt@google.com \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=patches@lists.linux.dev \
--cc=sagi@grimberg.me \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox