Re: kcsan -Wmaybe-uninitialized warning in ntfs3
Marco Elver <[email protected]> Tue, 21 Apr 2026 13:35:19 +0200
| Newsgroups | dev.linux.lists.ntfs3,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CANpmjNOY20G7w3AB=XfwSAQ0EVfM+sOqj1kTq6NnkPiB8Fx11Q@mail.gmail.com> |
On Tue, 21 Apr 2026 at 12:21, Arnd Bergmann <[email protected]> wrote: > > On Tue, Apr 21, 2026, at 11:33, Marco Elver wrote: > > On Tue, 21 Apr 2026 at 09:54, Arnd Bergmann <[email protected]> wrote: > >> What happens here is that copy_from_user() is used in a very > >> normal way to copy a user space structure into a previously > >> uninitialized on-stack buffer. With KCSAN enabled, this passes > >> the pointer to that buffer into __kcsan_check_access(), which > >> takes a 'const volatile void *' pointer. Gcc correctly notices > >> that there is no way to access the data behind this pointer > >> when it hasn't been initialized yet, as both read and write > >> would cause undefined behavior. > >> > >> I'm not sure what a good solution would be to avoid this, > >> but I assume this should be fixed in the kcsan instrumentation. > >> I tried changing that code to pass non-const pointers for > >> any instrument_write variant, which does avoid the warning, > >> but also adds a bit of complexity, see below. > >> > >> Any other ideas? > > > > Indeed, the below is rather complex, and seems unnecessary to me just > > to suppress this warning which not even the whole kernel enables. > > > > How can I reproduce this? GCC version? .config? I can't seem to with > > an x86 defconfig + CONFIG_NTFS3_FS + KCSAN config + GCC on linux-next > > (20260420). > > I ran into this during randconfig testing, I have attached a > reproducer .config here, but have not tried to narrow down the > configuration options that are required for triggering it. The attached .config is a KASAN config, still can't reproduce.