From: "Sosnowski, Maciej" <maciej.sosnowski@intel.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Nick Piggin <nickpiggin@yahoo.com.au>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
Andrea Arcangeli <aarcange@redhat.com>,
Jeff Moyer <jmoyer@redhat.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
"Leech, Christopher" <christopher.leech@intel.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [RFC][PATCH v3 6/6] fix wrong get_user_pages usage in iovlock.c
Date: Fri, 17 Apr 2009 16:07:38 +0100 [thread overview]
Message-ID: <129600E5E5FB004392DDC3FB599660D792A39DCE@irsmsx504.ger.corp.intel.com> (raw)
In-Reply-To: <20090415174658.AC4F.A69D9226@jp.fujitsu.com>
KOSAKI Motohiro wrote:
>>> I would perhaps not fold gup_fast conversions into the same patch as
>>> the fix.
>>
>> OK. I'll fix.
>
> Done.
>
>
>
> ===================================
> Subject: [Untested][RFC][PATCH] fix wrong get_user_pages usage in iovlock.c
>
> down_read(mmap_sem)
> get_user_pages()
> up_read(mmap_sem)
>
> is fork unsafe.
> fix it.
>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> Cc: Maciej Sosnowski <maciej.sosnowski@intel.com>
> Cc: David S. Miller <davem@davemloft.net>
> Cc: Chris Leech <christopher.leech@intel.com>
> Cc: netdev@vger.kernel.org
> ---
> drivers/dma/iovlock.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Index: b/drivers/dma/iovlock.c
> ===================================================================
> --- a/drivers/dma/iovlock.c 2009-04-13 22:58:36.000000000 +0900
> +++ b/drivers/dma/iovlock.c 2009-04-14 20:27:16.000000000 +0900
> @@ -104,8 +104,6 @@ struct dma_pinned_list *dma_pin_iovec_pa
> 0, /* force */
> page_list->pages,
> NULL);
> - up_read(¤t->mm->mmap_sem);
> -
> if (ret != page_list->nr_pages)
> goto unpin;
>
> @@ -127,6 +125,8 @@ void dma_unpin_iovec_pages(struct dma_pi
> if (!pinned_list)
> return;
>
> + up_read(¤t->mm->mmap_sem);
> +
> for (i = 0; i < pinned_list->nr_iovecs; i++) {
> struct dma_page_list *page_list = &pinned_list->page_list[i];
> for (j = 0; j < page_list->nr_pages; j++) {
I have tried it with net_dma and here is what I've got.
Regards,
Maciej
---
=======================================================
[ INFO: possible circular locking dependency detected ]
2.6.30-rc2 #2
-------------------------------------------------------
iperf/10555 is trying to acquire lock:
(sk_lock-AF_INET){+.+.+.}, at: [<ffffffff80450991>] sk_wait_data+0x90/0xc5
but task is already holding lock:
(&mm->mmap_sem){++++++}, at: [<ffffffff8043d0f6>] dma_pin_iovec_pages+0x122/0x1a0
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (&mm->mmap_sem){++++++}:
[<ffffffffffffffff>] 0xffffffffffffffff
-> #0 (sk_lock-AF_INET){+.+.+.}:
[<ffffffffffffffff>] 0xffffffffffffffff
other info that might help us debug this:
1 lock held by iperf/10555:
#0: (&mm->mmap_sem){++++++}, at: [<ffffffff8043d0f6>] dma_pin_iovec_pages+0x122/0x1a0
stack backtrace:
Pid: 10555, comm: iperf Tainted: G W 2.6.30-rc2 #2
Call Trace:
[<ffffffff8025b1dc>] ? print_circular_bug_tail+0xc0/0xc9
[<ffffffff8025aa2b>] ? print_circular_bug_header+0xc8/0xcf
[<ffffffff8025b984>] ? validate_chain+0x67d/0xc7c
[<ffffffff8025c6e6>] ? __lock_acquire+0x763/0x7ec
[<ffffffff8025c835>] ? lock_acquire+0xc6/0xea
[<ffffffff80450991>] ? sk_wait_data+0x90/0xc5
[<ffffffff8044ff01>] ? lock_sock_nested+0xee/0x100
[<ffffffff80450991>] ? sk_wait_data+0x90/0xc5
[<ffffffff80259b07>] ? mark_held_locks+0x43/0x5b
[<ffffffff802403ee>] ? local_bh_enable_ip+0xc4/0xc7
[<ffffffff80259c3c>] ? trace_hardirqs_on_caller+0x11d/0x148
[<ffffffff80450991>] ? sk_wait_data+0x90/0xc5
[<ffffffff8024ebb3>] ? autoremove_wake_function+0x0/0x2e
[<ffffffff80488ad3>] ? tcp_recvmsg+0x3bf/0xa21
[<ffffffff8044f601>] ? sock_common_recvmsg+0x30/0x45
[<ffffffff8044d847>] ? sock_recvmsg+0xf0/0x10f
[<ffffffff8024ebb3>] ? autoremove_wake_function+0x0/0x2e
[<ffffffff8025c704>] ? __lock_acquire+0x781/0x7ec
[<ffffffff802b553c>] ? fget_light+0xd5/0xdf
[<ffffffff802b54b0>] ? fget_light+0x49/0xdf
[<ffffffff8044e91b>] ? sys_recvfrom+0xbc/0x119
[<ffffffff80259c3c>] ? trace_hardirqs_on_caller+0x11d/0x148
[<ffffffff804e1a7f>] ? _spin_unlock_irq+0x24/0x27
[<ffffffff802359ab>] ? finish_task_switch+0x7a/0xe4
[<ffffffff80235967>] ? finish_task_switch+0x36/0xe4
[<ffffffff804df188>] ? thread_return+0x3e/0x97
[<ffffffff802718f7>] ? audit_syscall_entry+0x192/0x1bd
[<ffffffff8020b96b>] ? system_call_fastpath+0x16/0x1b
--
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>
next prev parent reply other threads:[~2009-04-17 15:09 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-14 6:15 [RFC][PATCH 0/6] IO pinning(get_user_pages()) vs fork race fix KOSAKI Motohiro
2009-04-14 6:16 ` [RFC][PATCH v3 1/6] mm: Don't unmap gup()ed page KOSAKI Motohiro
2009-04-14 9:25 ` Nick Piggin
2009-04-14 12:02 ` KOSAKI Motohiro
2009-04-14 12:25 ` Nick Piggin
2009-04-14 13:39 ` KOSAKI Motohiro
2009-04-14 14:12 ` Andrea Arcangeli
2009-04-14 14:26 ` Nick Piggin
2009-04-14 14:32 ` Andrea Arcangeli
2009-04-14 14:42 ` Nick Piggin
2009-04-14 15:21 ` Andrea Arcangeli
2009-04-15 8:05 ` KOSAKI Motohiro
2009-04-15 8:22 ` Nick Piggin
2009-04-15 9:22 ` Nick Piggin
2009-04-15 10:46 ` Andrea Arcangeli
2009-04-15 11:39 ` KOSAKI Motohiro
2009-04-15 11:41 ` Andrea Arcangeli
2009-04-15 11:53 ` KOSAKI Motohiro
2009-04-19 12:37 ` KOSAKI Motohiro
2009-04-14 14:38 ` Andrea Arcangeli
2009-04-14 6:18 ` [RFC][PATCH v3 2/6] mm, directio: fix fork vs direct-io race (read(2) side IOW gup(write) side) KOSAKI Motohiro
2009-04-14 6:25 ` KOSAKI Motohiro
2009-04-14 16:45 ` Jeff Moyer
2009-04-14 17:51 ` Andrea Arcangeli
2009-04-14 18:10 ` Jeff Moyer
2009-04-14 19:48 ` Andrea Arcangeli
2009-04-14 6:19 ` [RFC][PATCH v3 3/6] nfs, direct-io: fix fork vs direct-io race on nfs KOSAKI Motohiro
2009-04-14 16:48 ` Jeff Moyer
2009-04-14 6:20 ` [RFC][PATCH v3 4/6] aio: Don't inherit aio ring memory at fork KOSAKI Motohiro
2009-04-14 13:41 ` Andrea Arcangeli
2009-04-14 16:01 ` Jeff Moyer
2009-04-15 0:56 ` KOSAKI Motohiro
2009-04-15 2:44 ` Jeff Moyer
2009-04-15 3:00 ` KOSAKI Motohiro
2009-04-14 6:21 ` [RFC][PATCH v3 5/6] don't use bio-map in read() path KOSAKI Motohiro
2009-04-14 6:23 ` [RFC][PATCH v3 6/6] fix wrong get_user_pages usage in iovlock.c KOSAKI Motohiro
2009-04-14 6:56 ` Nick Piggin
2009-04-14 6:58 ` KOSAKI Motohiro
2009-04-15 8:48 ` KOSAKI Motohiro
2009-04-17 15:07 ` Sosnowski, Maciej [this message]
2009-04-19 12:37 ` KOSAKI Motohiro
2009-04-23 12:48 ` Sosnowski, Maciej
2009-04-14 8:41 ` [RFC][PATCH 0/6] IO pinning(get_user_pages()) vs fork race fix Nick Piggin
2009-04-14 9:19 ` KOSAKI Motohiro
2009-04-14 9:37 ` Nick Piggin
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=129600E5E5FB004392DDC3FB599660D792A39DCE@irsmsx504.ger.corp.intel.com \
--to=maciej.sosnowski@intel.com \
--cc=aarcange@redhat.com \
--cc=akpm@osdl.org \
--cc=christopher.leech@intel.com \
--cc=davem@davemloft.net \
--cc=jmoyer@redhat.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
--cc=torvalds@osdl.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