From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756140AbbCEObZ (ORCPT ); Thu, 5 Mar 2015 09:31:25 -0500 Received: from mail-qc0-f180.google.com ([209.85.216.180]:35360 "EHLO mail-qc0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755996AbbCEObW (ORCPT ); Thu, 5 Mar 2015 09:31:22 -0500 Message-ID: <54F868B7.9010709@hurleysoftware.com> Date: Thu, 05 Mar 2015 09:31:19 -0500 From: Peter Hurley User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Johan Hovold , Greg Kroah-Hartman CC: Jiri Slaby , Samuel Ortiz , "David S. Miller" , Alan Cox , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-serial@vger.kernel.org, netdev@vger.kernel.org, ZIV-Asier Llano Palacios , stable Subject: Re: [PATCH 4/5] TTY: fix tty_wait_until_sent on 64-bit machines References: <1425461947-15888-1-git-send-email-johan@kernel.org> <1425461947-15888-5-git-send-email-johan@kernel.org> In-Reply-To: <1425461947-15888-5-git-send-email-johan@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/04/2015 04:39 AM, Johan Hovold wrote: > Fix overflow bug in tty_wait_until_sent on 64-bit machines, where an > infinite timeout (0) would be passed to the underlying tty-driver's > wait_until_sent-operation as a negative timeout (-1), causing it to > return immediately. Wow, that is a nasty bug. > This manifests itself for example as tcdrain() returning immediately, > drivers not honouring the drain flags when setting terminal attributes, > or even dropped data on close as a requested infinite closing-wait > timeout would be ignored. > > The first symptom was reported by Asier LLANO who noted that tcdrain() > returned prematurely when using the ftdi_sio usb-serial driver. > > Fix this by passing 0 rather than MAX_SCHEDULE_TIMEOUT (LONG_MAX) to the > underlying tty driver. > > Note that the serial-core wait_until_sent-implementation is not affected > by this bug due to a lucky chance (comparison to an unsigned maximum > timeout), and neither is the cyclades one that had an explicit check for > negative timeouts, but all other tty drivers appear to be affected. Reviewed-by: Peter Hurley