From: Matthew Wilcox <willy@infradead.org>
To: cgel.zte@gmail.com
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, xu xin <xu.xin16@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH linux-next] mm/folio-compat: fix potential NULL pointer access
Date: Sat, 9 Oct 2021 20:35:47 +0100 [thread overview]
Message-ID: <YWHvEy5lDD5GnrlQ@casper.infradead.org> (raw)
In-Reply-To: <20210913081113.79975-1-xu.xin16@zte.com.cn>
On Mon, Sep 13, 2021 at 08:11:13AM +0000, cgel.zte@gmail.com wrote:
> From: xu xin <xu.xin16@zte.com.cn>
>
> The pointer 'folio' might be NULL, but the structure it points to is accessed.
> Accordingly, we add a check of NULL pointer by 'if (!folio)'.
> Secondly, there is no need to check if folio is pointer or value with 'xa_is_value(folio)'
> because folio is alwayse pointer.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
Your robot is garbage.
> folio = __filemap_get_folio(mapping, index, fgp_flags, gfp);
> - if ((fgp_flags & FGP_HEAD) || !folio || xa_is_value(folio))
> + if (!folio)
> + return NULL;
> + if ((fgp_flags & FGP_HEAD))
> return &folio->page;
&folio->page *does not access folio*. It does pointer arithmetic on
folio. Specifically, it adds zero to folio, because page is the first
element of folio.
Secondly, __filemap_get_folio() absolutely can return an xa_is_value()
result if FGP_ENTRY entry is set. It's right there in the first few
lines:
folio = mapping_get_entry(mapping, index);
if (xa_is_value(folio)) {
if (fgp_flags & FGP_ENTRY)
return folio;
prev parent reply other threads:[~2021-10-09 19:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 8:11 [PATCH linux-next] mm/folio-compat: fix potential NULL pointer access cgel.zte
2021-10-09 19:35 ` Matthew Wilcox [this message]
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=YWHvEy5lDD5GnrlQ@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=cgel.zte@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=xu.xin16@zte.com.cn \
--cc=zealci@zte.com.cn \
/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).