Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3757165imm; Mon, 8 Oct 2018 09:03:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV637BSimfcQVXmtau4inHuRnC9eWPRsxh5g6F7+fw0TbreVtIwIyHn6tusxCSxgi6AoUVhTr X-Received: by 2002:a65:609a:: with SMTP id t26-v6mr21176841pgu.41.1539014592040; Mon, 08 Oct 2018 09:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539014592; cv=none; d=google.com; s=arc-20160816; b=Sf9RiPsLP1GJmU88VHD9ujhBdQuMxBoYbt77loYnZBXl0JpE50DYFnkb3JU7z6Cr5K l4nlkkso4819awhPdVf0ldm7pVJ8qelK1j2YKuXw7Wzqp83Md2Mh8LTjp7IQLsN+1Ao2 3nFQy2rSzmTkqmIsO85hJjPvevB4rIM2j/y6hzC3JT1Dnn6380rOUUWhUwkzXRVX+HIE 54++eEO67u4G0pHNTjZ3zFtKttJ4m79fzZEeLtVPZfN3tS7KPxUWXGo8xO7fr7CEJVYQ JqOwwhEHEyAUiGPOeh36dv8wdf0VHPTleAmaX42bq8n8EUtcCJLMsV8ocXwib7DjT2CX Fd5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=jCKZKpB5OjmswEfaWWbhqI9SqFBewnTDr172I/UFG2M=; b=yCAvlpMAoXX6ZaKI2vO1Sxe/nrC5H0p3fp92GP7spCtLmSi3Hig+cLe5cRxQzYGWOO OFjonHrn1MYP6DsiFMX21BfAUgbiomxOnt76gLnSO4NVuew9alvWgMelN6pwUSPdoonv bTpY1II1cIsQXeMRWjRP/H2laBcG83nmPdAJ75JceAX1NJ6ZIIOieeluuBcv9YZI85AF +NzRG9TsXHslvthO0cG/IFRx9i2FMFbbAs++TviBFje8V15JDqk/8hsuDRQJmb4ha6Gd 3ovGfa8vzRTJEk1d7jodYmpvgr2PvIjDrkPnyC7HboacJyAsWpJfcQyqDnd29C9WhUXK laEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w9-v6si14801521pgl.503.2018.10.08.09.02.56; Mon, 08 Oct 2018 09:03:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726722AbeJHXOB (ORCPT + 99 others); Mon, 8 Oct 2018 19:14:01 -0400 Received: from terminus.zytor.com ([198.137.202.136]:37171 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726291AbeJHXOA (ORCPT ); Mon, 8 Oct 2018 19:14:00 -0400 Received: from carbon-x1.hos.anvin.org (c-24-5-245-234.hsd1.ca.comcast.net [24.5.245.234] (may be forged)) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id w98G1A7q671449 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Mon, 8 Oct 2018 09:01:10 -0700 Subject: Re: [PATCH stable v2 1/2] arch/alpha, termios: implement BOTHER, IBSHIFT and termios2 To: Johan Hovold Cc: linux-kernel@vger.kernel.org, Tobias Klausmann , Greg Kroah-Hartman , Jiri Slaby , Al Viro , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Gleixner , Kate Stewart , Philippe Ombredanne , Eugene Syromiatnikov , linux-alpha@vger.kernel.org, linux-serial@vger.kernel.org, Alan Cox , stable@vger.kernel.org References: <20181008040620.1248277-1-hpa@zytor.com> <20181008040620.1248277-2-hpa@zytor.com> <20181008153840.GD3332@localhost> From: "H. Peter Anvin" Message-ID: <96b760ca-1faa-8bf7-5616-c16bfcf75ec4@zytor.com> Date: Mon, 8 Oct 2018 09:01:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20181008153840.GD3332@localhost> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/8/18 8:38 AM, Johan Hovold wrote: > On Sun, Oct 07, 2018 at 09:06:19PM -0700, H. Peter Anvin wrote: >> From: "H. Peter Anvin (Intel)" >> >> Alpha has had c_ispeed and c_ospeed, but still set speeds in c_cflags >> using arbitrary flags. Because BOTHER is not defined, the general >> Linux code doesn't allow setting arbitrary baud rates, and because >> CBAUDEX == 0, we can have an array overrun of the baud_rate[] table in >> drivers/tty/tty_baudrate.c if (c_cflags & CBAUD) == 037. >> >> Resolve both problems by #defining BOTHER to 037 on Alpha. >> >> However, userspace still needs to know if setting BOTHER is actually >> safe given legacy kernels (does anyone actually care about that on >> Alpha anymore?), so enable the TCGETS2/TCSETS*2 ioctls on Alpha, even >> though they use the same structure. Define struct termios2 just for >> compatibility; it is the exact same structure as struct termios. In a >> future patchset, this will be cleaned up so the uapi headers are >> usable from libc. > > Is this really needed? By defining BOTHER (and IBSHIFT which you forgot > to mention here) you are enabling arbitrary rates also through TCSETS on > alpha, right? > Yes, it's needed, not because the old ioctls won't work on NEW kernels, but because Alpha is so far behind the times, *and* the OLD kernels are severely broken if we pass BOTHER to them, we need a new ioctl number so we can guarantee that we won't do anything that user space doesn't intend; this is actually made far worse because if I read the code correctly, the kernel will still report back BOTHER and the speed field set on a legacy kernel in response to TCGETS, but the values will be completely bogus. This means that glibc will need a workaround for Alpha only, and the new ioctl numbers handles support for it. gcc should be able to fold the code together, since it should be able to detect that multiple branches of execution are otherwise identical. To micro-optimize, we could define TERMIOS_OLD as (CBAUDEX ? 8 : 0) in a future (non-stable) patch. We don't need to worry about it on PowerPC because PowerPC implemented this so long ago, before the current glibc support threshold. -hpa