From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id BBDDA3858C50 for ; Mon, 2 May 2022 20:04:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BBDDA3858C50 Received: by mail-oi1-x22f.google.com with SMTP id r1so16082785oie.4 for ; Mon, 02 May 2022 13:04:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=HRb97qh7x5xAwZ30foE4mj7A/vjzyETww/3MyQN3JQw=; b=krtuooeUxceGQsRB83wVXdSxmCkrXfIGR49wJ3F59EQbyunjd2X5k1A6/J6w+8kg1K 90EwGH5m124Px6TQ4I8mDBCD+D+u4WsfW/YZnenvMr6I4+iXb5BVc/5Ghn1klMbNXNWg ntp6SaSzyG0GYCq47eqvJkGKwFjGZw/AZBzG3CKBENskEMfuX2VmmkiFg2OpLz8hk9sY b/Su6ul5Q9+WbdcAC1mvqSiar6OMoa2phr1gq87KCJBUTC1pmfK4G/96GSvhi6D5xwR6 xD79wool44+44yXQe6dD/ss3QEe57CvhptGqBID8ThVlWlFLbofu1x3hLYBPDJK69aAx 5Oug== X-Gm-Message-State: AOAM533FGV72xo2ZjoqNJR8LJrmS1+WhrUdWo/0Ki2vcfxG81sAOJW0q eUwgFAfQxe6paCtH8rE5o5K1dpxdMlTLPQ== X-Google-Smtp-Source: ABdhPJxftu1/pxbnhhjbbCi9lygGvydq56BeDCPgdwwY6f+UmxGRuptYBbs5peovIwyPXJUanoL2kg== X-Received: by 2002:a05:6808:18a2:b0:325:ce71:e16 with SMTP id bi34-20020a05680818a200b00325ce710e16mr404284oib.94.1651521860172; Mon, 02 May 2022 13:04:20 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:726:60d4:f990:5a9a:e5b1? ([2804:431:c7cb:726:60d4:f990:5a9a:e5b1]) by smtp.gmail.com with ESMTPSA id w23-20020a4aca17000000b0035eb4e5a6b6sm4124953ooq.12.2022.05.02.13.04.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 May 2022 13:04:19 -0700 (PDT) Message-ID: <3d8e378d-4dfd-f98e-1d8b-92acf56f407e@linaro.org> Date: Mon, 2 May 2022 17:04:16 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] linux: Fallback to fork and exec for clone fail on posix_spawn (BZ#29115) Content-Language: en-US To: Alexey Izbyshev Cc: Florian Weimer , libc-alpha@sourceware.org References: <20220502180605.1510951-1-adhemerval.zanella@linaro.org> <450b4ade5d5fafd551eb63f85c2a8286@ispras.ru> From: Adhemerval Zanella In-Reply-To: <450b4ade5d5fafd551eb63f85c2a8286@ispras.ru> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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:04:22 -0000 On 02/05/2022 17:02, Alexey Izbyshev wrote: > 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). It should work indeed.