From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:55816 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751080AbeCVLOb (ORCPT ); Thu, 22 Mar 2018 07:14:31 -0400 Date: Thu, 22 Mar 2018 11:14:25 +0000 From: Al Viro To: "Eric W. Biederman" Cc: Jeff Layton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, "J. Bruce Fields" , Thomas Gleixner , Daniel P =?iso-8859-1?Q?=2E_Berrang=E9?= , Kate Stewart , Dan Williams , Philippe Ombredanne , Greg Kroah-Hartman Subject: Re: [PATCH v2] locks: change POSIX lock ownership on execve when files_struct is displaced Message-ID: <20180322111424.GE30522@ZenIV.linux.org.uk> References: <20180317142520.30520-1-jlayton@kernel.org> <20180317165859.26200-1-jlayton@kernel.org> <87bmfgvg8w.fsf@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87bmfgvg8w.fsf@xmission.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Mar 22, 2018 at 12:19:59AM -0500, Eric W. Biederman wrote: > Jeff Layton writes: > > > From: Jeff Layton > > > > POSIX mandates that open fds and their associated file locks should be > > preserved across an execve. This works, unless the process is > > multithreaded at the time that execve is called. > > Would this perhaps work better if we moved unshare_files to after or > inside of de_thread. That would remove any cases where fd->count is > 1 > simply because you are multi-threaded. It would only leave the strange > cases where files struct is shared between different processes. So during the probing of binfmts, etc. the descriptor table would be modifiable by other threads? flush_old_exec() is far too late in execve()...