From: Linus Torvalds <torvalds@linux-foundation.org>
To: Dan Carpenter <dan.carpenter@linaro.org>,
Anna Schumaker <anna@kernel.org>,
Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Josef Bacik <josef@toxicpanda.com>,
Johannes Weiner <hannes@cmpxchg.org>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
syzbot+48011b86c8ea329af1b9@syzkaller.appspotmail.com,
Christoph Hellwig <hch@lst.de>, David Sterba <dsterba@suse.com>,
Bob Peterson <rpeterso@redhat.com>,
Andreas Gruenbacher <agruenba@redhat.com>
Subject: Re: [PATCH] filemap: Handle error return from __filemap_get_folio()
Date: Tue, 9 May 2023 10:37:12 -0700 [thread overview]
Message-ID: <CAHk-=whD=py2eMXFNOEQyDUobAXBJ3O0eFAG6yjC=EN4iZrhKw@mail.gmail.com> (raw)
In-Reply-To: <d98acf2e-04bd-4824-81e4-64e91a26537c@kili.mountain>
On Tue, May 9, 2023 at 12:43 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> I ran the new code last night. There was one more folio bug (but every
> function in the call tree triggers a warning).
>
> fs/nfs/dir.c:405 nfs_readdir_folio_get_locked() warn: 'folio' is an error pointer or valid
Thanks. I fixed that one up too.
In the process I ended up grepping for the other wrappers around
__filemap_get_folio() that also return ERR_PTR's for errors.
I might have missed some - this was just manual, after all - but while
I'm sure smatch finds those NULL pointer confusions, what I *did* find
was a lack of testing the result at all.
In fs/btrfs/extent_io.c, we have
while (index <= end_index) {
folio = filemap_get_folio(mapping, index);
filemap_dirty_folio(mapping, folio);
and in fs/gfs2/lops.c we have a similar case of filemap_get_folio ->
folio_wait_locked use without checking for any errors.
I assume it's probably hard to trigger errors in those paths, but it
does look dodgy.
Added some relevant people to the participants to let them know...
I wonder if smatch can figure out automatically when error pointers do
*not* work, and need checking for.
A lot of places do not need to check for them, because they just
return the error pointer further up the call chain, but anything that
then actually dereferences it should have checked for them (same as
for NULL, of course).
Linus
next prev parent reply other threads:[~2023-05-09 17:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-06 16:04 Matthew Wilcox (Oracle)
2023-05-06 16:09 ` Linus Torvalds
2023-05-06 16:35 ` Linus Torvalds
2023-05-06 17:04 ` Linus Torvalds
2023-05-06 17:10 ` Linus Torvalds
2023-05-06 17:34 ` Linus Torvalds
2023-05-06 17:41 ` Andrew Morton
2023-05-08 13:56 ` Dan Carpenter
2023-05-09 7:43 ` Dan Carpenter
2023-05-09 17:37 ` Linus Torvalds [this message]
2023-05-09 20:49 ` Christoph Hellwig
2023-05-11 9:44 ` Dan Carpenter
2023-05-09 19:19 ` Johannes Weiner
2023-05-10 20:27 ` Peter Xu
2023-05-10 21:33 ` Linus Torvalds
2023-05-10 21:44 ` Linus Torvalds
2023-05-11 4:45 ` Peter Xu
2023-05-12 0:14 ` Peter Xu
2023-05-12 3:28 ` [PATCH 1/3] mm: handle_mm_fault_one() kernel test robot
2023-05-12 3:52 ` kernel test robot
2023-05-12 3:52 ` kernel test robot
2023-05-12 4:49 ` kernel test robot
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='CAHk-=whD=py2eMXFNOEQyDUobAXBJ3O0eFAG6yjC=EN4iZrhKw@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=agruenba@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=anna@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=dsterba@suse.com \
--cc=hannes@cmpxchg.org \
--cc=hch@lst.de \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rpeterso@redhat.com \
--cc=syzbot+48011b86c8ea329af1b9@syzkaller.appspotmail.com \
--cc=trond.myklebust@hammerspace.com \
--cc=willy@infradead.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