From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id D8302385840C for ; Fri, 28 Jan 2022 23:05:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D8302385840C Received: by mail-ot1-x335.google.com with SMTP id d18-20020a9d51d2000000b005a09728a8c2so7189401oth.3 for ; Fri, 28 Jan 2022 15:05:20 -0800 (PST) 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=7oQkY1z6q496G6N5WKDqWHo9XJKwWikix6uNahLsSPI=; b=TR5/GeUCz3b3qk+ybcPmQjkb38ErALkXb/hiS6oQDvIfCTGS4GLSdbCWjGEQVj1L20 aVW22tBEdMEUvIVo/8dukU9WEovxQ4L1zSWDIqnTP/SlK5chkBs+YQ+OQFKKJh5dDEWI enzNIh0xIyYcs+OY5lJdRvW5HMgXJL2jqwQPDY2LsVxp/PPWKnyEkrVtMHjFGi2Mvpxb iI/wv50y4/adABnh7H4SY1wgfYYNSf1Y5ppZOZzUVAvnZuqz8KfPKMZTGVxfuGWM8Tgr muM0++aE9T35F7Flmi6LqoQabweBoqfivzBt1G1iatklmeWRBCXH2Pl74pmZPqW57N36 jG1A== X-Gm-Message-State: AOAM533OXoGw8+obMZRMJm88jBkBjbNpsjd7QZQ0vzYpLmbgE1trNpwz /BDnrphdlnRLdRo92+Zx68w93tdl10845Q== X-Google-Smtp-Source: ABdhPJx4UKptYcCG6xQyg+RHKXxRLjVQ5K7rUjkPrPPHIjHYe5ttiM6wboawWhVKfJupooYd9Agnlw== X-Received: by 2002:a9d:7306:: with SMTP id e6mr6123718otk.315.1643411120182; Fri, 28 Jan 2022 15:05:20 -0800 (PST) Received: from ?IPV6:2804:431:c7ca:709a:aad4:4e8:bc05:17ad? ([2804:431:c7ca:709a:aad4:4e8:bc05:17ad]) by smtp.gmail.com with ESMTPSA id 4sm7025216oon.21.2022.01.28.15.05.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jan 2022 15:05:19 -0800 (PST) Message-ID: Date: Fri, 28 Jan 2022 20:05:17 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH 2/2] linux: posix_spawn: return EINVAL on argc < 1 Content-Language: en-US To: Joseph Myers Cc: =?UTF-8?Q?Cristian_Rodr=c3=adguez?= , libc-alpha@sourceware.org References: <20220128133937.9555-1-crrodriguez@opensuse.org> From: Adhemerval Zanella In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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: Fri, 28 Jan 2022 23:05:22 -0000 On 28/01/2022 15:03, Joseph Myers wrote: > On Fri, 28 Jan 2022, Adhemerval Zanella via Libc-alpha wrote: > >> Since Linux is discussing changing on execve syscall [1], I think it would be >> better to the same not only for posix_spawn, but rather to all execve >> functions. >> >> And since all ends up calling execve, even posix_spawn, I think it would be >> better to: >> >> 1. Make posix/execve.c call __execveat. >> 1.1. It would also allow remove the Hurd implementation 'sysdeps/mach/hurd/execve.c' >> 2. Add the proper check on generic, Linux, and Hurd implementation execveat. >> 2.1. Maybe even add __execveat_internal that just issue the syscall and let the >> generic wrapper handle the argument parsing. >> 3. Add a regression test. >> >> I also think returning EINVAL is better than the kernel EFAULT one (it >> seems that the last message on thread does settle for that). > > Apart from the need for a test, a note under "Deprecated and removed > features, and other changes affecting compatibility" in NEWS, and > documentation in the manual if there's an appropriate place for it to go > (there is for execve; posix_spawn isn't documented in the manual at all), We can add a note on deprecated and removed features, but I am not sure if would make any difference now that kernels will changes the semantic anyway and it will cause compatibility issues anyway. > I'd also think it would be better in terms of application compatibility to > construct an array { pathname, NULL } and pass that in place of argv when > argv[0] is NULL (*not* when argv[0] is an empty string, I don't see a > problem with an empty string there), rather than returning an error. I am really not sure about keeping compatibility here, applications running on newer kernels with older glibc will need to handle it anyway and I think it is good move forward to mask this wrong usage. Also, other system already explicit disallow it, so it is a good indication that portable programs should not rely on this behavior. > That's more similar in spirit to what we do with reopening fds 0, 1, 2 if > not open at startup (but I'd also tend to think the kernel is a better > place than libc to deal with this, given that anything the *calling* > program does in userspace with execve can't avoid security issues in the > *called* program with NULL argv[0] - in the case of fds 0, 1, 2 glibc is > addressing the problem state directly in the *called* process). > > I don't think the "should" in the POSIX specification of posix_spawn is > very relevant as a justification for the patch (it only requires things > for Strictly Conforming POSIX Applications). >