mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Duane Griffin" <duaneg@dghda.com>
To: "Nick Piggin" <npiggin@suse.de>
Cc: "Linus Torvalds" <torvalds@linux-foundation.org>,
	"linux-kernel Mailing List" <linux-kernel@vger.kernel.org>,
	stable@kernel.org
Subject: Re: 2.6.23 regression: accessing invalid mmap'ed memory from gdb causes unkillable spinning
Date: Wed, 31 Oct 2007 10:27:47 +0000	[thread overview]
Message-ID: <e9e943910710310327w189c136ey2c8d893b20e81a83@mail.gmail.com> (raw)
In-Reply-To: <20071031041932.GA12189@wotan.suse.de>

On 31/10/2007, Nick Piggin <npiggin@suse.de> wrote:
> Well that's probably the best bug report I've ever had, thanks Duane!

Aw, shucks!

> The issue is a silly thinko -- I didn't pay enough attention to the ptrace
> rules in filemap_fault :( partly I think that's because I don't understand
> them and am scared of them ;)
>
> The following minimal patch fixes it here, and should probably be applied to
> 2.6.23 stable as well as 2.6.24. If you could verify it, that would be much
> appreciated.

I can confirm that it fixes the problem, thanks Nick!

Feel free to add:
Tested-by: Duane Griffin <duaneg@dghda.com>

> However I actually don't really like how this all works. I don't like that
> filemap.c should have to know about ptrace, or exactly what ptrace wants here.
> It's a bit hairy to force insert page into pagecache and pte into pagetables
> here, given the races.
>
> In access_process_vm, can't we just zero fill in the case of a sigbus? Linus?
> That will also avoid changing applicatoin behaviour due to a gdb read...
>
> Thanks,
> Nick
>
> --
> Duane Griffin noticed a 2.6.23 regression that will cause gdb to hang when
> it tries to access the memory of another process beyond i_size.
>
> This is because the solution to the fault vs invalidate race requires that
> we recheck i_size after the page lock is taken. However in that case, I
> had not accounted for the fact that ptracers are granted an exception to this
> rule.
>
> Cc: Duane Griffin <duaneg@dghda.com>
> Cc: stable@kernel.org
> Signed-off-by: Nick Piggin <npiggin@suse.de
> ---
> Index: linux-2.6/mm/filemap.c
> ===================================================================
> --- linux-2.6.orig/mm/filemap.c
> +++ linux-2.6/mm/filemap.c
> @@ -1374,7 +1374,7 @@ retry_find:
>
>         /* Must recheck i_size under page lock */
>         size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
> -       if (unlikely(vmf->pgoff >= size)) {
> +       if (unlikely(vmf->pgoff >= size) && vma->vm_mm == current->mm) {
>                 unlock_page(page);
>                 page_cache_release(page);
>                 goto outside_data_content;
>

Cheers,
Duane.

-- 
"I never could learn to drink that blood and call it wine" - Bob Dylan

  reply	other threads:[~2007-10-31 10:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-31  0:45 Duane Griffin
2007-10-31  4:19 ` Nick Piggin
2007-10-31 10:27   ` Duane Griffin [this message]
2007-10-31 15:11   ` Linus Torvalds
2007-10-31 15:19     ` Nick Piggin
2007-10-31 15:59       ` Linus Torvalds
2007-10-31 17:19         ` Duane Griffin
2007-10-31 22:55         ` Nick Piggin
2007-10-31 23:08           ` Linus Torvalds
2007-11-01  2:37             ` Nick Piggin
2007-11-01 15:14               ` Linus Torvalds
2007-11-01 15:47                 ` Nick Piggin
2007-11-01 16:08                   ` Linus Torvalds
2007-11-01 23:56                     ` Nick Piggin
2007-11-02  1:17                       ` Linus Torvalds
2007-11-02  6:30                         ` Nick Piggin
2007-10-31  6:42 ` Nick Piggin
2007-10-31  6:56   ` David Miller
2007-10-31  7:41     ` Nick Piggin
2007-10-31  7:44       ` David Miller
2007-11-02  5:02         ` David Miller
2007-11-02 10:45           ` Nick Piggin
2007-11-02 15:36             ` Ingo Molnar

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=e9e943910710310327w189c136ey2c8d893b20e81a83@mail.gmail.com \
    --to=duaneg@dghda.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npiggin@suse.de \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®