From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id 4F8453858C50 for ; Mon, 2 May 2022 20:02:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4F8453858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ispras.ru Received: from mail.ispras.ru (unknown [83.149.199.84]) by mail.ispras.ru (Postfix) with ESMTPSA id 30AE340D403D; Mon, 2 May 2022 20:02:21 +0000 (UTC) MIME-Version: 1.0 Date: Mon, 02 May 2022 23:02:21 +0300 From: Alexey Izbyshev To: Adhemerval Zanella Cc: Florian Weimer , libc-alpha@sourceware.org Subject: Re: [PATCH] linux: Fallback to fork and exec for clone fail on posix_spawn (BZ#29115) In-Reply-To: References: <20220502180605.1510951-1-adhemerval.zanella@linaro.org> User-Agent: Roundcube Webmail/1.4.4 Message-ID: <450b4ade5d5fafd551eb63f85c2a8286@ispras.ru> X-Sender: izbyshev@ispras.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 May 2022 20:02:23 -0000 On 2022-05-02 22:57, Adhemerval Zanella wrote: > On 02/05/2022 16:42, Adhemerval Zanella wrote: >> >> >> On 02/05/2022 16:15, Alexey Izbyshev wrote: >>> Shouldn't also __spawni_child() check whether posix_spawn actions are >>> trying to do something with the error pipe write end (e.g. to close >>> it, to dup() it or dup2() over it, etc.) and prevent that? >> >> Yeah we should, we need to either duplicate the file descriptor if a >> file operation >> might clobber it and return EBADF for dup2 file action. > > And using a pipe brings another issue with closefrom where the file > action might > close the pipe's end and using a dup will help much (since we can not > be sure > if the duplicate file descriptor will be lower than the closefrom > value). Maybe > using mmap with MAP_SHARED would be better here. But closefrom() is implemented via close_range() on Linux, so can we just close_range(start, pipe_fd - 1) and close_range(pipe_fd + 1, INT_MAX)? (Ignoring edge conditions here). Alexey