From: John Garry <john.garry@huawei.com>
To: <kbusch@kernel.org>, <axboe@fb.com>, <hch@lst.de>, <sagi@grimberg.me>
Cc: <linux-nvme@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
"John Garry" <john.garry@huawei.com>
Subject: [PATCH] nvme: Fix nvme_setup_command metadata trace event for cdw10
Date: Wed, 6 Jul 2022 16:16:38 +0800 [thread overview]
Message-ID: <1657095398-114310-1-git-send-email-john.garry@huawei.com> (raw)
For x86_64 allmodconfig I get this warning:
In function ‘fortify_memcpy_chk’,
inlined from ‘perf_trace_nvme_setup_cmd’ at drivers/nvme/host/./trace.h:47:1:
./include/linux/fortify-string.h:352:4: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror]
__read_overflow2_field(q_size_field, size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘fortify_memcpy_chk’,
inlined from ‘trace_event_raw_event_nvme_setup_cmd’ at drivers/nvme/host/./trace.h:47:1:
./include/linux/fortify-string.h:352:4: error: call to ‘__read_overflow2_field’ declared with attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()? [-Werror]
__read_overflow2_field(q_size_field, size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cdw10 metadata is 24 bytes, and we try to copy size of cdw10 metadata from
nvme_command.common.cdw10 into that cdw10 metadata, but
nvme_command.common.cdw10 is only 4 bytes in size.
Fix by making the trace metadata size as 4 bytes.
I find that this warning started first appearing from commit f68f2ff91512
("fortify: Detect struct member overflows in memcpy() at compile-time").
Signed-off-by: John Garry <john.garry@huawei.com>
diff --git a/drivers/nvme/host/trace.h b/drivers/nvme/host/trace.h
index b5f85259461a..d6d35f935006 100644
--- a/drivers/nvme/host/trace.h
+++ b/drivers/nvme/host/trace.h
@@ -57,7 +57,7 @@ TRACE_EVENT(nvme_setup_cmd,
__field(u16, cid)
__field(u32, nsid)
__field(bool, metadata)
- __array(u8, cdw10, 24)
+ __array(u8, cdw10, 4)
),
TP_fast_assign(
__entry->ctrl_id = nvme_req(req)->ctrl->instance;
--
2.35.3
next reply other threads:[~2022-07-06 8:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-06 8:16 John Garry [this message]
2022-07-06 16:10 ` Christoph Hellwig
2022-07-06 16:13 ` Keith Busch
2022-07-06 16:18 ` Christoph Hellwig
2022-07-06 16:26 ` Keith Busch
2022-07-06 16:34 ` Christoph Hellwig
2022-07-06 16:44 ` Keith Busch
2022-07-06 16:58 ` John Garry
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=1657095398-114310-1-git-send-email-john.garry@huawei.com \
--to=john.garry@huawei.com \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/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
all inboxes | Powered by JetHome®