[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210329193214.GA28602@pc638.lan>
Date: Mon, 29 Mar 2021 21:32:14 +0200
From: Uladzislau Rezki <urezki@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Matthew Wilcox <willy@...radead.org>,
Colin King <colin.king@...onical.com>,
Nicholas Piggin <npiggin@...il.com>, linux-mm@...ck.org,
kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] mm/vmalloc: Fix read of pointer area after it has
been free'd
> On Mon, Mar 29, 2021 at 08:14:53PM +0200, Uladzislau Rezki wrote:
> > On Mon, Mar 29, 2021 at 07:40:29PM +0200, Uladzislau Rezki wrote:
> > > On Mon, Mar 29, 2021 at 06:14:34PM +0100, Matthew Wilcox wrote:
> > > > On Mon, Mar 29, 2021 at 06:07:30PM +0100, Colin King wrote:
> > > > > From: Colin Ian King <colin.king@...onical.com>
> > > > >
> > > > > Currently the memory pointed to by area is being freed by the
> > > > > free_vm_area call and then area->nr_pages is referencing the
> > > > > free'd object. Fix this swapping the order of the warn_alloc
> > > > > message and the free.
> > > > >
> > > > > Addresses-Coverity: ("Read from pointer after free")
> > > > > Fixes: 014ccf9b888d ("mm/vmalloc: improve allocation failure error messages")
> > > >
> > > > i don't have this git sha. if this is -next, the sha ids aren't stable
> > > > and shouldn't be referenced in commit logs, because these fixes should
> > > > just be squashed into the not-yet-upstream commits.
> > > >
> > > > > Signed-off-by: Colin Ian King <colin.king@...onical.com>
> > > > > ---
> > > > > mm/vmalloc.c | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > > > > index b73e4e715e0d..7936405749e4 100644
> > > > > --- a/mm/vmalloc.c
> > > > > +++ b/mm/vmalloc.c
> > > > > @@ -2790,11 +2790,11 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
> > > > > }
> > > > >
> > > > > if (!pages) {
> > > > > - free_vm_area(area);
> > > > > warn_alloc(gfp_mask, NULL,
> > > > > "vmalloc size %lu allocation failure: "
> > > > > "page array size %lu allocation failed",
> > > > > area->nr_pages * PAGE_SIZE, array_size);
> > > > > + free_vm_area(area);
> > > > > return NULL;
> > > >
> > > > this fix looks right to me.
> > > >
> > > That is from the linux-next. Same to me.
> > >
> > > Reviewed-by: Uladzislau Rezki (Sony) <urezki@...il.com>
> > >
> > > --
> > > Vlad Rezki
> > Is the linux-next(next-20210329) broken?
> >
> Please ignore my previous email. That was due to my local "stashed" change.
>
Hello, Andrew.
Could you please squash below patch with the one that is in question?
Or should i send out it as separate patch?
>From 6d1c221fec4718094c6e825e3879a76ad70dba93 Mon Sep 17 00:00:00 2001
From: "Uladzislau Rezki (Sony)" <urezki@...il.com>
Date: Mon, 29 Mar 2021 21:12:47 +0200
Subject: [PATCH] mm/vmalloc: print correct vmalloc allocation size
On entry the area->nr_pages is not set yet and is zero, thus
when an allocation of the page-table array fails the vmalloc
size will not be reflected correctly in a error message.
Replace area->nr_pages by the nr_small_pages.
Fixes: 014ccf9b888d ("mm/vmalloc: improve allocation failure error messages")
Signed-off-by: Uladzislau Rezki (Sony) <urezki@...il.com>
---
mm/vmalloc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index b73e4e715e0d..8b564f91a610 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2794,7 +2794,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
warn_alloc(gfp_mask, NULL,
"vmalloc size %lu allocation failure: "
"page array size %lu allocation failed",
- area->nr_pages * PAGE_SIZE, array_size);
+ nr_small_pages * PAGE_SIZE, array_size);
return NULL;
}
--
2.20.1
--
Vlad Rezki
Powered by blists - more mailing lists