From: Arnd Bergmann <arnd@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: Arnd Bergmann <arnd@arndb.de>, Kees Cook <keescook@chromium.org>,
Tejun Heo <tj@kernel.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] [RFC] blk-iocost stringop-overread warning workaround
Date: Mon, 20 Sep 2021 15:15:00 +0200 [thread overview]
Message-ID: <20210920131516.2437790-1-arnd@kernel.org> (raw)
From: Arnd Bergmann <arnd@arndb.de>
In some randconfig builds with gcc-11, I get a warning from
the fortified string helpers:
In function 'memcpy',
inlined from 'ioc_cost_model_write' at block/blk-iocost.c:3345:2:
include/linux/fortify-string.h:20:33: error: '__builtin_memcpy' reading 48 bytes from a region of size 0 [-Werror=stringop-overread]
20 | #define __underlying_memcpy __builtin_memcpy
| ^
include/linux/fortify-string.h:191:16: note: in expansion of macro '__underlying_memcpy'
191 | return __underlying_memcpy(p, q, size);
| ^~~~~~~~~~~~~~~~~~~
I don't see anything wrong in the code itself, so I suspect it's
gcc doing something weird again. The only way I could find to make
this warning go away is to hide the object using the RELOC_HIDE()
macro, but this is really ugly and I hope someone has a better
idea.
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
block/blk-iocost.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index b3880e4ba22a..51f641840ed9 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -3173,6 +3173,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,
ioc = q_to_ioc(bdev->bd_disk->queue);
}
+ ioc = RELOC_HIDE(ioc, 0);
spin_lock_irq(&ioc->lock);
memcpy(qos, ioc->params.qos, sizeof(qos));
enable = ioc->enabled;
@@ -3340,6 +3341,7 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input,
ioc = q_to_ioc(bdev->bd_disk->queue);
}
+ ioc = RELOC_HIDE(ioc, 0);
spin_lock_irq(&ioc->lock);
memcpy(u, ioc->params.i_lcoefs, sizeof(u));
user = ioc->user_cost_model;
--
2.29.2
next reply other threads:[~2021-09-20 13:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-20 13:15 Arnd Bergmann [this message]
2021-09-20 16:17 ` [PATCH] [RFC] blk-iocost stringop-overread warning workaround Arnd Bergmann
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=20210920131516.2437790-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=arnd@arndb.de \
--cc=axboe@kernel.dk \
--cc=keescook@chromium.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@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