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] [day] [month] [year] [list]
Message-ID: <20171031074607.exg2nh6qvnvkqu3s@dhcp22.suse.cz>
Date:   Tue, 31 Oct 2017 08:46:07 +0100
From:   Michal Hocko <mhocko@...nel.org>
To:     Minchan Kim <minchan@...nel.org>
Cc:     "Huang, Ying" <ying.huang@...el.com>,
        Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org,
        Huang Ying <huang.ying.caritas@...il.com>,
        Tim Chen <tim.c.chen@...ux.intel.com>, stable@...r.kernel.org,
        Christian Kujau <lists@...dbynature.de>
Subject: Re: [PATCH -mm -V2] mm, swap: Fix false error message in
 __swp_swapcount()

On Tue 31-10-17 16:37:10, Minchan Kim wrote:
> On Tue, Oct 31, 2017 at 08:31:07AM +0100, Michal Hocko wrote:
> > On Tue 31-10-17 11:17:02, Minchan Kim wrote:
> > > On Mon, Oct 30, 2017 at 09:02:30AM +0100, Michal Hocko wrote:
> > > > On Mon 30-10-17 08:57:13, Minchan Kim wrote:
> > > > [...]
> > > > > Although it's better than old, we can make it simple, still.
> > > > > 
> > > > > diff --git a/include/linux/swapops.h b/include/linux/swapops.h
> > > > > index 291c4b534658..f50d5a48f03a 100644
> > > > > --- a/include/linux/swapops.h
> > > > > +++ b/include/linux/swapops.h
> > > > > @@ -41,6 +41,13 @@ static inline unsigned swp_type(swp_entry_t entry)
> > > > >  	return (entry.val >> SWP_TYPE_SHIFT(entry));
> > > > >  }
> > > > >  
> > > > > +extern struct swap_info_struct *swap_info[];
> > > > > +
> > > > > +static inline struct swap_info_struct *swp_si(swp_entry_t entry)
> > > > > +{
> > > > > +	return swap_info[swp_type(entry)];
> > > > > +}
> > > > > +
> > > > >  /*
> > > > >   * Extract the `offset' field from a swp_entry_t.  The swp_entry_t is in
> > > > >   * arch-independent format
> > > > > diff --git a/mm/swap_state.c b/mm/swap_state.c
> > > > > index 378262d3a197..a0fe2d54ad09 100644
> > > > > --- a/mm/swap_state.c
> > > > > +++ b/mm/swap_state.c
> > > > > @@ -554,6 +554,7 @@ struct page *swapin_readahead(swp_entry_t entry, gfp_t gfp_mask,
> > > > >  			struct vm_area_struct *vma, unsigned long addr)
> > > > >  {
> > > > >  	struct page *page;
> > > > > +	struct swap_info_struct *si = swp_si(entry);
> > > > 
> > > > Aren't you accessing beyond the array here?
> > > 
> > > I couldn't understand what you intend. Could you explain what case does it accesses
> > > beyond the arrary?
> > 
> > what if swp_type > nr_swapfiles
> 
> Logicall, it shouldn't be happen but it's a bug once it happens.
> Such a bug can happen everywhere.
> Why do you want to take care in this logic?

You are right. It was my misunderstanding of the patch. I though the
readahead swap entries could overflow swp_type as well as the offset.
My bad.

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ