* [PATCH] [RFC] blk-iocost stringop-overread warning workaround
@ 2021-09-20 13:15 Arnd Bergmann
2021-09-20 16:17 ` Arnd Bergmann
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-09-20 13:15 UTC (permalink / raw)
To: Jens Axboe; +Cc: Arnd Bergmann, Kees Cook, Tejun Heo, linux-block, linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [RFC] blk-iocost stringop-overread warning workaround
2021-09-20 13:15 [PATCH] [RFC] blk-iocost stringop-overread warning workaround Arnd Bergmann
@ 2021-09-20 16:17 ` Arnd Bergmann
0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2021-09-20 16:17 UTC (permalink / raw)
To: Jens Axboe
Cc: Arnd Bergmann, Kees Cook, Tejun Heo, linux-block,
Linux Kernel Mailing List
On Mon, Sep 20, 2021 at 3:15 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> 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>
Please disregard my patch for now. After looking closer, I found that I had
applied a patch that accidentally removed the
KBUILD_CFLAGS += -fno-delete-null-pointer-checks
line from the top-level Makefile. If I put that line back, the warning
disappears.
Arnd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-20 16:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 13:15 [PATCH] [RFC] blk-iocost stringop-overread warning workaround Arnd Bergmann
2021-09-20 16:17 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).