From: Andrew Morton <akpm@linux-foundation.org>
To: Adam Lackorzynski <adam@os.inf.tu-dresden.de>
Cc: linux-kernel@vger.kernel.org, Nick Piggin <nickpiggin@yahoo.com.au>
Subject: Re: [PATCH] 2.6.28, vmalloc.c, vmap_page_range
Date: Fri, 26 Dec 2008 16:39:46 -0800 [thread overview]
Message-ID: <20081226163946.6d38e919.akpm@linux-foundation.org> (raw)
In-Reply-To: <20081225210235.GC5431@os.inf.tu-dresden.de>
On Thu, 25 Dec 2008 22:02:35 +0100 Adam Lackorzynski <adam@os.inf.tu-dresden.de> wrote:
> Hi,
>
> in 2.6.28, the flush_cache_vmap in vmap_page_range() is called with the end of
> the range twice. The following patch fixes this for me.
>
Did this bug have any observeable runtime effects? If so, what were
they?
> ---
> vmalloc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> --- linux-2.6.28/mm/vmalloc.c 2008-12-25 00:26:37.000000000 +0100
> +++ linux-2.6.28.a/mm/vmalloc.c 2008-12-25 21:45:43.118725744 +0100
> @@ -155,7 +155,7 @@
> pgprot_t prot, struct page **pages)
> {
> pgd_t *pgd;
> - unsigned long next;
> + unsigned long next, start = addr;
> int err = 0;
> int nr = 0;
>
> @@ -167,7 +167,7 @@
> if (err)
> break;
> } while (pgd++, addr = next, addr != end);
> - flush_cache_vmap(addr, end);
> + flush_cache_vmap(start, end);
>
> if (unlikely(err))
> return err;
Well yeah. This is what happens when functions modify their incoming
arguments. It's a bad programming practice which leads directly to
exactly this sort of bug.
How about we fix that?
--- a/mm/vmalloc.c~vmallocc-fix-flushing-in-vmap_page_range
+++ a/mm/vmalloc.c
@@ -151,11 +151,12 @@ static int vmap_pud_range(pgd_t *pgd, un
*
* Ie. pte at addr+N*PAGE_SIZE shall point to pfn corresponding to pages[N]
*/
-static int vmap_page_range(unsigned long addr, unsigned long end,
+static int vmap_page_range(unsigned long start_addr, unsigned long end,
pgprot_t prot, struct page **pages)
{
pgd_t *pgd;
unsigned long next;
+ unsigned long addr = start_addr;
int err = 0;
int nr = 0;
@@ -167,7 +168,7 @@ static int vmap_page_range(unsigned long
if (err)
break;
} while (pgd++, addr = next, addr != end);
- flush_cache_vmap(addr, end);
+ flush_cache_vmap(start_addr, end);
if (unlikely(err))
return err;
_
next prev parent reply other threads:[~2008-12-27 0:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-25 21:02 [PATCH] 2.6.28, vmalloc.c, vmap_page_range Adam Lackorzynski
2008-12-27 0:39 ` Andrew Morton [this message]
2008-12-27 3:36 ` Johannes Weiner
2008-12-27 9:02 ` Ingo Molnar
2008-12-27 14:25 ` Johannes Weiner
2008-12-27 12:03 ` Adam Lackorzynski
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=20081226163946.6d38e919.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=adam@os.inf.tu-dresden.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
/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