From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:58210 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934472AbcLTRad (ORCPT ); Tue, 20 Dec 2016 12:30:33 -0500 Date: Tue, 20 Dec 2016 18:29:56 +0100 From: Oleg Nesterov To: Aleksa Sarai Cc: viro@zeniv.linux.org.uk, ebiederm@xmission.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, cyphar@cyphar.com, dev@opencontainers.org Subject: Re: [PATCH] fs: exec: apply CLOEXEC before changing dumpable task flags Message-ID: <20161220172955.GA7776@redhat.com> References: <20161220110457.22254-1-asarai@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161220110457.22254-1-asarai@suse.de> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 12/20, Aleksa Sarai wrote: > > @@ -1287,6 +1287,13 @@ void setup_new_exec(struct linux_binprm * bprm) > /* This is the point of no return */ > current->sas_ss_sp = current->sas_ss_size = 0; > > + /* > + * We have to apply CLOEXEC before we change whether the process is > + * dumpable to avoid a race with a process in userspace trying to access > + * the should-be-closed file descriptors of a process undergoing exec(2). > + */ > + do_close_on_exec(current->files); Cosmetic, but perhaps this should go into flush_old_exec() then? But I am fine either way, up to you. Oleg.