From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x224PUJiOvTC39Ha3kY6yu37JFE45wFKnG2X/0Y17G1JcIXCI6XMfn6VIB+kU1O0tNZhBUNRg ARC-Seal: i=1; a=rsa-sha256; t=1516474140; cv=none; d=google.com; s=arc-20160816; b=CIUwj8zqxGIAtuwHT8fVos1IVNRF9lQxY5BEV23oBZSTcw2FleA6d23Ec7RC+S7nA4 vtfDL/6O2fLktFrxvQ45t/Bt3kFyc4L2BPHnEmVOgAK2JVMT5CAXnHOaJwEhkrhXmK50 mR7Nb+WYodeS6DKl4NUnQ2WfKmILnE8owexrNaskaBXMBm4mogSaW5gUXKE2pr28519y ZHbHi0oWGIVYGsDVVyoy0z707NVkGKsg2dgTvmvStvHgPcegF66LUqSXNJ0YS08mgQ2O cF26BihurHeE9RB0lqUvFnr/Fv0y5ppNqzTvYF2a5pE8aI5B1LHo+6f5/Y89cpnY1QeJ C1PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=PCCMDgiv03ZVeDYusUs8vU1UVWIrgzoOwSmK+2pc7K0=; b=ZCXQqa2D0CpWly3sgfMwe1480wCwfbHdKl+G7jsMxyGVlAdVpqw2T2B2aqTkfUxrpy FsIjT6VOmNRFcpOUE7+kCvN10DneMwtEJqihFD2UbHB5TQOgnBAXcvIYS19VEGsCFbJ+ 15HzM6krJ2Xp/Nbzyvf1vGCjH8iXpqyuTmG9Qxs8MtJ99zFow44nPSEz/BGFO8mUsiri B4JhtUcJRt/Dr7ubtkDqCA87bjCiEIsy0fmPaEw4hGhBPWTslK5Tt/nP6Q6s/ZTmiW2c LPN557N7qUzN89GzBZihYopquFUfG/+SgtGm9XLCVPQaK+Lxk/NaEcU1HhK/hP8ZOyuN 9ehw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gnomes@lxorguk.ukuu.org.uk designates 82.70.14.225 as permitted sender) smtp.mailfrom=gnomes@lxorguk.ukuu.org.uk Authentication-Results: mx.google.com; spf=pass (google.com: domain of gnomes@lxorguk.ukuu.org.uk designates 82.70.14.225 as permitted sender) smtp.mailfrom=gnomes@lxorguk.ukuu.org.uk 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1589846180511155236?= X-GMAIL-MSGID: =?utf-8?q?1590138388304764984?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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