Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1296259

Re: [PATCH] mm, oom: initiallize all new zap_details fields before use

From Andrew Morton <akpm@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] mm, oom: initiallize all new zap_details fields before use
Date 2015-12-21 23:30 +0100
Message-ID <qIh7P-3UO-15@gated-at.bofh.it> (permalink)
References <qHec1-4Q0-1@gated-at.bofh.it> <qHvPz-7sY-11@gated-at.bofh.it> <qHxRn-ux-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, 19 Dec 2015 17:03:15 -0500 Sasha Levin <sasha.levin@oracle.com> wrote:

> On 12/19/2015 02:52 PM, Kirill A. Shutemov wrote:
> > On Fri, Dec 18, 2015 at 08:04:51PM -0500, Sasha Levin wrote:
> >> > Commit "mm, oom: introduce oom reaper" forgot to initialize the two new fields
> >> > of struct zap_details in unmap_mapping_range(). This caused using stack garbage
> >> > on the call to unmap_mapping_range_tree().
> >> > 
> >> > Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> >> > ---
> >> >  mm/memory.c |    1 +
> >> >  1 file changed, 1 insertion(+)
> >> > 
> >> > diff --git a/mm/memory.c b/mm/memory.c
> >> > index 206c8cd..0e32993 100644
> >> > --- a/mm/memory.c
> >> > +++ b/mm/memory.c
> >> > @@ -2431,6 +2431,7 @@ void unmap_mapping_range(struct address_space *mapping,
> >> >  	details.last_index = hba + hlen - 1;
> >> >  	if (details.last_index < details.first_index)
> >> >  		details.last_index = ULONG_MAX;
> >> > +	details.check_swap_entries = details.ignore_dirty = false;
> > Should we use c99 initializer instead to make it future-proof?
> 
> I didn't do that to make these sort of failures obvious. In this case, if we would have
> used an initializer and it would default to the "wrong" values it would be much harder
> to find this bug.
> 

If we're to make that approach useful and debuggable we should poison
the structure at the outset with some well-known and crazy pattern.  Or
use kasan.

But I don't think we need any special treatment here so yes, the
conventional way of zapping everything is best, IMO.

--- a/mm/memory.c~mm-oom-introduce-oom-reaper-fix-5-fix
+++ a/mm/memory.c
@@ -2414,7 +2414,7 @@ static inline void unmap_mapping_range_t
 void unmap_mapping_range(struct address_space *mapping,
 		loff_t const holebegin, loff_t const holelen, int even_cows)
 {
-	struct zap_details details;
+	struct zap_details details = { };
 	pgoff_t hba = holebegin >> PAGE_SHIFT;
 	pgoff_t hlen = (holelen + PAGE_SIZE - 1) >> PAGE_SHIFT;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mm, oom: initiallize all new zap_details fields before use Sasha Levin <sasha.levin@oracle.com> - 2015-12-19 02:10 +0100
  Re: [PATCH] mm, oom: initiallize all new zap_details fields before  use "Kirill A. Shutemov" <kirill@shutemov.name> - 2015-12-19 21:00 +0100
    Re: [PATCH] mm, oom: initiallize all new zap_details fields before  use Sasha Levin <sasha.levin@oracle.com> - 2015-12-19 23:10 +0100
      Re: [PATCH] mm, oom: initiallize all new zap_details fields before  use Andrew Morton <akpm@linux-foundation.org> - 2015-12-21 23:30 +0100
        Re: [PATCH] mm, oom: initiallize all new zap_details fields before  use Sasha Levin <sasha.levin@oracle.com> - 2015-12-22 02:00 +0100
  Re: [PATCH] mm, oom: initiallize all new zap_details fields before  use Michal Hocko <mhocko@kernel.org> - 2015-12-21 09:40 +0100

csiph-web