From: Nathan Chancellor <nathan@kernel.org>
To: Kees Cook <kees@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>,
Christian Brauner <brauner@kernel.org>,
Heiko Carstens <hca@linux.ibm.com>,
gregkh@linuxfoundation.org, rafael@kernel.org, dakr@kernel.org,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>,
Xiao Ni <xni@redhat.com>
Subject: Re: [PATCH] devtmpfs: don't use vfs_getattr_nosec to query i_mode
Date: Fri, 25 Apr 2025 13:17:45 -0400 [thread overview]
Message-ID: <20250425171745.GA3071749@ax162> (raw)
In-Reply-To: <D865215C-0373-464C-BB7D-235ECAF16E49@kernel.org>
On Fri, Apr 25, 2025 at 08:40:23AM -0700, Kees Cook wrote:
>
>
> On April 25, 2025 6:32:59 AM PDT, Christoph Hellwig <hch@lst.de> wrote:
> >On Fri, Apr 25, 2025 at 12:12:36PM +0200, Christian Brauner wrote:
> >> > That is: if dev_mynode(dev, inode) is not true some random value will be returned.
> >>
> >> Don't bother resending, Christoph.
> >> I've already fixed this with int err = 0 in the tree.
> >
> >Thanks! Let me use this as a platform to rant about our option
> >defaults and/or gcc error handling. It seems like ever since we started
> >zeroing on-stack variables by default gcc stopped warnings about using
> >uninitialized on-stack variables, leading to tons of these case where
> >we don't catch uninitialized variables. Now in this and in many cases
> >the code works fine because it assumed zero initialization, but there are
> >also cases where it didn't, leading to new bugs.
I don't think developers can assume that zero initialization is
universally available because 1. there are supported compiler versions
that might not support it and 2. someone may have turned it off or
switched to pattern initialization. Isn't default initialization of
variables supposed to be viewed more as a mitigation against missed
initializations than something to be relied on implicitly? We still want
to know unambiguously and explicitly what the default value of variables
should be.
> This isn't the case: the feature was explicitly designed in both GCC
> and Clang to not disrupt -Wuninitialized. But -Wuninitialized has been
> so flakey for so long that it is almost useless (there was even
> -Wmaybe-uninitialized added to try to cover some of the missed
Right, the fact that GCC does not warn on uninitialized variables is
somewhat self inflicted for the kernel because of 6e8d666e9253 ("Disable
"maybe-uninitialized" warning globally"); I say somewhat because I
understand that the warning was disabled for false positives but it does
mean that there are no true positives either.
> diagnostics). And it's one of the many reasons stack variable zeroing
> is so important, since so much goes undiagnosed. :(
>
> Fixing -Wuninitialized would be lovely, but it seems no one has been
> able to for years now.
I think clang at one point had a similar problem to GCC's
-Wmaybe-uninitialized (it is -Wconditional-uninitialized there) and that
is how -Wsometimes-uninitialized came into existence. Perhaps GCC could
explore something similar to help gain back some coverage?
There is another big difference between clang and GCC's -Wuninitialized
is that clang's -Wuninitialized will trigger whenever a variable is
guaranteed to be used initialized at its first use, regardless of what
control flow may happen between the declaration and that point, whereas
GCC may turn it into a -Wmaybe-uninitialized.
https://godbolt.org/z/MYxeozc36
Cheers,
Nathan
next prev parent reply other threads:[~2025-04-25 17:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 4:59 [PATCH] devtmpfs: don't use vfs_getattr_nosec to query i_mode Christoph Hellwig
2025-04-23 5:54 ` Christian Brauner
2025-04-23 6:42 ` Greg KH
2025-04-24 8:40 ` Christian Brauner
2025-04-23 6:45 ` Heiko Carstens
2025-04-24 5:07 ` Jain, Ayush
2025-04-24 8:41 ` Christian Brauner
2025-04-25 10:03 ` Heiko Carstens
2025-04-25 10:12 ` Christian Brauner
2025-04-25 13:32 ` Christoph Hellwig
2025-04-25 15:40 ` Kees Cook
2025-04-25 17:17 ` Nathan Chancellor [this message]
2025-04-28 13:15 ` Christoph Hellwig
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=20250425171745.GA3071749@ax162 \
--to=nathan@kernel.org \
--cc=brauner@kernel.org \
--cc=dakr@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hca@linux.ibm.com \
--cc=hch@lst.de \
--cc=kees@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--cc=xni@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).