From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 28 Sep 2007 13:08:36 -0700 (PDT) From: Linus Torvalds Subject: Re: [patch] splice mmap_sem deadlock In-Reply-To: Message-ID: References: <20070928160035.GD12538@wotan.suse.de> <20070928173144.GA11717@kernel.dk> <20070928181513.GB11717@kernel.dk> <20070928193017.GC11717@kernel.dk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=us-ascii Sender: owner-linux-mm@kvack.org Return-Path: To: Jens Axboe Cc: Nick Piggin , Andrew Morton , Linux Memory Management List List-ID: On Fri, 28 Sep 2007, Linus Torvalds wrote: > > So something like the appended might work. Untested. Btw, it migth be cleaner to separate out this thing as a function of it's own, ie something like /* * Do a copy-from-user while holding the mmap_semaphore for reading */ int copy_from_user_mmap_sem(void *dst, const void __user *src, size_t n) { int partial; pagefault_disable(); partial = __copy_from_user_inatomic(dst, src, n); pagefault_enable(); if (!partial) return 0; up_read(¤t->mm->mmap_sem); partial = copy_from_user(dst, src, n); down_read(¤t->mm->mmap_sem); return partial ? -EFAULT : 0; } in case anybody else needs it. And even if nobody else does, making it a static inline function in fs/splice.c would at least separate out this thing from the core functionality, and just help keep things clear. Wanna test that thing? Linus -- 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: email@kvack.org