Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp389671pxu; Thu, 7 Jan 2021 07:33:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJza5fIbIZsE6s5T6T34JxYhUX0z1+4MDHHZYwkFWa1b7vXH5p/2HPRrph8U/guD1GgV5nFU X-Received: by 2002:a50:9e22:: with SMTP id z31mr2163932ede.235.1610033592919; Thu, 07 Jan 2021 07:33:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610033592; cv=none; d=google.com; s=arc-20160816; b=c1Rkv5QwE2zub0BrBWTwRn17zf6uMm+Je51wlqvI6pWhM+wx+V6yhTm9FLaHeuEPPi tWPrEC8/H3qAHOxg3Tl8YLqadMUfaZkPdHu5d3qeeGDx+sxzBiK+3BypDQkMY/cUmdWD Cx4j+BAhMBS5f0beRLvufE8Y4/+aPEverJ9wbLi1hkq6b8hbUBYAnN7UDc4zK/Qqxoqx /Ia9/8J8LMdeHoRJ5Q9qn15XMvDS3QG9JgG5m2x4lhB5cAykRSj7UvGejXUapF6TeZ3N 7wOj4G1ZPg5FRy2U2QfM89ldJI49XAEGTsMYIC0E7zJW8kh6odOsQMODsrxfjRJbR83N l80A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C3l1I+MROOJVcjTtjoiC20OfXAIUyfupTI01Umk4EAA=; b=u8t8apnrQIRvXh3xrDerKeO3dde2rFIhjHtLAICJvSwwZfATRJh0sf0w8Vu0Tm2GfV zSRZZgvqCByD08ID3guO6E+zJWYSACRrjwcGA5bzt7ovhnLznMrkYrdFtx57MchmVSBw d4ybwMnFiAVWW7F2JrWan7ffcIevRtqWRYEaVjUfnybghkNOV6rKz6r4HP/CuZ3rZfxs qwaYVktj+p+++cM+HyMH/avwG5yBNdaG9ec5Axe5lysjKAWwHxBEl76v0PIfb0htAQc3 vBkWNJCrYOEwK1bKrwu0IdOXsMxVSMb2hh957YB8lQsQ9Av8Lo95OkiVFZW7YrU2PgRK CngQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LjMaCWt4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t23si2443376edc.387.2021.01.07.07.32.48; Thu, 07 Jan 2021 07:33:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LjMaCWt4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726664AbhAGPb7 (ORCPT + 99 others); Thu, 7 Jan 2021 10:31:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:33610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbhAGPb7 (ORCPT ); Thu, 7 Jan 2021 10:31:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2DFB8224B0; Thu, 7 Jan 2021 15:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610033478; bh=Xb/OryXbIvuQ9xk17LvU0wVCWg5Lqq9GXtoBiaBCfyQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LjMaCWt4QUuFOCUH1RtDPvjXYndcG87JWo7VKYi6huHvY/vx3EsRgoNgNGe4HNol7 b3TZA8LL0U0gzdPoCR+Sok/Pm0aGARgCLdLFGX1tejvwddPwdfIpTWm5RNAAdpEufY 2BB4lEEMCUnS9mv7E6o6b682DCSoffunmws2SEng= Date: Thu, 7 Jan 2021 16:32:38 +0100 From: Greg Kroah-Hartman To: minyard@acm.org Cc: Jiri Slaby , LKML , Peter Hurley , brian.bloniarz@gmail.com Subject: Re: [PATCH 0/2] drivers:tty:pty: Fix a race causing data loss on close Message-ID: References: <20201124004902.1398477-1-minyard@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201124004902.1398477-1-minyard@acm.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 23, 2020 at 06:49:00PM -0600, minyard@acm.org wrote: > I finally got some time to spend with this issue, and I think I have a > good fix. Not really a v2, this is a completely different fix. > Basically, calling tty_vhangup() on the slave when closing a pty master > is just a bad idea. > > >From what I can tell, the tty_vhangup() is there in case there was a > console redirect to the pty slave. When you close the master, you need > to release the redirect. I didn't see another reason for tty_vhangup(). > So this has two parts, export the release of the tty redirect release > for the pty code to use, and call it from the pty code. > > With this change, everything seems to work ok and no data is lost on the > slave side if the master closes with outstanding data. I have updated > my test program to check that all written data is read, it's available > at https://sourceforge.net/projects/ser2net/files/tmp/testpty.c/download > > But, this code is quite intricate and I certainly may have missed > something. Tricky stuff, but I think this makes sense, so let's see how the test-builders and linux-next work with this... thanks, greg k-h