From: "Theodore Ts'o" <tytso@mit.edu>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Su Hui <suhui@nfschina.com>,
adilger.kernel@dilger.ca, nathan@kernel.org, trix@redhat.com,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] ext4: mballoc: avoid garbage value from err
Date: Mon, 24 Jul 2023 16:57:21 -0400 [thread overview]
Message-ID: <20230724205721.GA2504240@mit.edu> (raw)
In-Reply-To: <CAKwvOdk-fdJr9TcgUnOhCiU0LvD2Qe_c+6YOe-c1k0Ukm+negA@mail.gmail.com>
On Mon, Jul 24, 2023 at 10:19:02AM -0700, Nick Desaulniers wrote:
> >
> > err is uninitialized and will be judged when it enters the
> > loop first time and the condition "!ext4_sb_block_valid()"
> > is true. Although this can't make problems now, it's better
> > to correct it.
> >
> > Signed-off-by: Su Hui <suhui@nfschina.com>
>
> Hi Su,
> Thanks for the patch! I see what the warning is getting at;
>
> If `len <= 0` then `err` is never initialized, then is used at line
> 4178 (that is UB).
>
> Would you mind sending a v2 with the commit message updated to reflect
> the above points? I'd be happy to sign-off on that.
Fortunately, as near as I can tell, ext4_mb_mark_bb() should never be
called with len <= 0. It might be possible to trick ext4 via a
corrupted file system --- I'd have to take a closer look at that, but
fortunately, in the case where len <= 0, bitmap_bh will be NULL, so
regardless of whether err is 0, or some garbage non-zero value,
brelse(NULL) is a no-op.
So while it's good to avoid the clang warning, but the fact that it
might be possible for err to be a "garbage value" shouldn't be causing
any problem.
Cheers,
- Ted
next prev parent reply other threads:[~2023-07-24 20:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 5:45 [PATCH] ext4: mballoc: avoid garbage value from err Su Hui
2023-07-24 17:19 ` Nick Desaulniers
2023-07-24 20:57 ` Theodore Ts'o [this message]
2023-07-25 4:21 ` Su Hui
2023-07-25 4:33 ` Dan Carpenter
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=20230724205721.GA2504240@mit.edu \
--to=tytso@mit.edu \
--cc=adilger.kernel@dilger.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=suhui@nfschina.com \
--cc=trix@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