From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id ED5D724A3D for ; Fri, 29 Nov 2024 07:09:13 +0100 (CET) Received: (qmail 1994 invoked by uid 550); 29 Nov 2024 06:09:10 -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 x-ms-reactions: disallow Received: (qmail 1957 invoked from network); 29 Nov 2024 06:09:09 -0000 Date: Fri, 29 Nov 2024 01:08:58 -0500 From: Rich Felker To: Gil Pedersen Cc: musl@lists.openwall.com Message-ID: <20241129060857.GH10433@brightrain.aerifal.cx> References: <20240820111100.GX10433@brightrain.aerifal.cx> <4D107104-6B65-4A82-9662-A8392B56B744@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D107104-6B65-4A82-9662-A8392B56B744@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] bug: isatty() can return wrong value On Tue, Nov 26, 2024 at 11:03:36AM +0100, Gil Pedersen wrote: > > On 20 Aug 2024, at 13.11, Rich Felker wrote: > > > > What guarantee do we have that nothing other than a tty in this state > > will return EIO for the ioctl? The implementation on the kernel side > > suggests that, if they tried to put any other device in such a state > > by replacing its ioctl function the same way, it would also give EIO > > for these ioctls. > > Yeah, EIO is unconditionally signalled for any (expect TIOCSPGRP) ioctl call when a tty is hung. > While a TIOCGWINSZ ioctl call that returns EIO will very likely be a tty, there is indeed no such guarantee. > > > I'm hopeful there's some good fix here where we don't have to have > > either of these bad behaviors, but returning true for isatty() of a > > device that is absolutely not a tty is a much worse behavior than > > returning false for a device that is/was a tty when it was opened but > > that's been replaced by the kernel with a defunct device. > > I have proposed a change to the ioctl handling in the kernel: > > https://lore.kernel.org/linux-serial/20241121111506.4717-1-gpdev@gpost.dk/ > > If merged, the issue should be fixed going forward. Great. AIUI the proposed kernel change would fix this issue without needing any further action on the libc side, right? Rich