linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Nick Piggin <npiggin@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Badari Pulavarty <pbadari@us.ibm.com>,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [patch] mm: fix madvise infinine loop
Date: Thu, 15 Mar 2007 19:49:24 +0000 (GMT)	[thread overview]
Message-ID: <Pine.LNX.4.64.0703151937350.7795@blonde.wat.veritas.com> (raw)
In-Reply-To: <20070310034942.GB13299@wotan.suse.de>

On Sat, 10 Mar 2007, Nick Piggin wrote:
> 
> This has been noticed when running a particular database server which I
> won't name. Please apply.
> 
> --
> madvise(MADV_REMOVE) can go into an infinite loop or cause an oops if
> the call covers a region from the start of a vma, and extending past that
> vma.
> 
> Signed-off-by: Nick Piggin <npiggin@suse.de>

Good find,
Acked-by: Hugh Dickins <hugh@veritas.com>

>From the patch itself, it looks odd that you've added a prev arg to
madvise_remove, which could perfectly well be assigned by the caller.
But you're doing the right thing, to follow the established convention
there.  Or would we do better to preset *prev = vma in madvise_vma,
to prevent a similar error next time?  (No need to delay this fix,
just a question for the future, I'm uncertain.)

Hugh

> 
> Index: linux-2.6.16/mm/madvise.c
> ===================================================================
> --- linux-2.6.16.orig/mm/madvise.c
> +++ linux-2.6.16/mm/madvise.c
> @@ -155,11 +155,14 @@ static long madvise_dontneed(struct vm_a
>   * Other filesystems return -ENOSYS.
>   */
>  static long madvise_remove(struct vm_area_struct *vma,
> +				struct vm_area_struct **prev,
>  				unsigned long start, unsigned long end)
>  {
>  	struct address_space *mapping;
>          loff_t offset, endoff;
>  
> +	*prev = vma;
> +
>  	if (vma->vm_flags & (VM_LOCKED|VM_NONLINEAR|VM_HUGETLB))
>  		return -EINVAL;
>  
> @@ -199,7 +202,7 @@ madvise_vma(struct vm_area_struct *vma, 
>  		error = madvise_behavior(vma, prev, start, end, behavior);
>  		break;
>  	case MADV_REMOVE:
> -		error = madvise_remove(vma, start, end);
> +		error = madvise_remove(vma, prev, start, end);
>  		break;
>  
>  	case MADV_WILLNEED:

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2007-03-15 19:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-10  3:49 Nick Piggin
2007-03-15 19:49 ` Hugh Dickins [this message]

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=Pine.LNX.4.64.0703151937350.7795@blonde.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=npiggin@suse.de \
    --cc=pbadari@us.ibm.com \
    /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