From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934227AbcCNN6U (ORCPT ); Mon, 14 Mar 2016 09:58:20 -0400 Received: from queue01b.mail.zen.net.uk ([212.23.3.242]:50881 "EHLO queue01b.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933297AbcCNN6Q (ORCPT ); Mon, 14 Mar 2016 09:58:16 -0400 X-Greylist: delayed 2567 seconds by postgrey-1.27 at vger.kernel.org; Mon, 14 Mar 2016 09:58:16 EDT Date: Mon, 14 Mar 2016 13:15:00 +0000 From: Julian Smith To: Oleg Nesterov Cc: Janak Desai , Andrew Morton , ebiederm@xmission.com, Linus Torvalds , linux-kernel@vger.kernel.org Subject: unshare(CLONE_VM) Re: [PATCH] unshare: Use rcu_assign_pointer when setting sighand Message-ID: <20160314131500.21b9f6c5@jules-lenovo3> In-Reply-To: <441C4263.B779CDA8@tv-sign.ru> References: <441AF596.F6E66BC9@tv-sign.ru> <20060317125607.78a5dbe4.akpm@osdl.org> <441C0741.3BC25010@tv-sign.ru> <441C2AA0.3080200@us.ibm.com> <441C4263.B779CDA8@tv-sign.ru> Organization: Undo Software X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Originating-smarthost03a-IP: [82.68.48.14] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 18 Mar 2006 20:24:51 +0300 Oleg Nesterov wrote: [...] > However, I stronly beleive unshare(CLONE_VM) is buggy. > > sys_unshare: > > > if (new_mm) { > ... > new_mm = mm; > } > > ... > > bad_unshare_cleanup_vm: > if (new_mm) > mmput(new_mm); > > > mmput() ignores mm->core_waiters. Apologies for re-opening a ten-year-old thread. I'm looking into whether it would be possible to extend the unshare syscall to support the CLONE_VM flag with multi-threaded processes, because this would allow us at Undo to record multi-threaded user processes much more efficiently than at present. We currently have to serialise threads and so suffer an N-times slowdown when recording a process with N cpu-bound threads. But if we could get per-thread memory permissions with unshare(CLONE_VM), we'd be able record a multi-threaded process with almost no per-thread slowdown. When the unshare syscall was introduced, it seems that the mm->core_waiters issue was the only thing that prevented CLONE_VM being supported. Is that right, or were there other problems too? Many thanks for any information about this. - Julian -- http://undo-software.com