Received: by 10.223.176.46 with SMTP id f43csp1102274wra; Sat, 20 Jan 2018 10:53:52 -0800 (PST) X-Google-Smtp-Source: AH8x226F1CWm+hXPXHxUczjbF/4j/VaWLcXLYqkb71D5/0x8fjBpiB0f8VqCeZ/jyrnfSRHrdzQx X-Received: by 2002:a17:902:bf46:: with SMTP id u6-v6mr1267640pls.62.1516474432479; Sat, 20 Jan 2018 10:53:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516474432; cv=none; d=google.com; s=arc-20160816; b=YE0AW9Q6c2vlpOu5yu266guyL5kmLNoYVf9EK3JyJ0b37OYXri8DMHvrHy5ymSYlxU +spoqhh9fHK5l3PdSpjKflkPWG5rjm6mGWtoTQdF/RY2b6DkfgsiePAh3nsc40zXQ7Tv SwlLdA76iHEOr3qcCLir2s2cW2w3gpTilQOw20g/F4jNi8tpoiktMB4a82lYWxNPBp4r UVzp2KrgvfhG4JwACbARCspL4eUfKvw2n1T6z2j92m6TdzJVsHrAmttDtc8UWiXjxcP1 U0xx8fywlREcatpOEq1W0zzNwrfAOi9wrEfl8Akt72D3Dg3b6nJtvecZujPknxHX0ocw Tsyg== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=PCCMDgiv03ZVeDYusUs8vU1UVWIrgzoOwSmK+2pc7K0=; b=i4OwtYhwz/zwsJ9k0aZkQsZnMBVwGZs8C5/6K0bhqyGCyK/vaNELtbHA6ekATD3QRA 7mEyhLkJACF5zpRUZQ7USrZCTuZ8JPrOYGFPc49wJD6yqhd8l/o/KvKf8Ej652IeXxjf p58c5bYYSqeuKdxqCJ3gSb7N88j8qby64dniyb/17c0AI8fbU/ny40oSqzy+5nDSww7E Swox4i6kv8j9QbVpACvMOO395FW0IEgea92QLzS4h0CQGvBVgoaxuKM/VA+6n0DUx9bl nQh0srUyUDX6/h8sQMK+frDFtepRbRuFJvPSf+JzapGcCAkjQJoNy5BYmLpvNnGe0SDz qu8Q== 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 v34-v6si1905441plg.803.2018.01.20.10.53.26; Sat, 20 Jan 2018 10:53:52 -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; 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 S1756624AbeATSuA (ORCPT + 99 others); Sat, 20 Jan 2018 13:50:00 -0500 Received: from www.llwyncelyn.cymru ([82.70.14.225]:45548 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756533AbeATSts (ORCPT ); Sat, 20 Jan 2018 13:49:48 -0500 Received: from alans-desktop (82-70-14-226.dsl.in-addr.zen.co.uk [82.70.14.226]) by fuzix.org (8.15.2/8.15.2) with ESMTP id w0KImqrw031222; Sat, 20 Jan 2018 18:48:53 GMT Date: Sat, 20 Jan 2018 18:48:52 +0000 From: Alan Cox To: Gaurav Kohli Cc: jslaby@suse.com, gregkh@linuxfoundation.org, mikey@neuling.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, stable@kernel.org Subject: Re: [PATCH V1] tty: fix data race between tty_init_dev and flush of buf Message-ID: <20180120184852.456d92ad@alans-desktop> In-Reply-To: <1516195459-1080-1-git-send-email-gkohli@codeaurora.org> References: <1516195459-1080-1-git-send-email-gkohli@codeaurora.org> Organization: Intel Corporation X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 17 Jan 2018 18:54:19 +0530 Gaurav Kohli wrote: > There can be a race, if receive_buf call comes before > tty initialization completes in n_tty_open and tty->disc_data > may be NULL. > > CPU0 CPU1 > ---- ---- > 000|n_tty_receive_buf_common() n_tty_open() > -001|n_tty_receive_buf2() tty_ldisc_open.isra.3() > -002|tty_ldisc_receive_buf(inline) tty_ldisc_setup() > > Using ldisc semaphore lock in tty_init_dev till disc_data > initializes completely. > > Signed-off-by: Gaurav Kohli Reviewed-by: Alan Cox Alan