From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:51156 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728361AbeIQU4J (ORCPT ); Mon, 17 Sep 2018 16:56:09 -0400 Date: Mon, 17 Sep 2018 17:28:17 +0200 From: Oleg Nesterov To: "Eric W. Biederman" Cc: Jeff Layton , viro@zeniv.linux.org.uk, berrange@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton Subject: Re: [PATCH v3 3/3] exec: do unshare_files after de_thread Message-ID: <20180917152817.GB25173@redhat.com> References: <20180914105310.6454-1-jlayton@kernel.org> <20180914105310.6454-4-jlayton@kernel.org> <20180915163704.GA31693@redhat.com> <87efdttmjm.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87efdttmjm.fsf@xmission.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 09/16, Eric W. Biederman wrote: > > Oleg Nesterov writes: > > > IOW. Lets ignore do_close_on_exec(), lets ignore the fact that unshare_fd() > > can fail and thus it makes sense to call it before point-of-no-return. > > > > Any other reason why we can't simply call unshare_files() at the end of > > __do_execve_file() on success? > > The reason we call we call unshare_files is in case the files are shared > with another process. AKA old style linux threads, or someone being > clever. In that case we need a private copy of files for close on exec > because we should not close the files of the other process that has not > called exec. This is clear, > The only reason for calling unshare_files before the point of no return > is so that we can get a good error message to the calling process if > unshare_files fails. OK, so you too think there are no other reasons. > AKA it would be reasonable to move unshare_files to just above > do_close_on_exec in flush_old_exec. We could further make the > unshare_files not return displaced and just drop it. Yes, this is exactly what I had in mind. Oleg.