[{"id":3669266,"web_url":"http://patchwork.ozlabs.org/comment/3669266/","msgid":"<87h5q37oik.fsf@gmail.com>","list_archive_url":null,"date":"2026-03-25T18:27:47","subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","submitter":{"id":88687,"url":"http://patchwork.ozlabs.org/api/people/88687/","name":"Collin Funk","email":"collin.funk1@gmail.com"},"content":"Lucas Chollet <lucas.chollet@free.fr> writes:\n\n> Hello all,\n> This is my first contribution here, so I hope I got everything right.\n> I tested this patch on my Linux x86_64 machine with `make check` and\n> got no regressions compared to master.\n>\n> 8<\n>\n> This patch makes `posix_spawn_file_actions_addfchdir` return EBADF on\n> negative file descriptors. This is mandated by POSIX and similar to what\n> is already done in addopen/addclose.\n>\n> Signed-off-by: Lucas Chollet <lucas.chollet@free.fr>\n> ---\n>  posix/spawn_faction_addfchdir.c | 3 +++\n>  1 file changed, 3 insertions(+)\n>\n> diff --git a/posix/spawn_faction_addfchdir.c b/posix/spawn_faction_addfchdir.c\n> index a3df6df489..b51139a61f 100644\n> --- a/posix/spawn_faction_addfchdir.c\n> +++ b/posix/spawn_faction_addfchdir.c\n> @@ -28,6 +28,9 @@ posix_spawn_file_actions_addfchdir_np (posix_spawn_file_actions_t *actions,\n>  {\n>    struct __spawn_action *rec;\n>  \n> +  if (!__spawn_valid_fd (fd))\n> +    return EBADF;\n> +\n>    /* Allocate more memory if needed.  */\n>    if (actions->__used == actions->__allocated\n>        && __posix_spawn_file_actions_realloc (actions) != 0)\n\nThank you for the patch!\n\nHowever, I want to note here that __spawn_valid_fd() checks if the file\ndescriptor is greater than getdtablesize(). Using it here, along with\nsome (all?) other places it is used, is incorrect. POSIX states [1]:\n\n    [EBADF]\n        The value specified by fildes is negative.\n\n    It shall not be considered an error for the path or fildes argument\n    passed to these functions to specify a pathname or file descriptor\n    for which the specified operation could not be performed at the time\n    of the call. Any such error shall be detected when the associated\n    file actions object is later used during a posix_spawn() or\n    posix_spawnp() operation.\n\nI noticed glibc's misbehavior when working on Gnulib last year, but\nevidently forgot to fix it...\n\nCollin\n\n[1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addchdir.html\n[2] https://lists.gnu.org/archive/html/bug-gnulib/2025-10/msg00118.html","headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=FdGofjVZ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=FdGofjVZ","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","sourceware.org; spf=pass smtp.mailfrom=gmail.com","server2.sourceware.org;\n arc=none smtp.remote-ip=2607:f8b0:4864:20::1236"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgwQ65T7Tz1y1K\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 05:28:14 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id A40DB4BB5890\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 18:28:12 +0000 (GMT)","from mail-dl1-x1236.google.com (mail-dl1-x1236.google.com\n [IPv6:2607:f8b0:4864:20::1236])\n by sourceware.org (Postfix) with ESMTPS id 2462B4BAD14A\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 18:27:50 +0000 (GMT)","by mail-dl1-x1236.google.com with SMTP id\n a92af1059eb24-12a74039dc6so132672c88.0\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 11:27:50 -0700 (PDT)","from fedora (c-73-93-224-2.hsd1.ca.comcast.net. [73.93.224.2])\n by smtp.gmail.com with ESMTPSA id\n a92af1059eb24-12aa7274231sm515343c88.8.2026.03.25.11.27.48\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 Mar 2026 11:27:48 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org A40DB4BB5890","OpenDKIM Filter v2.11.0 sourceware.org 2462B4BAD14A"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 2462B4BAD14A","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 2462B4BAD14A","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774463270; cv=none;\n b=mEMhXpG/IMb5cq8qbTpukt5QRKJNY2qxhd+ua03tGKWBfoOK7w8q07eXIZ31EROKX3jFiIwZmHDl4iYOKsbBiZ5tjH1WUuxcHDX0nmBeAU+r2Xa8YX61V4t1oiZpQAjMIQA+4kq+E4A2uuYEET5TWWBfo7OdEbmj9PVrOQjRRhY=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774463270; c=relaxed/simple;\n bh=EO9+FprxX7vTb/WdYSlimPhs7aJ64xUGv/vYzqy+Ah4=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=WGHURd2Viscv5lUfHw8RP2YofJD7MFLocxV+5Nek/nb1yVAIMzQhNSX2Bnl7CVc34dIqJ65Kvsa+DSa6GFHVDWOjO92icp27EpH9PQa1HR2K9JlmD7ptSVCPL8B37r6+sPt04WrYs1e7R1g9Js8otPBZsXhlJvwpvfZ81KZW9Y8=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1774463269; x=1775068069; darn=sourceware.org;\n h=mime-version:user-agent:message-id:date:references:in-reply-to\n :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=HmfA6vVrIlOUAigCS/5uSG/L5cspcLcnfrDev10tMww=;\n b=FdGofjVZ4nrcnZR+c3BlcUGAK+DfSDfWDPZJGMVIac/JfOKThEmet0EyyBRahud92t\n wqHd04zrfcz9h02k8HXaLkc70IcAD//+gcED7an7Ndjgy+rtCte9BlO0Ypl4FXmGsjb4\n tuBYMMw6xfUBeC4m0/JUEfO/6L2Jdx2N2z2URe2+5zR3B66VifHM1N/CUxDminVuz45M\n PHa/9OePbWTzl36J+nhmQhxYyS8FiuYO8dyVPQQQ4KGEcLjzzvnN+5BJyob+sgLja8xW\n KO1sRf+DcZZLcBlODM6LqJX4A8vS00UQS0h3M53lgIyOFnbBJqx/FuxRxP4VdCgaa3Se\n 0mdg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774463269; x=1775068069;\n h=mime-version:user-agent:message-id:date:references:in-reply-to\n :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n :date:message-id:reply-to;\n bh=HmfA6vVrIlOUAigCS/5uSG/L5cspcLcnfrDev10tMww=;\n b=eCOBW2fdf70wmnCCsRQYPR84rXIRqAUHqgkblKkMnIAWoTE26fLMg2M/4y/0D6bRB5\n YOxDKmanblSJQmoxe6L1pypirmtgDqvyb3etrDPPIzqxnqYKj5tjRo3MRgLjYqnCYO+F\n paqD4FwzY5RJtHfjFu6fXnPnP0Y1wtJhHeR9bEKWI5ZQwjK8kCEeK+X8WfJym3RHOcoH\n yPFNuOLcRoZBj/KSFaxwxmyNYP+Vk8p1hQyNPDP6az+0cDKoBOiRRK0/tOj0Sq+BLCf9\n kwP3azu4w6YpQSMpPMIgPJ4UmxYhoQhsmpnghOfwcrwZLX3sjth+aLEPKjRS+3/bP/Lw\n tj6w==","X-Gm-Message-State":"AOJu0YzSu36BAHcEsD6CiLJ46AF7w9yyhElrvccgd/FxEQ2dnQetYHS5\n ZWOQ9G9DNOzQUZo1DkKwO516JSQBfcg4BSiCmOzGE0MsJfsymnWg171LE31kXg==","X-Gm-Gg":"ATEYQzyCoAiBR06dPpaDhqcLm8l42z68EIgI82AgO6Hvtr0GHxqz1HIeDHbOw5k1Xvj\n A65VBg75O1ZrhRkyRVSUVMRqZryCUWPZHgp8fL2SIa6z5GCMJfKhGJx036MmcB42oMuTjtszuAI\n 0F0wL1Ogm9OK4WESrnuvU08hcYwSWa6YUYoqADrHblIdVQdRbSzCUqNotYbk5SYL0kg6nlZ3mtF\n ITGUbMHABlhfxDv4uGKJpFTe5Tzb0WgKCwh5qz/B25sPr+pHemANvmrXaWj4R1+HIzSo6PFrjpF\n YpJJNmrcicozbP+6oOGHK9CROSw9ZTX+2Om0EznU5Ebwk/1KCWdxvH9MLBt/06jxqTIImS8xQ4F\n CWKYn54ap3UwrrbEegmkcGs3+THxdJKQd6SX+o2Z4PHhuGBf3MFZM7NOHuZfyJLA7olVM6uom3o\n jJ+Jsmut9BKCtfAYvCxvqtlyAAH77hpuCO7iC9SI8rzqR390NrFkB5","X-Received":"by 2002:a05:7022:6a4:b0:12a:8ea4:24d with SMTP id\n a92af1059eb24-12a96ede806mr2248739c88.19.1774463268937;\n Wed, 25 Mar 2026 11:27:48 -0700 (PDT)","From":"Collin Funk <collin.funk1@gmail.com>","To":"Lucas Chollet <lucas.chollet@free.fr>","Cc":"libc-alpha@sourceware.org","Subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","In-Reply-To":"<20260325140452.1825551-2-lucas.chollet@free.fr>","References":"<20260325140452.1825551-2-lucas.chollet@free.fr>","Date":"Wed, 25 Mar 2026 11:27:47 -0700","Message-ID":"<87h5q37oik.fsf@gmail.com>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","Content-Type":"text/plain","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"}},{"id":3669281,"web_url":"http://patchwork.ozlabs.org/comment/3669281/","msgid":"<90d68c74-29b4-4b00-975d-1da810583c68@linaro.org>","list_archive_url":null,"date":"2026-03-25T19:15:02","subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","submitter":{"id":66065,"url":"http://patchwork.ozlabs.org/api/people/66065/","name":"Adhemerval Zanella Netto","email":"adhemerval.zanella@linaro.org"},"content":"On 25/03/26 15:27, Collin Funk wrote:\n> Lucas Chollet <lucas.chollet@free.fr> writes:\n> \n>> Hello all,\n>> This is my first contribution here, so I hope I got everything right.\n>> I tested this patch on my Linux x86_64 machine with `make check` and\n>> got no regressions compared to master.\n>>\n>> 8<\n>>\n>> This patch makes `posix_spawn_file_actions_addfchdir` return EBADF on\n>> negative file descriptors. This is mandated by POSIX and similar to what\n>> is already done in addopen/addclose.\n>>\n>> Signed-off-by: Lucas Chollet <lucas.chollet@free.fr>\n>> ---\n>>  posix/spawn_faction_addfchdir.c | 3 +++\n>>  1 file changed, 3 insertions(+)\n>>\n>> diff --git a/posix/spawn_faction_addfchdir.c b/posix/spawn_faction_addfchdir.c\n>> index a3df6df489..b51139a61f 100644\n>> --- a/posix/spawn_faction_addfchdir.c\n>> +++ b/posix/spawn_faction_addfchdir.c\n>> @@ -28,6 +28,9 @@ posix_spawn_file_actions_addfchdir_np (posix_spawn_file_actions_t *actions,\n>>  {\n>>    struct __spawn_action *rec;\n>>  \n>> +  if (!__spawn_valid_fd (fd))\n>> +    return EBADF;\n>> +\n>>    /* Allocate more memory if needed.  */\n>>    if (actions->__used == actions->__allocated\n>>        && __posix_spawn_file_actions_realloc (actions) != 0)\n> \n> Thank you for the patch!\n> \n> However, I want to note here that __spawn_valid_fd() checks if the file\n> descriptor is greater than getdtablesize(). Using it here, along with\n> some (all?) other places it is used, is incorrect. POSIX states [1]:\n> \n>     [EBADF]\n>         The value specified by fildes is negative.\n> \n>     It shall not be considered an error for the path or fildes argument\n>     passed to these functions to specify a pathname or file descriptor\n>     for which the specified operation could not be performed at the time\n>     of the call. Any such error shall be detected when the associated\n>     file actions object is later used during a posix_spawn() or\n>     posix_spawnp() operation.\n> \n> I noticed glibc's misbehavior when working on Gnulib last year, but\n> evidently forgot to fix it...\n\nIndeed it seems that POSIX 2018 [1] changed the error handling for possible\ninvalid file descriptors.   It seems that __spawn_valid_fd checks are not\nrequired anymore.\n\n[1] https://austingroupbugs.net/view.php?id=418 \n\n> \n> Collin\n> \n> [1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addchdir.html\n> [2] https://lists.gnu.org/archive/html/bug-gnulib/2025-10/msg00118.html","headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=P6AMjkAJ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=P6AMjkAJ","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=linaro.org","sourceware.org; spf=pass smtp.mailfrom=linaro.org","server2.sourceware.org;\n arc=none smtp.remote-ip=2607:f8b0:4864:20::a2b"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgxSm4mdsz1xy3\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 06:15:35 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id D565A4BAD15F\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 19:15:31 +0000 (GMT)","from mail-vk1-xa2b.google.com (mail-vk1-xa2b.google.com\n [IPv6:2607:f8b0:4864:20::a2b])\n by sourceware.org (Postfix) with ESMTPS id 0E3F04B9DB51\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 19:15:09 +0000 (GMT)","by mail-vk1-xa2b.google.com with SMTP id\n 71dfb90a1353d-56cfe7b2344so105489e0c.2\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 12:15:09 -0700 (PDT)","from ?IPV6:2804:1b3:a7c1:90ea:f484:49d6:b6f2:cec1?\n ([2804:1b3:a7c1:90ea:f484:49d6:b6f2:cec1])\n by smtp.gmail.com with ESMTPSA id\n 71dfb90a1353d-56d31bf74basm1190115e0c.2.2026.03.25.12.15.04\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Wed, 25 Mar 2026 12:15:06 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org D565A4BAD15F","OpenDKIM Filter v2.11.0 sourceware.org 0E3F04B9DB51"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 0E3F04B9DB51","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 0E3F04B9DB51","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774466109; cv=none;\n b=JTJ1sLrk33nyD3uYJCMwGaDs2lT3wOOQb7RzUCnZfNhH8v7ZwRt5u4MbObqOhOsyoNghRPoL0KwB3A5QXovyHKm0RpP2Ka5r+7szTFQEnxupnUrfGbJNtxdMI3qtUmta8IGZNegAeofeXEP7BgAy3LHqIhuAZyHpniez7KRYNbA=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774466109; c=relaxed/simple;\n bh=wgVRkdqS6oQOeLoTwvoiQVaKLD77bBAkw/bcTWe/BP0=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=EL6d0/DxEbjOeHwv7IKWaJMhsoe0BDn3JOOZwMYBoi8Sx6BbWHuTJOvfygBto6G83EIxgCMOcSYV9tO6Y93uhw7why5ASBZOrOgmGS9YayxveyiIsg3h6X71WtfNvaNSCTdlkE2cx/wC4BqSVBy9atr0Fz1gZJgiO2v4/lrAdGY=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1774466108; x=1775070908; darn=sourceware.org;\n h=content-transfer-encoding:in-reply-to:organization:from\n :content-language:references:cc:to:subject:user-agent:mime-version\n :date:message-id:from:to:cc:subject:date:message-id:reply-to;\n bh=PLtrfPBx5gVWXjqh6JqZj81q7/co1W9FqbOe9QzOijU=;\n b=P6AMjkAJnu0Pm0YxAT7OCYTDycy8Lg2ON1dAgpjvTiWwotn/vUTjwIDdU5OvsxOX7A\n ayF2/CPRo/SpSFwLp0obEH0ysNICyR4DhZppwOXCA5ZUNmTUcmlsEX8pUKlDiLrOvGNL\n A66YGkH6CcRWhIprgJ6C7CafwBDEkiadeu+Ws2emvH/JWnN/lMaZrg2OYsCUqXaWyuKn\n W5jZmiItVtcdv5KDeSxduhBwSpZobWb0ImZOczJVxcSFpGsg1aQ5mxzn4mntNhhJY+WX\n nenjaVEyrAlwaIsczO+eoG7WC3/e8yuzLGfzgQ5f7AVCdbj3pLcvYDyPInH3MmaGKc8F\n gQRw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774466108; x=1775070908;\n h=content-transfer-encoding:in-reply-to:organization:from\n :content-language:references:cc:to:subject:user-agent:mime-version\n :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=PLtrfPBx5gVWXjqh6JqZj81q7/co1W9FqbOe9QzOijU=;\n b=D/oFgewb+fj+oNFvuvlNu/ML5FDLxBN8o0ZTha+wg8wFHrkIjFvX0WeQNHdKCQyouw\n 5Qj6zX/2ezGzQxNLyNxA2S7PXV88fNI++F/cFQHwkSjIp7osXtMx9Hm7ci61fuCxa+LC\n vG86o+WB31mDIKpaPMVqDjDGaLLedBo117zxTwra1/K8rNAr3Dvs287HfhEh34w07sdP\n 3fOh1MXbLTGbdu04Zo4txy7QakEWm9pJj9dcBcvMPlLkusGHSKuP0BnoY2qwmkcwIYMa\n YawDOEYfU+RsyY3jbg1Q8HSxHsmZE1sWlU3qPVc8hERiKo18pRvsyTVJdXZJ0TPFn7Hb\n H08Q==","X-Gm-Message-State":"AOJu0YwSBaA5M1xxwvejp0+z1RT3btP0yWM5j86H1F1Y6Ab27G1JJe9+\n W99la0tEPMfzX2Wd60t8/n3T4jb9UNDg11k9IMxbzdbpAuS89Zv0Q2S5ubNptyYI7l4=","X-Gm-Gg":"ATEYQzy5AMRZi5HVqTf4pnx+qX5esk3h+TLizxvisKCLObSFf8yuu5EJm0j2xVMqcMl\n FND0EPvL9b2Xratw8aiStMSY2/bG3inTZdCUOCeo49S7K84WqHySu0blmaAu5VJ+NvrZTfkBRdQ\n UXypjJJk9e7OXLs8tlW7XxXNNKl3jCIuZ4Z8SLTo5KfdfpBfNIJR/+mu+8q5YgtiFBsOejrjQPi\n q6A4iUG/LiVQYuR4FsVvrOXzYIR4fbaa0gU5dBADPkMeUEljqMZqDTBKBC5ZYnvOBZWT9Lhnzfu\n RWLPPZafA1mDzBU2Ea/D2kUNVG2U0WlEhZ6oCzM5E0HTuxVG7eW2q0g/RQrTpuBJ1X2C8qni6Ap\n ICLe0xXEe8cm2DpcwX0T+IuMl397dG73s2NxSkiwmzMulEhexHL0/87SSmx006S5IxthwMOmj5O\n CX2tJRHdRZ2g6mw9wQ1m/4aCYiBsrQqI1FEfg4mGOprOeE/29q1qcjlE6wktPt18Mc02kg7FliQ\n sJYXUY87Xn22y3yZ0q8TpFYe8hoOHRoYLpdxPkdj5TM","X-Received":"by 2002:a05:6122:a08:b0:56a:fc35:9664 with SMTP id\n 71dfb90a1353d-56d21f2340bmr2646782e0c.3.1774466108175;\n Wed, 25 Mar 2026 12:15:08 -0700 (PDT)","Message-ID":"<90d68c74-29b4-4b00-975d-1da810583c68@linaro.org>","Date":"Wed, 25 Mar 2026 16:15:02 -0300","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","To":"Collin Funk <collin.funk1@gmail.com>,\n Lucas Chollet <lucas.chollet@free.fr>","Cc":"libc-alpha@sourceware.org","References":"<20260325140452.1825551-2-lucas.chollet@free.fr>\n <87h5q37oik.fsf@gmail.com>","Content-Language":"en-US","From":"Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>","Organization":"Linaro","In-Reply-To":"<87h5q37oik.fsf@gmail.com>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"}},{"id":3669332,"web_url":"http://patchwork.ozlabs.org/comment/3669332/","msgid":"<62a973ce-6a60-432b-b847-5b5a8e533293@linaro.org>","list_archive_url":null,"date":"2026-03-25T21:19:00","subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","submitter":{"id":66065,"url":"http://patchwork.ozlabs.org/api/people/66065/","name":"Adhemerval Zanella Netto","email":"adhemerval.zanella@linaro.org"},"content":"On 25/03/26 16:15, Adhemerval Zanella Netto wrote:\n> \n> \n> On 25/03/26 15:27, Collin Funk wrote:\n>> Lucas Chollet <lucas.chollet@free.fr> writes:\n>>\n>>> Hello all,\n>>> This is my first contribution here, so I hope I got everything right.\n>>> I tested this patch on my Linux x86_64 machine with `make check` and\n>>> got no regressions compared to master.\n>>>\n>>> 8<\n>>>\n>>> This patch makes `posix_spawn_file_actions_addfchdir` return EBADF on\n>>> negative file descriptors. This is mandated by POSIX and similar to what\n>>> is already done in addopen/addclose.\n>>>\n>>> Signed-off-by: Lucas Chollet <lucas.chollet@free.fr>\n>>> ---\n>>>  posix/spawn_faction_addfchdir.c | 3 +++\n>>>  1 file changed, 3 insertions(+)\n>>>\n>>> diff --git a/posix/spawn_faction_addfchdir.c b/posix/spawn_faction_addfchdir.c\n>>> index a3df6df489..b51139a61f 100644\n>>> --- a/posix/spawn_faction_addfchdir.c\n>>> +++ b/posix/spawn_faction_addfchdir.c\n>>> @@ -28,6 +28,9 @@ posix_spawn_file_actions_addfchdir_np (posix_spawn_file_actions_t *actions,\n>>>  {\n>>>    struct __spawn_action *rec;\n>>>  \n>>> +  if (!__spawn_valid_fd (fd))\n>>> +    return EBADF;\n>>> +\n>>>    /* Allocate more memory if needed.  */\n>>>    if (actions->__used == actions->__allocated\n>>>        && __posix_spawn_file_actions_realloc (actions) != 0)\n>>\n>> Thank you for the patch!\n>>\n>> However, I want to note here that __spawn_valid_fd() checks if the file\n>> descriptor is greater than getdtablesize(). Using it here, along with\n>> some (all?) other places it is used, is incorrect. POSIX states [1]:\n>>\n>>     [EBADF]\n>>         The value specified by fildes is negative.\n>>\n>>     It shall not be considered an error for the path or fildes argument\n>>     passed to these functions to specify a pathname or file descriptor\n>>     for which the specified operation could not be performed at the time\n>>     of the call. Any such error shall be detected when the associated\n>>     file actions object is later used during a posix_spawn() or\n>>     posix_spawnp() operation.\n>>\n>> I noticed glibc's misbehavior when working on Gnulib last year, but\n>> evidently forgot to fix it...\n> \n> Indeed it seems that POSIX 2018 [1] changed the error handling for possible\n> invalid file descriptors.   It seems that __spawn_valid_fd checks are not\n> required anymore.\n> \n> [1] https://austingroupbugs.net/view.php?id=418 \n\nHowever, the POSIX requirements seems conflicting.  It states that\n\n  [EBADF]\n  The value specified by fildes is negative or greater than or equal to {OPEN_MAX}.\n\nBut at the same time it states that values potentially greater than\nOPEN_MAX are not necessary an error:\n\n  \"It shall not be considered an error for the fildes argument passed to these\n   functions to specify a file descriptor for which the specified operation could \n   not be performed\"\n\nSo I think the 'EBADF' is a 'shall fail' only for negative values,\nwhich seems the interpretation of musl and *BSD. I think it makes more sense.","headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=ei9QexCf;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=ei9QexCf","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=linaro.org","sourceware.org; spf=pass smtp.mailfrom=linaro.org","server2.sourceware.org;\n arc=none smtp.remote-ip=2607:f8b0:4864:20::932"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fh0Dk0TBXz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 08:20:22 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 26EEF4BB58E0\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 21:20:20 +0000 (GMT)","from mail-ua1-x932.google.com (mail-ua1-x932.google.com\n [IPv6:2607:f8b0:4864:20::932])\n by sourceware.org (Postfix) with ESMTPS id C36024BB5890\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 21:19:04 +0000 (GMT)","by mail-ua1-x932.google.com with SMTP id\n a1e0cc1a2514c-950c41532e1so185983241.1\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 14:19:04 -0700 (PDT)","from ?IPV6:2804:1b3:a7c1:90ea:f484:49d6:b6f2:cec1?\n ([2804:1b3:a7c1:90ea:f484:49d6:b6f2:cec1])\n by smtp.gmail.com with ESMTPSA id\n a1e0cc1a2514c-951be56f28esm1444587241.10.2026.03.25.14.19.02\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Wed, 25 Mar 2026 14:19:03 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 26EEF4BB58E0","OpenDKIM Filter v2.11.0 sourceware.org C36024BB5890"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org C36024BB5890","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org C36024BB5890","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774473544; cv=none;\n b=snsM32xpbFpEFq/0dBPkERwWueFeWoe5H/n4L0ie0QxRd58383NEdg2eoT1kmUICjadqNGnwV7ovIqInfb6gCk5FMPQQKqxn3m1B7xdw7oW3tON74g5Cb/iR/XUgvw+kC4uIUnAa14eYMKJneW8PIt3AsQ7huYt4mRD9jBE+4d4=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774473544; c=relaxed/simple;\n bh=K9eeYzvWObHQKqBy4uCSLsCezquM+GHV+ByeFax9rEw=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To;\n b=ptd3qCOWeWPSv6itqlcnOHOHiIR/Bpq3FcLOHGLEK6FN/KTMHCUAZERPsH02i8N3A9VWIcjgMAuJIICBwcFqaa7EuaBj9ENvGbDes/OTryxnW27mZ7osG8dVmim2ohsFZwvRuQbb/x8jLMz3QS+lSUfXALW3jp1UTk3G8LU+hHc=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1774473544; x=1775078344; darn=sourceware.org;\n h=content-transfer-encoding:in-reply-to:organization:content-language\n :references:cc:to:from:subject:user-agent:mime-version:date\n :message-id:from:to:cc:subject:date:message-id:reply-to;\n bh=mtZaC/umZvYJDNVBNpz4NBI/jvbYEbVFGdTXKvMhUyY=;\n b=ei9QexCftzzhaFIq627JC1KVbIEo3qT4QXMMAvr566JthuS7sArBCrDVL6E7XQSGST\n ApGfEShHW2ynGLhRs2nlcmq6RIl8fUqO0zuoNhXb4Pb3+od4XQFZCrVLmHu/dVWodU4j\n k2GyIJnnkMO5Ezu7SCHeFhCVw3ISt0NgsgtnQTlCzyHqrov8UhGPASz2r5LsCK89RyUN\n ODKDAfSIqRBPLcB57HjonbGDjuK0AR/3e4mv7IJ8MugYuOTOUeMsHtRV4Ga4XgkKp6yv\n kqqeqNFRrpYpt7o9NP8nPcX7a2mqHlMadixC2vMAt47gcqyG2EVsnxbp4RI3mLjkilsQ\n TqYA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774473544; x=1775078344;\n h=content-transfer-encoding:in-reply-to:organization:content-language\n :references:cc:to:from:subject:user-agent:mime-version:date\n :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=mtZaC/umZvYJDNVBNpz4NBI/jvbYEbVFGdTXKvMhUyY=;\n b=qLNhjP9Mfl5if6Xb79szBxSto1VQELh73rdUykZVjC081sIAlrSd++DGuNK0q+nkSS\n CH7LKRaO9fbXNtjMGs5tfZ4TbX+54CseQ8BDLeuImeHaX/5wTbjOQdDlWpeZkU19Irk3\n LJlwEmu3ZNBnyYP82WPEkq/Qzng9XLiqXzrRI8+qyANHKeqiqaLYEFHhlZwILxbTNkQ7\n FPHRgWHKdXC/PWWpfiVq0tWWjTFJXUNARCDQm1xY56xt2m4WbOKueWEP/hjubgp7D74w\n qt+v7B0PE5oHLCyYRhGc7hdTXrqvISp1yl7gFk5gFczAG6Sd2mrKt8+EnA64p2RYcUZa\n R7ug==","X-Gm-Message-State":"AOJu0Yx+oKKC5Rfxtimhr+bgrhYUDZCp5oeQz8ctgS3SuKwjOKbf3U8A\n whyv7WIOiEJoxUakaYN1hZQqq77Me5iT1Rf4I6xVbcKU0zBttvnnWsTSNUiOXvz+geg=","X-Gm-Gg":"ATEYQzyJgpWxqnGawkILyrRXrfdCCIT1fkEWVUfeb/XUd1af4kQBSh5JtsHUrxz4pSl\n xJF4y3E/IY3PbfERDYQp5bnrlCMyIAB3O3UadVsN1oZ/KpL4bZEs9JPFItdUb8YonVybkZczQax\n tRkjrw9lwSJ/Ji+46SCmGrVAqZqzPuXNdJnSe3qEHEACXIoVhU+KMWh/SWseNqROCXORG7yBGrz\n ygzcQ+8UOL+fGkCEHGY03j0AkvxYlkglXyAORJAQRyUsuCxRQ/Oe8pZZ/GXravHFjyKG9R96g3K\n YvmZQMFHjUzNDp88MD2TWZhLWx9Btq/uvuj6dIDoPhlsiap5+C7t059TIwC83qJEGCrKvicjfgt\n UQVC1jBpvwY4l1vUp65H7WyK6EwdmS2cGNUOg1ZXfusT+BaEReaySSiPbCTNRcMWJsVTCXht4aH\n BYVjpsp+cDxnzzl5qaHoGuviTqG/HN88jDuFaqgyEHqqI+PKuIbbYzUImLE+z5QIT80FDrGqsTA\n 2XcQ5w/WH0pY0JVdY7H9n5rky70T1QF/w==","X-Received":"by 2002:a05:6102:3353:b0:602:a15d:f615 with SMTP id\n ada2fe7eead31-60387238126mr2490779137.21.1774473544134;\n Wed, 25 Mar 2026 14:19:04 -0700 (PDT)","Message-ID":"<62a973ce-6a60-432b-b847-5b5a8e533293@linaro.org>","Date":"Wed, 25 Mar 2026 18:19:00 -0300","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","From":"Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>","To":"Collin Funk <collin.funk1@gmail.com>,\n Lucas Chollet <lucas.chollet@free.fr>","Cc":"libc-alpha@sourceware.org","References":"<20260325140452.1825551-2-lucas.chollet@free.fr>\n <87h5q37oik.fsf@gmail.com> <90d68c74-29b4-4b00-975d-1da810583c68@linaro.org>","Content-Language":"en-US","Organization":"Linaro","In-Reply-To":"<90d68c74-29b4-4b00-975d-1da810583c68@linaro.org>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"}},{"id":3669336,"web_url":"http://patchwork.ozlabs.org/comment/3669336/","msgid":"<87341nppku.fsf@gmail.com>","list_archive_url":null,"date":"2026-03-25T21:27:29","subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","submitter":{"id":88687,"url":"http://patchwork.ozlabs.org/api/people/88687/","name":"Collin Funk","email":"collin.funk1@gmail.com"},"content":"Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:\n\n> However, the POSIX requirements seems conflicting.  It states that\n>\n>   [EBADF]\n>   The value specified by fildes is negative or greater than or equal to {OPEN_MAX}.\n>\n> But at the same time it states that values potentially greater than\n> OPEN_MAX are not necessary an error:\n>\n>   \"It shall not be considered an error for the fildes argument passed to these\n>    functions to specify a file descriptor for which the specified operation could \n>    not be performed\"\n>\n> So I think the 'EBADF' is a 'shall fail' only for negative values,\n> which seems the interpretation of musl and *BSD. I think it makes more sense.\n\nLikewise. I assume they just forgot to remove the text from EBADF. I can\nopen a Austin Group bug report and send a patch after confirmation from\nthem.\n\nCollin","headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=BRstKzfv;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=BRstKzfv","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","sourceware.org; spf=pass smtp.mailfrom=gmail.com","server2.sourceware.org;\n arc=none smtp.remote-ip=2607:f8b0:4864:20::1333"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fh0PS0Sv2z1y1x\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 08:27:56 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id D8B934BB3BCD\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 21:27:53 +0000 (GMT)","from mail-dy1-x1333.google.com (mail-dy1-x1333.google.com\n [IPv6:2607:f8b0:4864:20::1333])\n by sourceware.org (Postfix) with ESMTPS id 4E79B4BB3BCF\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 21:27:32 +0000 (GMT)","by mail-dy1-x1333.google.com with SMTP id\n 5a478bee46e88-2c15849aa2cso407441eec.0\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 14:27:32 -0700 (PDT)","from fedora (c-73-93-224-2.hsd1.ca.comcast.net. [73.93.224.2])\n by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2c16edc0473sm992745eec.20.2026.03.25.14.27.30\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 Mar 2026 14:27:30 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org D8B934BB3BCD","OpenDKIM Filter v2.11.0 sourceware.org 4E79B4BB3BCF"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 4E79B4BB3BCF","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 4E79B4BB3BCF","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774474052; cv=none;\n b=qTMON9NkK+yi/C4USHjsSBUHY+BCEbOd6X1REhWGjUwL+MouZo1yZ8j9UAmzoczK6M+yrCP1uAkjBpbq5MYewYygY3xSy673nosXEsxhQq0jFr9zVJZV6nIQjPEanD2OlFbGMXYJp4IK2zZsmk1r45Voj11n1MxqHfK+qUfKEvA=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774474052; c=relaxed/simple;\n bh=j94jcEwL+q9wWHrg+Vs5G9eXEE5JxgApG5hJANeUE4k=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=rwpNpB2e3WUHzPcPZ3lhnHVrSwFRkLGCGsoL9o19aO+ouKOzG/mE/HUuWYHD67OZdOdM1L5RqDO0G16GisWWEYvuUEmo3Z1bORUby/FELaaOHxiagGdxRHUiZGHE7wme30V7zHw2lx4OhW4w9D4AnERtgDVGek33/F7WCe8w96g=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1774474051; x=1775078851; darn=sourceware.org;\n h=mime-version:user-agent:message-id:date:references:in-reply-to\n :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=J5CSbO3twqCdlSX3qkmW+bMgVh2p4OrD4wpuZXmM1sY=;\n b=BRstKzfvkJ9ey4US+P7MrWGJi5m7PZVRi8qcvKcpaEfLv/s74K9O0IzWYib3O4bDQB\n 3y8faxWtdTCczZI7oIUtKzgCROt5SB1DKQjihqv73RQe9c9UJy2V7Vpsy5r5BHHtbAZ1\n e9xUiB/qwkI+dhqbjuUIstrZYGJoIlXFfyYsLH04c8kj3KEYfAfaX34dLL5ck90FdhOE\n 3yuYxQlyGkCFyf3o4e9wnFoMhkRYN4yGyYs9lMPjB6QRUP0twMs3BD1az62U6WkwFg2j\n 51d8jl2l20T1HDWoqfG0DCQEU1ovEKWmeQFMMNCH7YG1dtNQOPgm2GErO2YH8J87KyOu\n 8dGw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774474051; x=1775078851;\n h=mime-version:user-agent:message-id:date:references:in-reply-to\n :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n :date:message-id:reply-to;\n bh=J5CSbO3twqCdlSX3qkmW+bMgVh2p4OrD4wpuZXmM1sY=;\n b=OnkAMt3qSp5jaGXza/udv9bVLY5DBIEJiZS4X1+X3NgEDBOIRdWetWrepcAwftLnbq\n wDEGw1FY5ds1L9tQAh+Sf0bpZgAm4QU/iH0Rj3KgnGwBGym6bHLLJkQ3Oskyt33bhTms\n VxlnEmHnKXc0Oqti7EMRzTXz/5kzlQ9v/B0PAAHUp2/xeMMVeA23TcK1qYaYRx6u3JwJ\n AZiVy9QpZ1si2X1TigXCK4B0vBVaTqD1HYO/dehVROq7eHPV1QGbRpqXOwRKIcYlK/G3\n pSq4ZidJwYwuIZA/e+4Nt3L2jKNZOoLUCIW7gO4kisbChznnS70IFG00ZPFvINQIlsDJ\n myiA==","X-Forwarded-Encrypted":"i=1;\n AJvYcCVINap+d6uny0pUfv4nROrIwMakAEGyEVb9PDxvb+hovTj0udjwSLMsOUaByzDLtjrswIC7fdDfAmNd@sourceware.org","X-Gm-Message-State":"AOJu0YzNjsRclJ6LzVXixYfi4HlceU55PEDI9bBezo0oz8NwWT6FPOcG\n cPbN+GenK5Hi7YT4f6XFVi5ECWSFQvUUXU0tbGzG98Y+qLsyLtmt2sIMjKHp8w==","X-Gm-Gg":"ATEYQzwZNJEBVbahmqoKbZmtIM8FkKTvRC5+x2ePtzlUenerWhmh0REm84zW48x9xwS\n Z8FXgYkmPtPq8eV2iOfP/eORapz7eW3ULeLE+LNADL8CBx/efvzCVfG8Y5jAcmyivZ8uuLOPO71\n ykoSmX+Ebwuf6ZkDVn+U0L+qNnIXdiN2zO0rbR1g99P2w3yWSA4yCNqa2smnfGvyv+KfiMH30g2\n 3Ysdu2FYwTz6guN3nb6WjMxlHPAwaUT3ZITzO1iBXWkC4gt5/wY9xuajKbpxrRtgiy6y9QGqoQN\n FzX/4JHyeu8MC5spzYOH++vO08qPu5MaztsnGvJ1spyN6a2kifOsSWuZafk1dBFg6JLLbCQSxrY\n EWdYngc+hMAUDp/GZI/J1obypMGIt2oDkYPmNBc5ACs0pj5+UzACMAR1NZs42fSx8HCcgNcKJqX\n aF+rajHscTA2ZqO8tYkmZGy0ZNVA+NU7PYuqRW7tN82INxPXQsD+T//ROHziQIlxk=","X-Received":"by 2002:a05:7300:ce82:b0:2c1:2999:4990 with SMTP id\n 5a478bee46e88-2c15d443d6cmr1932739eec.16.1774474051163;\n Wed, 25 Mar 2026 14:27:31 -0700 (PDT)","From":"Collin Funk <collin.funk1@gmail.com>","To":"Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>","Cc":"Lucas Chollet <lucas.chollet@free.fr>,  libc-alpha@sourceware.org","Subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","In-Reply-To":"<62a973ce-6a60-432b-b847-5b5a8e533293@linaro.org>","References":"<20260325140452.1825551-2-lucas.chollet@free.fr>\n <87h5q37oik.fsf@gmail.com>\n <90d68c74-29b4-4b00-975d-1da810583c68@linaro.org>\n <62a973ce-6a60-432b-b847-5b5a8e533293@linaro.org>","Date":"Wed, 25 Mar 2026 14:27:29 -0700","Message-ID":"<87341nppku.fsf@gmail.com>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","Content-Type":"text/plain","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"}},{"id":3669365,"web_url":"http://patchwork.ozlabs.org/comment/3669365/","msgid":"<87341nva04.fsf@igel.home>","list_archive_url":null,"date":"2026-03-25T22:07:23","subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","submitter":{"id":2170,"url":"http://patchwork.ozlabs.org/api/people/2170/","name":"Andreas Schwab","email":"schwab@linux-m68k.org"},"content":"On Mär 25 2026, Adhemerval Zanella Netto wrote:\n\n> However, the POSIX requirements seems conflicting.  It states that\n>\n>   [EBADF]\n>   The value specified by fildes is negative or greater than or equal to {OPEN_MAX}.\n\nhttps://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addfchdir.html\ndoes not say anything about OPEN_MAX.","headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org; dmarc=none (p=none dis=none)\n header.from=linux-m68k.org","sourceware.org; spf=pass smtp.mailfrom=nefkom.net","server2.sourceware.org;\n arc=none smtp.remote-ip=2001:a60:0:28:0:1:25:1"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fh1Hc0Ccwz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 09:07:56 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DDC384B9DB7E\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 22:07:53 +0000 (GMT)","from mail-out.m-online.net (mail-out.m-online.net\n [IPv6:2001:a60:0:28:0:1:25:1])\n by sourceware.org (Postfix) with ESMTPS id 5FB384B9DB46\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 22:07:32 +0000 (GMT)","from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10])\n by mail-out.m-online.net (Postfix) with ESMTP id 4fh1H65W1Gz1sFNf;\n Wed, 25 Mar 2026 23:07:30 +0100 (CET)","from frontend03.mail.m-online.net (unknown [192.168.6.182])\n by mail-out.m-online.net (Postfix) with ESMTP id 4fh1H04l4Sz1sFNM;\n Wed, 25 Mar 2026 23:07:24 +0100 (CET)","from localhost (dynscan3.mnet-online.de [192.168.6.87])\n by mail.m-online.net (Postfix) with ESMTP id 4fh1H03V4zz1rCnv;\n Wed, 25 Mar 2026 23:07:24 +0100 (CET)","from mail.mnet-online.de ([192.168.6.182])\n by localhost (dynscan3.mail.m-online.net [192.168.6.87]) (amavis, port 10024)\n with ESMTP id Gt3JUV0RpN-N; Wed, 25 Mar 2026 23:07:23 +0100 (CET)","from igel.home (aftr-82-135-83-50.dynamic.mnet-online.de\n [82.135.83.50])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mail.mnet-online.de (Postfix) with ESMTPSA;\n Wed, 25 Mar 2026 23:07:23 +0100 (CET)","by igel.home (Postfix, from userid 1000)\n id 398942C1711; Wed, 25 Mar 2026 23:07:23 +0100 (CET)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org DDC384B9DB7E","OpenDKIM Filter v2.11.0 sourceware.org 5FB384B9DB46"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 5FB384B9DB46","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 5FB384B9DB46","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774476452; cv=none;\n b=g/FBKACAlo7MCR3NHHCWf5SnaesSPO59r09Ag19J/QnQSmZ/feyt6daxrwbnab62CE6hmtceEBrp2l5kodgSDlU0hO7KvID8JDt9K3896e076lF0HVQgYvbMErAKtLwgzDwLGoEq/pjrOr3y5t0m4Ap+bVOFG3rvoTYhJZfLVgQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774476452; c=relaxed/simple;\n bh=XuRXJayrgDvPrKi+LWBSHbxvNDx072a2VSgRs9SUiTE=;\n h=From:To:Subject:Date:Message-ID:MIME-Version;\n b=jKb0UG3rByyc8egV3ihP5iDooH3EgGLNzvkYLjfUU4JaewZcQv5pBG7dxGpti6bBMsrfI46PGmMJIvVqkVxWJkAyidjqTlMfTSyjewZz967XqOer/Wnd0Kl+okfUfKtrJoKAP0INCDtUi92ElYhDv8JjRsQwWl/OuTpMw43PgOA=","ARC-Authentication-Results":"i=1; server2.sourceware.org","X-Virus-Scanned":"amavis at mnet-online.de","X-Auth-Info":"cbCial1vE1B4YrdJOSHfUh2avUt0MBFkFeIo3acZ8u/nVqGBvejmf4lgw92VK52p","From":"Andreas Schwab <schwab@linux-m68k.org>","To":"Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>","Cc":"Collin Funk <collin.funk1@gmail.com>,  Lucas Chollet\n <lucas.chollet@free.fr>,  libc-alpha@sourceware.org","Subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","In-Reply-To":"<62a973ce-6a60-432b-b847-5b5a8e533293@linaro.org> (Adhemerval\n Zanella Netto's message of \"Wed, 25 Mar 2026 18:19:00 -0300\")","References":"<20260325140452.1825551-2-lucas.chollet@free.fr>\n <87h5q37oik.fsf@gmail.com>\n <90d68c74-29b4-4b00-975d-1da810583c68@linaro.org>\n <62a973ce-6a60-432b-b847-5b5a8e533293@linaro.org>","Date":"Wed, 25 Mar 2026 23:07:23 +0100","Message-ID":"<87341nva04.fsf@igel.home>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"8bit","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"}},{"id":3669366,"web_url":"http://patchwork.ozlabs.org/comment/3669366/","msgid":"<87tsu3o8zn.fsf@gmail.com>","list_archive_url":null,"date":"2026-03-25T22:11:08","subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","submitter":{"id":88687,"url":"http://patchwork.ozlabs.org/api/people/88687/","name":"Collin Funk","email":"collin.funk1@gmail.com"},"content":"Andreas Schwab <schwab@linux-m68k.org> writes:\n\n> On Mär 25 2026, Adhemerval Zanella Netto wrote:\n>\n>> However, the POSIX requirements seems conflicting.  It states that\n>>\n>>   [EBADF]\n>>   The value specified by fildes is negative or greater than or equal to {OPEN_MAX}.\n>\n> https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addfchdir.html\n> does not say anything about OPEN_MAX.\n\nI think Adhemerval was referring to posix_spawn_file_actions_addclose\nwhich does have the OPEN_MAX text [1].\n\nCollin\n\n[1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addclose.html","headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=JAFofy9N;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=JAFofy9N","sourceware.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","sourceware.org; spf=pass smtp.mailfrom=gmail.com","server2.sourceware.org;\n arc=none smtp.remote-ip=2607:f8b0:4864:20::1336"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fh1Mn616nz1y1x\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 09:11:33 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id BA8224B9DB55\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 22:11:31 +0000 (GMT)","from mail-dy1-x1336.google.com (mail-dy1-x1336.google.com\n [IPv6:2607:f8b0:4864:20::1336])\n by sourceware.org (Postfix) with ESMTPS id 68BA54BA9039\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 22:11:11 +0000 (GMT)","by mail-dy1-x1336.google.com with SMTP id\n 5a478bee46e88-2c156c4a9efso426140eec.1\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 15:11:11 -0700 (PDT)","from fedora (c-73-93-224-2.hsd1.ca.comcast.net. [73.93.224.2])\n by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2c16ec4934asm808439eec.8.2026.03.25.15.11.09\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 Mar 2026 15:11:09 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org BA8224B9DB55","OpenDKIM Filter v2.11.0 sourceware.org 68BA54BA9039"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 68BA54BA9039","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 68BA54BA9039","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774476671; cv=none;\n b=Y6kia2vinZb1yMx5kOpJ2k8vD0PdZgCZO8HsipEEvDhorIJPMja/HkyOKSH1ntaapERYpyHSYLMdUwIm7d+heWcDaM9FhCoCxmHujkf2mWX+yR/m+MMFOEiTeg2B69vzdTMakGZolq0wQ/Mapfg4Gd8+i0X/VQ/rjmAHpPOP9I0=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774476671; c=relaxed/simple;\n bh=EeHLSbWgQ4d4WqiKPik8Bl9mBYDdPJi9X2p82MwzLkM=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=VWT7sz6Q9N7ZUyDLv1X/OXjqjKFQ41s4pcuJuThSTiqS9joq+Do/xK3Fl8jKhmUdZ5wlgDRUg7Ooc7vWUFOhgcKWecnEyicPTJwKjYpuBHRw5QtA8CogqmOUmGOhpMnCzotQZL4Emt8yTsmgQbHyzxmmVMklxSLZSJ+kWfp8QQ4=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1774476670; x=1775081470; darn=sourceware.org;\n h=content-transfer-encoding:mime-version:user-agent:message-id:date\n :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=57+fnJQvHurOgbYGSivge9Dj5wZhGSSwpOPfDFNoG4E=;\n b=JAFofy9NhmyO3gLAbemiq6wbwDoooju8ja4CfUVrHOBrQepKiajiL4qKO8NQPiejza\n Y5Ni8GaAIw8dXS4VnuArRNsL61JtNsz5fn3cE0bnsD+33OZVbli13NVo20B+s9IKDziK\n MSKXUJWv/20K8Fyip50DnLowyuuwr8NNq8YhbgWkAICSv4XQo/LJmIFKyLn2Q2CoSMej\n pzaDNkJKAkVJYJyxDW4+hC4tpxvSNF+MWoc9309ShvBJTc6opQeBazLYQpPmvdnjNVcm\n d9ZVrxIPlFFxr+owyt82d0tNQjx6/Uwj87MzV0il0tA+X3fFv4JmPRKv3thVJH4XX6oC\n Kxhg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774476670; x=1775081470;\n h=content-transfer-encoding:mime-version:user-agent:message-id:date\n :references:in-reply-to:subject:cc:to:from:x-gm-gg\n :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=57+fnJQvHurOgbYGSivge9Dj5wZhGSSwpOPfDFNoG4E=;\n b=nrJfUGpZz74WzfHx/aFoe2iISmbkEGinInQ+Fjggwf8WSyQQMwIHLcgKqJq2+PDgLm\n Jld1KoM4ourjayT+CEIARv9BSsURpYZ5DynY0qA8KPvPpxFo1KdTEzyBAshU/IfEf5q2\n ORoqUt6pWRPHN2bbP08DQ8zTdYhD3pUmCLlkm4X2v2W9l73mNjxNGy/lVlh5zUyAYHMe\n oqz44nv82me++x6MHV5yOMTBm4CQLneNPAVYyf5lo2jIxdkziCmfvL4ls1WtRKn/ALro\n BAWo7CKd301e5ivLU7tA1vjXpTk6hFAolT5jrmpYAgpYh1lOJBrk9x34berAD6KiTfe9\n 3LVA==","X-Forwarded-Encrypted":"i=1;\n AJvYcCUCtrw1k6bQVkU4L6NO/+7/4SxV0xtDiIjgohCFAtZc4af99e63wDH6LMSZjgi3JXcuOUnuJzCaTJBU@sourceware.org","X-Gm-Message-State":"AOJu0Yzq0/ivJugfwxrIszbz0u20vpK1A9nKsNzjusCxaF8tw1MNNEih\n jPBeiWg5lbp3EPqxCIohdCUWvBhXWo7wPMoxjyVQbs5gXRTnCgyx5xdjjh2tDg==","X-Gm-Gg":"ATEYQzxJnOq6/B8aaoNw+r4D9MhPDiiT1x1UxWTf3I3KkjFzuSnGF3kNvqasz7sO9Bj\n rSblNvtEew9lSAczAI/DJaewxQtC0WxRzGSzkHuxFotzOWqvmYHt3Xr8WD5Kfi7K3fQXezHBbrR\n uAynQN7hsPyXVwCijtRSaa5pJdsNYaMUMnZZzf/ay2hxha5B15TQC4fXM/feYeu3FJg9J+XA+rk\n k8JN0KUpg5ESGj7AEnaub/cnsdR7h+VkM0XfyZVTOaN4OBbWtABuCvKWN9sHnI5eKrAxCUrVGNk\n OaUuXwJSGk1Iu+thVumVAPyOXTg82U79plCwhcJ3A9Qmv4ujAy6fM8Ump1KOjDH68ZmI0EiZTpU\n N1TlUStfZN3M+0pBcrZJWYBVVyfnsrBpOugXuxuFx8IWE+RTH9AJ3XTRH2M6yIBk/7qfE49yA8z\n B2+mcV/yYPCK7tOgWdzruyzgIZLWKHqM73ZfC9rEx32PQOf9Styz5i","X-Received":"by 2002:a05:7300:3209:b0:2c1:3f85:756 with SMTP id\n 5a478bee46e88-2c15d30e3a5mr2746752eec.11.1774476670242;\n Wed, 25 Mar 2026 15:11:10 -0700 (PDT)","From":"Collin Funk <collin.funk1@gmail.com>","To":"Andreas Schwab <schwab@linux-m68k.org>","Cc":"Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,  Lucas Chollet\n <lucas.chollet@free.fr>,  libc-alpha@sourceware.org","Subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","In-Reply-To":"<87341nva04.fsf@igel.home>","References":"<20260325140452.1825551-2-lucas.chollet@free.fr>\n <87h5q37oik.fsf@gmail.com>\n <90d68c74-29b4-4b00-975d-1da810583c68@linaro.org>\n <62a973ce-6a60-432b-b847-5b5a8e533293@linaro.org>\n <87341nva04.fsf@igel.home>","Date":"Wed, 25 Mar 2026 15:11:08 -0700","Message-ID":"<87tsu3o8zn.fsf@gmail.com>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"}},{"id":3669535,"web_url":"http://patchwork.ozlabs.org/comment/3669535/","msgid":"<577b0666-13b2-4eb0-8906-89de6aa84d50@free.fr>","list_archive_url":null,"date":"2026-03-26T08:37:36","subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","submitter":{"id":86596,"url":"http://patchwork.ozlabs.org/api/people/86596/","name":"Lucas Chollet","email":"lucas.chollet@free.fr"},"content":"Thanks for the quick review!\n\nI initially used (fd < 0) but when I realized other factions functions used\n\n__spawn_valid_fd I told myself that it was the surely the way to go.\n\nAnyway, I sent a v2 that uses (fd < 0) instead.\n\nLucas\n\nOn 3/25/26 19:27, Collin Funk wrote:\n> Lucas Chollet <lucas.chollet@free.fr> writes:\n>\n>> Hello all,\n>> This is my first contribution here, so I hope I got everything right.\n>> I tested this patch on my Linux x86_64 machine with `make check` and\n>> got no regressions compared to master.\n>>\n>> 8<\n>>\n>> This patch makes `posix_spawn_file_actions_addfchdir` return EBADF on\n>> negative file descriptors. This is mandated by POSIX and similar to what\n>> is already done in addopen/addclose.\n>>\n>> Signed-off-by: Lucas Chollet <lucas.chollet@free.fr>\n>> ---\n>>   posix/spawn_faction_addfchdir.c | 3 +++\n>>   1 file changed, 3 insertions(+)\n>>\n>> diff --git a/posix/spawn_faction_addfchdir.c b/posix/spawn_faction_addfchdir.c\n>> index a3df6df489..b51139a61f 100644\n>> --- a/posix/spawn_faction_addfchdir.c\n>> +++ b/posix/spawn_faction_addfchdir.c\n>> @@ -28,6 +28,9 @@ posix_spawn_file_actions_addfchdir_np (posix_spawn_file_actions_t *actions,\n>>   {\n>>     struct __spawn_action *rec;\n>>   \n>> +  if (!__spawn_valid_fd (fd))\n>> +    return EBADF;\n>> +\n>>     /* Allocate more memory if needed.  */\n>>     if (actions->__used == actions->__allocated\n>>         && __posix_spawn_file_actions_realloc (actions) != 0)\n> Thank you for the patch!\n>\n> However, I want to note here that __spawn_valid_fd() checks if the file\n> descriptor is greater than getdtablesize(). Using it here, along with\n> some (all?) other places it is used, is incorrect. POSIX states [1]:\n>\n>      [EBADF]\n>          The value specified by fildes is negative.\n>\n>      It shall not be considered an error for the path or fildes argument\n>      passed to these functions to specify a pathname or file descriptor\n>      for which the specified operation could not be performed at the time\n>      of the call. Any such error shall be detected when the associated\n>      file actions object is later used during a posix_spawn() or\n>      posix_spawnp() operation.\n>\n> I noticed glibc's misbehavior when working on Gnulib last year, but\n> evidently forgot to fix it...\n>\n> Collin\n>\n> [1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addchdir.html\n> [2] https://lists.gnu.org/archive/html/bug-gnulib/2025-10/msg00118.html","headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=free.fr header.i=@free.fr header.a=rsa-sha256\n header.s=smtp-20201208 header.b=OIkdsEHH;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=free.fr header.i=@free.fr header.a=rsa-sha256\n header.s=smtp-20201208 header.b=OIkdsEHH","sourceware.org;\n dmarc=pass (p=quarantine dis=none) header.from=free.fr","sourceware.org; spf=pass smtp.mailfrom=free.fr","server2.sourceware.org;\n arc=none smtp.remote-ip=212.27.42.3"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fhHH941P9z1y1x\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 19:38:09 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 77A644BA2E1E\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 08:38:07 +0000 (GMT)","from smtp3-g21.free.fr (smtp3-g21.free.fr [212.27.42.3])\n by sourceware.org (Postfix) with ESMTPS id 78CDF4BA2E10\n for <libc-alpha@sourceware.org>; Thu, 26 Mar 2026 08:37:39 +0000 (GMT)","from [192.168.178.26] (unknown [84.254.90.136])\n (Authenticated sender: lucas.chollet@free.fr)\n by smtp3-g21.free.fr (Postfix) with ESMTPSA id 18AC113F8A7;\n Thu, 26 Mar 2026 09:37:37 +0100 (CET)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 77A644BA2E1E","OpenDKIM Filter v2.11.0 sourceware.org 78CDF4BA2E10"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 78CDF4BA2E10","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 78CDF4BA2E10","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774514259; cv=none;\n b=jucOAO+rkmD0/CRMst8LXrMerUadBkciQ6LZsfgAP86zQI5gmSKGoTMd7PHePMuHx6dOesJQ4JkOQHR77BodyzdcIfIn3XAmw9yq74Gkf/zH4R3lmPBJiOqUZDLv8i9qVK4kkrwdnL4BjU0n3khY2hMmBu0oJCcZkoHGnkNv6Oc=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774514259; c=relaxed/simple;\n bh=5t+T/rjTqY4FUxfz+3lmmJb91i2EOHn8T+MrG/V0y2I=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=HXEYVIREbMElEaMA+PHvpiQa/mltF28YSL3OaUff6ibOyY/cPbNFVBL865TCcNgZRsJMtYR30IRerV9id/A7SEuBuWDrBK6NOSZdUGZAdK45w0MKqYjG/ZqdoeAjE/fcdNTPHOBE/MTYByLeDA/veaIlMMyIT+/MHYNKuSWd32s=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr;\n s=smtp-20201208; t=1774514258;\n bh=5t+T/rjTqY4FUxfz+3lmmJb91i2EOHn8T+MrG/V0y2I=;\n h=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n b=OIkdsEHHBMIUzexL9naZWGlbVLQKafZrU0O0BJMjLt5KZ5QM851nvu/C7isS/HOf8\n zzd0lpoayPW6ws+aMuH9hALMwpEoKVnKNO/yNhku/5HkLPwJLY3TWsUKSpSzydyIDu\n 7zSZ/DbdIOwBhFoaoOJGgmCtnj+0LHolW5oHG6Uml+Y6czQv8tQyNpRgrDrkVp7UYT\n OBln77P/JKG8ljWEraVbSQ5YYRsZ6Wat5TtJLnODX9H9cqqxpslIGaxQ+1PSx7CqK4\n yAEQ8tPkaGB4UMLEIjzC8GQmULO3PkIt2X9TW6S5E0Ypxb/53WiQrv1+vT6UnFA+N+\n bx63eV/dGUU9Q==","Message-ID":"<577b0666-13b2-4eb0-8906-89de6aa84d50@free.fr>","Date":"Thu, 26 Mar 2026 09:37:36 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","To":"Collin Funk <collin.funk1@gmail.com>","Cc":"libc-alpha@sourceware.org","References":"<20260325140452.1825551-2-lucas.chollet@free.fr>\n <87h5q37oik.fsf@gmail.com>","Content-Language":"en-US","From":"Lucas <lucas.chollet@free.fr>","In-Reply-To":"<87h5q37oik.fsf@gmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"}},{"id":3669547,"web_url":"http://patchwork.ozlabs.org/comment/3669547/","msgid":"<da832177-8651-4db6-b365-bcec3b127428@free.fr>","list_archive_url":null,"date":"2026-03-26T08:49:47","subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","submitter":{"id":86596,"url":"http://patchwork.ozlabs.org/api/people/86596/","name":"Lucas Chollet","email":"lucas.chollet@free.fr"},"content":"If you want to open a Austin Group bug report, for completeness,\n\nposix_spawn_file_actions_adddup2 also has the OPEN_MAX text[1].\n\n[1] \nhttps://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_adddup2.html\n\nOn 3/25/26 23:11, Collin Funk wrote:\n> Andreas Schwab <schwab@linux-m68k.org> writes:\n>\n>> On Mär 25 2026, Adhemerval Zanella Netto wrote:\n>>\n>>> However, the POSIX requirements seems conflicting.  It states that\n>>>\n>>>    [EBADF]\n>>>    The value specified by fildes is negative or greater than or equal to {OPEN_MAX}.\n>> https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addfchdir.html\n>> does not say anything about OPEN_MAX.\n> I think Adhemerval was referring to posix_spawn_file_actions_addclose\n> which does have the OPEN_MAX text [1].\n>\n> Collin\n>\n> [1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn_file_actions_addclose.html","headers":{"Return-Path":"<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":["incoming@patchwork.ozlabs.org","libc-alpha@sourceware.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","libc-alpha@sourceware.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=free.fr header.i=@free.fr header.a=rsa-sha256\n header.s=smtp-20201208 header.b=WipiE1vl;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=free.fr header.i=@free.fr header.a=rsa-sha256\n header.s=smtp-20201208 header.b=WipiE1vl","sourceware.org;\n dmarc=pass (p=quarantine dis=none) header.from=free.fr","sourceware.org; spf=pass smtp.mailfrom=free.fr","server2.sourceware.org;\n arc=none smtp.remote-ip=212.27.42.3"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fhHXn6bbjz1y1x\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 19:50:17 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id A59944BA2E1C\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 08:50:15 +0000 (GMT)","from smtp3-g21.free.fr (smtp3-g21.free.fr [212.27.42.3])\n by sourceware.org (Postfix) with ESMTPS id E0AD74BA2E10\n for <libc-alpha@sourceware.org>; Thu, 26 Mar 2026 08:49:52 +0000 (GMT)","from [192.168.178.26] (unknown [84.254.90.136])\n (Authenticated sender: lucas.chollet@free.fr)\n by smtp3-g21.free.fr (Postfix) with ESMTPSA id 0AC2013FA35;\n Thu, 26 Mar 2026 09:49:47 +0100 (CET)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org A59944BA2E1C","OpenDKIM Filter v2.11.0 sourceware.org E0AD74BA2E10"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org E0AD74BA2E10","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org E0AD74BA2E10","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774514993; cv=none;\n b=NMCko59hSsz1LB5v7CxaNKhBTm/FCzl606AJ3uyBtSY06T7f3DtHdq1fAwvaQBX1j6AX5I2mu26EWedLgM2KQLJx0Ge7vsG+p/dIkgvl/oGPNnXmr6Qpn1daT7+gvUexDJTYOPCFLcnHURuot34b+fBioWm3ibaXeGcThzwdXmQ=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774514993; c=relaxed/simple;\n bh=bKfc4zTGCtXiQxQd3EmHIh2w0Qdw2buqjGGeZmDJjmk=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=cp1qVJagxCsfYtYhrvxAItxFXiAVdT+s90H5qQrykb7LnQsY5rue6U5EnClJMUsn1sSKS/6PEno88AUJzGeq6ABtTkIS0o+zfceiN2kfh70qgVK91FHLHcDCReSHsHzd5eyUXAPFhkJa+UYOJlr4+l9sLOIcrZxbL6+tg05dumw=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr;\n s=smtp-20201208; t=1774514991;\n bh=bKfc4zTGCtXiQxQd3EmHIh2w0Qdw2buqjGGeZmDJjmk=;\n h=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n b=WipiE1vlDiovK+0vCdTPMCn2o+tJkL9D2Vs73yIgajLNJGP0uepCQvF02dwlz9+tj\n sgEAnpzoqpOjsVigZseb2v1MKnxEhbZZsqGW8CdQ1tT5HuuJ4YAjkc2LOp+byCw4IF\n qV6GRiQdwcUcAr50ss45EQLV/bSqWQrD8lGs7c30f4WREtuOL0gyTzd6Kbq/YtUGX+\n wsAb3lx/qDdaw9DBlDU4csExtspWbCnMy3i0iEWuRfR+6MMtp/m2g2u7MZ/Mwe+SeO\n ZSgEWFbnz++OhSLyQd2gfcZfB+QH0Fz+jkxE/LwUIhYEB0EBf9kqJ+0cWRx/wujlZE\n 7bVFjTJbmmfRA==","Message-ID":"<da832177-8651-4db6-b365-bcec3b127428@free.fr>","Date":"Thu, 26 Mar 2026 09:49:47 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] posix: Handle negative fds in spawn's addfchdir","To":"Collin Funk <collin.funk1@gmail.com>,\n Andreas Schwab <schwab@linux-m68k.org>","Cc":"Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,\n libc-alpha@sourceware.org","References":"<20260325140452.1825551-2-lucas.chollet@free.fr>\n <87h5q37oik.fsf@gmail.com> <90d68c74-29b4-4b00-975d-1da810583c68@linaro.org>\n <62a973ce-6a60-432b-b847-5b5a8e533293@linaro.org> <87341nva04.fsf@igel.home>\n <87tsu3o8zn.fsf@gmail.com>","Content-Language":"en-US","From":"Lucas <lucas.chollet@free.fr>","In-Reply-To":"<87tsu3o8zn.fsf@gmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","X-BeenThere":"libc-alpha@sourceware.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Libc-alpha mailing list <libc-alpha.sourceware.org>","List-Unsubscribe":"<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>","List-Archive":"<https://sourceware.org/pipermail/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-request@sourceware.org?subject=help>","List-Subscribe":"<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>","Errors-To":"libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"}}]