Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2901828imu; Fri, 18 Jan 2019 01:05:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN5bToJSNT1TA+IzDEfFHUA6fiU55vxclym7djUoNKRjx6y7GfDfJOvEDyTvR7fKepLISd8Q X-Received: by 2002:a63:1b58:: with SMTP id b24mr16524542pgm.247.1547802358759; Fri, 18 Jan 2019 01:05:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547802358; cv=none; d=google.com; s=arc-20160816; b=giuMf815DRxjONbly28FYUtSIZf+g0qFbyeyTsSEW+v5BgMHoWB7n+wvGDs5FvKdOF XU7j2Hlr79FgfgRmgyFsLkpoPawtIrMNxvszSAPO3h+BGjSSgSil4PijImfl7l8a5eaG WlSrlnHDYT6EYzzVp6lzd8CZjX1Ax7SvjPTA4sb4qnxE3Nk7IxFBdq6XkYQMinXkUk8q Gd/FHEauCOb94P72HTt3FRaTph6ICrVggQFyYiWfN69EQHvjZ+HNjFpLnjADNOJJ17XC 8WflVyBsjVR/Jr7mBrOQvPJ4rFc0wSvJgM+d8e3R0h+mFogy+0YyazxcojF9BcgJE7SZ kPDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Ggk8relKqxY9zHNppxyZb+wTKq7e/4bW6Q5yVLYKMLY=; b=dbC5cUMVDHPVPI/zTCw0w0aeWJHmPbDR8UE8o6z5MOrH3CZD4O+dxOfixlZ8Te0o3x XmqjZKK/df2jAVUUd5yiVVyF8lScCenwAoCaK25KT9O90fv236GJNWs7/6SuyoYGlfLQ hYf8ywkbw5px8xHWUpNF9XCtmR9ITpa9VJcXVulvPvc+xGY+U79H1YNjBXg3wRIZZZIq R7LSN5t6Zm+X7wIGuwLJia8OA+m8gdgVkfuqriOzcNGs4tTd5ynxP07B0hU662cr3OrH kIJ7+Po7ksiwABANca2KH4fayY7Nh6s5lvQ9dmaNHmAQsGtbG5CBaR7P35xWNqRhpPLB yItw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KTMxi4Aa; 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 e7si3557113pgv.499.2019.01.18.01.05.39; Fri, 18 Jan 2019 01:05:58 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=KTMxi4Aa; 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 S1726120AbfARJEW (ORCPT + 99 others); Fri, 18 Jan 2019 04:04:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:55176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbfARJEW (ORCPT ); Fri, 18 Jan 2019 04:04:22 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ECE5D2086D; Fri, 18 Jan 2019 09:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547802261; bh=eM3yXsodugHNLWe+amuJhIuD/bQ9Xs4TEN0G7xbJ+14=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KTMxi4AaoR6OmWeFI8xnzyJIx37nj7QLiqJ66CtYNxvM3LQIvE2fCJrxDTH1JInuN mo1kAFBD83YLMv4z1UP2yWEjGqTWz+CB9encDMN7KZ43AJhMja62a9V2+z4XS3aL6Z faRTyYSt5oo+xmTngIZ9YgncauJkSFamGzQ9dvyU= Date: Fri, 18 Jan 2019 10:04:19 +0100 From: Greg KH To: Li RongQing Cc: jslaby@suse.com, linux-kernel@vger.kernel.org, gkohli@codeaurora.org Subject: Re: [PATCH][v3] tty: fix race between flush_to_ldisc and tty_open Message-ID: <20190118090419.GA1784@kroah.com> References: <1547801764-13660-1-git-send-email-lirongqing@baidu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1547801764-13660-1-git-send-email-lirongqing@baidu.com> User-Agent: Mutt/1.11.2 (2019-01-07) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 18, 2019 at 04:56:04PM +0800, Li RongQing wrote: > There still is a race window after the commit b027e2298bd588 > ("tty: fix data race between tty_init_dev and flush of buf"), > and we encountered this crash issue if receive_buf call comes > before tty initialization completes in n_tty_open and > tty->driver_data may be NULL. > > CPU0 CPU1 > ---- ---- > n_tty_open > tty_init_dev > tty_ldisc_unlock > schedule > flush_to_ldisc > receive_buf > tty_port_default_receive_buf > tty_ldisc_receive_buf > n_tty_receive_buf_common > __receive_buf > uart_flush_chars > uart_start > /*tty->driver_data is NULL*/ > tty->ops->open > /*init tty->driver_data*/ > > it can be fixed by extending ldisc semaphore lock in tty_init_dev > to driver_data initialized completely after tty->ops->open(), but > this will lead to put lock on one function and unlock in some other > function, and hard to maintain, so fix this race only by checking > tty->driver_data when receiving, and return if tty->driver_data > is NULL > > Signed-off-by: Wang Li > Signed-off-by: Zhang Yu > Signed-off-by: Li RongQing > --- > drivers/tty/tty_port.c | 3 +++ > 1 file changed, 3 insertions(+) What changed in this version, from the other versions? That is always to be listed below the --- line, as the documentation states. Please fix up and do a v4 with all of this information. thanks, greg k-h