From: Liam Ni <zhiguangni01@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: dave.hansen@linux.intel.com, luto@kernel.org,
peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, x86@kernel.org, hpa@zytor.com, rppt@kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm/sparse:avoid null pointer access in memory_present()
Date: Sat, 17 Jun 2023 14:17:58 +0800 [thread overview]
Message-ID: <CACZJ9cXM9VkJ5=euHphwM5TtX3aZqZ_QynOq10FtrqCxZfZsQA@mail.gmail.com> (raw)
In-Reply-To: <20230616224407.863c74a3dc9d4f1427802f91@linux-foundation.org>
On Sat, 17 Jun 2023 at 13:44, Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Sat, 17 Jun 2023 14:40:36 +1000 Liam Ni <zhiguangni01@gmail.com> wrote:
>
> > __nr_to_section() may return a null pointer,
> > before accessing the member variable section_mem_map,
> > we should first determine whether it is a null pointer.
> >
> > ...
> >
> > --- a/mm/sparse.c
> > +++ b/mm/sparse.c
> > @@ -258,7 +258,7 @@ static void __init memory_present(int nid, unsigned long start, unsigned long en
> > set_section_nid(section, nid);
> >
> > ms = __nr_to_section(section);
> > - if (!ms->section_mem_map) {
> > + if (ms && !ms->section_mem_map) {
> > ms->section_mem_map = sparse_encode_early_nid(nid) |
> > SECTION_IS_ONLINE;
> > __section_mark_present(ms, section);
>
> I'm suspecting that if __nr_to_section() returns NULL here, we should
> just panic. But a null-deref gives the same information, so why change
> things?
Do you mean if ms is a null pointer,ms->section_mem_map will cause
system panic,so we needn't change?
>
next prev parent reply other threads:[~2023-06-17 6:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-17 4:40 Liam Ni
2023-06-17 5:44 ` Andrew Morton
2023-06-17 6:17 ` Liam Ni [this message]
2023-06-17 7:00 ` Mike Rapoport
2023-06-17 8:59 ` Liam Ni
2023-06-18 7:16 ` Mike Rapoport
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='CACZJ9cXM9VkJ5=euHphwM5TtX3aZqZ_QynOq10FtrqCxZfZsQA@mail.gmail.com' \
--to=zhiguangni01@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rppt@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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