Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4985098rwr; Sun, 23 Apr 2023 18:27:31 -0700 (PDT) X-Google-Smtp-Source: AKy350ZyyBOuyBne93yHKMbjfOb9H2pX8BBo47W6p9pb3z0HX4qbwWLwhBbL3CY1tfkBtcv9Xj5P X-Received: by 2002:a17:902:d2c7:b0:1a1:be45:9857 with SMTP id n7-20020a170902d2c700b001a1be459857mr16864223plc.1.1682299650869; Sun, 23 Apr 2023 18:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682299650; cv=none; d=google.com; s=arc-20160816; b=h6P8zXojn4nyHm5SRSzO4EG6aQx8+knA7Z1t+KRL87XAyd/4EY+ciNfnmrF2GeqroC mtPj+edoUKuocpPJW0HkFewpc86LYMH7OiviQ/MWiNA5SKiZalhc9K4Pu1jYuvpX8ztd 3AkqmDbj31N8H1+4scGISi23mOh+S4wLlV+C+nxPWd13LWqe3vK16BnpqqggXUyGyoQs jloTbbOcbTEKrlPOnFL33lvJH6HvvCyCNaqw8U6T56YVPNBfUqeveo5IKwtXB69gwtEc H+gxhNJjIKn+IShfRcFu7vyAM1X1+kicAadzpw1KmbuRrfmodiTbkg/NTvxRvE+Ol7OL yBOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=0spUjL1w15l3FgA59YnHEj3dbemHbAQcRIT/oKZZu2g=; b=PRx2TL9f8aO/nuEybQ4+DelNAHVPmVtEnrscJYMuGMwv7nGIHLXIF1nCWQW+JnUL3d inPcD2capbi6DnPOcDjsG8HB6Sz3xBYNtCdBrQiYH2FvQ/6G1wON0809tn/148K1HZFn yeLhlW57Nb960THzcK3AiLwKTlhdfPcQimqqWDrB5cxxcjPIKdU/lw8jf3t414RXZRWj TCiLWwQmS797QvFpoluCM/Z1ZsXpSFE26Z6kL/d/I/qlG2OglclpSE3rh556qjm1/nJG OqDzvPzAmyJICMCXe/INXNv9E1n3w/I67RcYRkS6WyPfaVtgZIY9CH/dzAizsLWgX7tZ KAfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020a1709029a8e00b001a6bb7b7a44si9582140plp.307.2023.04.23.18.27.14; Sun, 23 Apr 2023 18:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230228AbjDXBJf (ORCPT + 99 others); Sun, 23 Apr 2023 21:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjDXBJd (ORCPT ); Sun, 23 Apr 2023 21:09:33 -0400 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4293FE78 for ; Sun, 23 Apr 2023 18:09:32 -0700 (PDT) Received: from fsav411.sakura.ne.jp (fsav411.sakura.ne.jp [133.242.250.110]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 33O19EIC081629; Mon, 24 Apr 2023 10:09:14 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav411.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav411.sakura.ne.jp); Mon, 24 Apr 2023 10:09:14 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav411.sakura.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 33O19DfL081626 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Mon, 24 Apr 2023 10:09:14 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <8e21256a-736e-4c2d-1ff4-723775bcac46@I-love.SAKURA.ne.jp> Date: Mon, 24 Apr 2023 10:09:12 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [syzbot] [kernel?] KCSAN: data-race in __fput / __tty_hangup (4) Content-Language: en-US To: Al Viro Cc: Dmitry Vyukov , syzbot , Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com References: <00000000000013aaac05f9d44e7a@google.com> <6ff6fdea-c955-f9dd-289e-b0d613a28280@I-love.SAKURA.ne.jp> <20230423233433.GF3390869@ZenIV> <20230424004431.GG3390869@ZenIV> From: Tetsuo Handa In-Reply-To: <20230424004431.GG3390869@ZenIV> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/04/24 9:44, Al Viro wrote: > Do you mean doing that in method instances that are present in tty_fops > you mean doing that in method instances that are present in tty_fops > and different in hung_up_tty_fops? I meant, remove hung_up_tty_fops, and embed callbacks defined in hung_up_tty_fops into tty_fops. For example, tty_read() (from "struct file_operations tty_fops"->read_iter) will be changed like static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to) { int i; struct file *file = iocb->ki_filp; struct inode *inode = file_inode(file); struct tty_struct *tty = file_tty(file); struct tty_ldisc *ld; + if (data_race(file->tty_hangup)) { + return hung_up_tty_read(iocb, to); + } + if (tty_paranoia_check(tty, inode, "tty_read")) return -EIO; if (!tty || tty_io_error(tty)) return -EIO; /* We want to wait for the line discipline to sort out in this * situation. */ ld = tty_ldisc_ref_wait(tty); if (!ld) return hung_up_tty_read(iocb, to); i = -EIO; if (ld->ops->read) i = iterate_tty_read(ld, tty, file, to); tty_ldisc_deref(ld); if (i > 0) tty_update_time(&inode->i_atime); return i; } in order to avoid wrapping filp->f_op->* dereferences using data_race().