Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp632403imm; Wed, 29 Aug 2018 08:21:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZtOdWSvTL+Y8I/MxaMiAJop60kitgYb+ii+sRXGtUeLVRiSvyEAGjDob9YmpnzTWUZk6gg X-Received: by 2002:a63:1f52:: with SMTP id q18-v6mr6062554pgm.88.1535556064994; Wed, 29 Aug 2018 08:21:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535556064; cv=none; d=google.com; s=arc-20160816; b=ucLtpUIGXip5kKLLHwg2GcKl2kN6YPROTdguIewBOa40q3IgMNg1Q6LB340WyYqzuq GKUpczu0CLENbFRHEbpfTGkjqBtcpslwwvbGsIdKnnRHrd9JlUNKlK5UHovSbde/t7TT Zx9bO4t531aE1AFvFwjC/owVbaKE/+2T/hEf8PX71TMdi0J+lIwlDUeKsKBQl5Wm7Y5W SNTHe+Uqpkp+s7fzf08QlhrkbKVTIzuHDHNUDm+0xeU0ekMNYEV1IsLvhCoD2v7urLOi l53c7R46VNU7R+xmAi6/jLHryT5ADXmUjnhBjEhYE78BqVqVjqm7Y1RLGIO6bmXQ5sbf luAw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=R2DoZmaB4xMREZc1AS7v3MPSD+pz7+qxLOhZoOfZkj4=; b=QtBWj0SOPR2GbIC7W1MyDzzEyEa5nm7f6nWoKMjSqkfQfP7myvQCZmeNT+9M5s4eBG hVfZA05B3hsWtUuKbzddPg2qXM3cllh7H6ZbWKRcalhsfJyEu075vODuPn5H5YNob/dY cQGGllLw1o+lhz6EJ9umHR4dTg1Rvk3ugikYYF3eIR5Syd7Me61muOjUhQKbDitmjaMe OGDIYQk/xJeQVa81D9ehHv1mzlAibRXtWrjQjZaVeratOQrg3s6xMQn3RaTJ9Q3Vv/Ox TXE3sld4tAoyreZ2dNMF6GSh7zOmDVujekG3glv0j/Q1AQhqNwTtnruXlunmypy9LPMx ItAg== 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 e31-v6si4011944pgm.166.2018.08.29.08.20.49; Wed, 29 Aug 2018 08:21:04 -0700 (PDT) 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 S1728995AbeH2TQf (ORCPT + 99 others); Wed, 29 Aug 2018 15:16:35 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:29445 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728701AbeH2TQf (ORCPT ); Wed, 29 Aug 2018 15:16:35 -0400 Received: from fsav301.sakura.ne.jp (fsav301.sakura.ne.jp [153.120.85.132]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w7TFJ8Q1046750; Thu, 30 Aug 2018 00:19:08 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav301.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav301.sakura.ne.jp); Thu, 30 Aug 2018 00:19:08 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav301.sakura.ne.jp) Received: from [192.168.1.8] (softbank060157066051.bbtec.net [60.157.66.51]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w7TFJ8Am046742 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 30 Aug 2018 00:19:08 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Subject: Re: [PATCH 2/4] tty: Hold tty_ldisc_lock() during tty_reopen() To: Dmitry Safonov , linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Daniel Axtens , Dmitry Vyukov , Michael Neuling , Mikulas Patocka , =?UTF-8?B?UGFzaSBLw6Rya2vDpGluZW4=?= , Peter Hurley , Sergey Senozhatsky , Tan Xiaojun , Greg Kroah-Hartman , Jiri Slaby , stable@vger.kernel.org References: <20180829022353.23568-1-dima@arista.com> <20180829022353.23568-3-dima@arista.com> From: Tetsuo Handa Message-ID: <0cb6bb7c-776b-28d6-65a6-f5b496e32344@I-love.SAKURA.ne.jp> Date: Thu, 30 Aug 2018 00:19:04 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180829022353.23568-3-dima@arista.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/08/29 11:23, Dmitry Safonov wrote: > tty_ldisc_reinit() doesn't race with neither tty_ldisc_hangup() > nor set_ldisc() nor tty_ldisc_release() as they use tty lock. > But it races with anyone who expects line discipline to be the same > after hoding read semaphore in tty_ldisc_ref(). > > We've seen the following crash on v4.9.108 stable: > > BUG: unable to handle kernel paging request at 0000000000002260 > IP: [..] n_tty_receive_buf_common+0x5f/0x86d > Workqueue: events_unbound flush_to_ldisc > Call Trace: > [..] n_tty_receive_buf2 > [..] tty_ldisc_receive_buf > [..] flush_to_ldisc > [..] process_one_work > [..] worker_thread > [..] kthread > [..] ret_from_fork > > I think, tty_ldisc_reinit() should be called with ldisc_sem hold for > writing, which will protect any reader against line discipline changes. > > Note: I failed to reproduce the described crash, so obiviously can't > guarantee that this is the place where line discipline was switched. This will be same with a report at https://syzkaller.appspot.com/bug?id=f08670354701fa64cc0dd3c0128a491bdb16adcc . syzbot is now testing a patch from Jiri Slaby.