From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11970 invoked from network); 27 Feb 2021 17:14:01 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 27 Feb 2021 17:14:01 -0000 Received: (qmail 29914 invoked by uid 550); 27 Feb 2021 17:13:56 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 29896 invoked from network); 27 Feb 2021 17:13:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5UWXO++m7qHzQYAtm26bxreRCN4oKo29LmzprCtLQlY=; b=cemFoDY9Ye07j5XUSUGflfYomFpXXc1P6gh/17NapOBPirg7qkwwym17skPX55RiS2 rfAmvzy3eCUI2viSgDdLsBhXUTrzD1CKPi7bFqqyyUt+mlqmQMU27AJhfzFHM7Z4Ntgc pIhX9SENEGp/9dBuRprwb9iwaKyMNvtWYAIIGq2IKhh6pCi7BueAprtYVl7jV00HdYcR U/CTPNiTl6In/twBsMx7fGx0wfKnUyeqr6m83dS0yy7a7yOjZjf4lwyu3vFA2MKp2QTa kBLy3UMGC5+gFcTOZZ2X2g0Re2zCxX0eovmCBlxazSPpiDG5UQsx/sWzVlUsPAJNIHPQ u2lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5UWXO++m7qHzQYAtm26bxreRCN4oKo29LmzprCtLQlY=; b=Wxo8edGQGjGRg1tyfaBKPU7HfE2JHoqFBhkR3HiMxondqrmQwQUtcJxy0Prvl68jhY z7L0K/PKZGa5mJsbzzbiLkhi5UEvGweafqchMzN2HHeJEAnAR8EsGwBISTT9VAYBaY0K HQ74Y0kp2eSFS5s4PamHxmQIIJSjGvotzeLyqyQPBMGNs9DKW/Or52GnX1RKoHuKupHo AZ1CmnHDJTVxLNFOV1WhB6D/N1IyOVDIBmZC0L0/Qq9xmntK/3gz9lQEXQeihYsg2PWo PyK55yOhsuKXUHZBz/PmbDIa2h3LIynuh7YgV89HuNQk6wUESF7z0krF4kp2WtJA7J6r dfug== X-Gm-Message-State: AOAM532KQWOOul8rVhw8I1GOT3DgCgcss6IludP/jqiWK54UHQ1tqzlm rmU7cSH5HEdYYy6AqCaGo/BXITh3nHAyqQmBMbno2qNyu+GTAw== X-Google-Smtp-Source: ABdhPJxhtmOvQIs7FgSSC7heugl3Dwh1WQpMR/crPhVz/URf2NVRhuEl8zwmRghivzS0m4ObR/UKrtr5bq22Gy/CQxo= X-Received: by 2002:a05:620a:124f:: with SMTP id a15mr4871884qkl.125.1614446023269; Sat, 27 Feb 2021 09:13:43 -0800 (PST) MIME-Version: 1.0 References: <77f18b20-f3fc-7b07-42e8-8fa013e52ec9@gmail.com> <20210226180040.GC32655@brightrain.aerifal.cx> In-Reply-To: <20210226180040.GC32655@brightrain.aerifal.cx> From: Khem Raj Date: Sat, 27 Feb 2021 09:13:17 -0800 Message-ID: To: musl@lists.openwall.com Cc: Dominic Chen Content-Type: text/plain; charset="UTF-8" Subject: Re: [musl] fdopen() doesn't check for valid fd On Fri, Feb 26, 2021 at 10:01 AM Rich Felker wrote: > > On Fri, Feb 26, 2021 at 12:36:19PM -0500, Dominic Chen wrote: > > I've been verifying the behavior of an application between glibc and > > musl, and have noticed that the musl implementation of fdopen() > > assumes that the input fd is valid, whereas glibc does not. Per > > https://pubs.opengroup.org/onlinepubs/9699919799/, it seems that > > fdopen() is allowed to fail with EBADF, so inside __fdopen(), the > > syscalls to SYS_fcntl and SYS_ioctl should probably check for an > > error, deallocate the FILE *, and return nullptr. > > This is specified as a "may fail" error not a "shall fail". It was > discussed before (I can look up the old thread if you're interested) > and there are some paths in which checking for it would be free, but > others where it would not, and it would require reorganizing the > function's flow in a way that's less desirable in one way or another, > so it doesn't seem like a good idea for the sake of something a caller > can't actually use. > perhaps we should add it to differences with glibc document [1] > Rich [1] https://wiki.musl-libc.org/functional-differences-from-glibc.html