lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230617070051.GU52412@kernel.org>
Date:   Sat, 17 Jun 2023 10:00:51 +0300
From:   Mike Rapoport <rppt@...nel.org>
To:     Liam Ni <zhiguangni01@...il.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        dave.hansen@...ux.intel.com, luto@...nel.org, peterz@...radead.org,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
        hpa@...or.com, linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH] mm/sparse:avoid null pointer access in memory_present()

On Sat, Jun 17, 2023 at 02:17:58PM +0800, Liam Ni wrote:
> On Sat, 17 Jun 2023 at 13:44, Andrew Morton <akpm@...ux-foundation.org> wrote:
> >
> > On Sat, 17 Jun 2023 14:40:36 +1000 Liam Ni <zhiguangni01@...il.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?
 
Yes, if __nr_to_section ever returns NULL the system will crash anyway.

-- 
Sincerely yours,
Mike.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ