Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2852934pxj; Sun, 23 May 2021 13:08:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw10I0iIVgK7MFskPg0RT6D9A7Lqrops9YCXhXNjzcTtWMbz1lJzJ8RSgyMGdxFzWNYa/BA X-Received: by 2002:a92:b00d:: with SMTP id x13mr14446800ilh.181.1621800532206; Sun, 23 May 2021 13:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621800532; cv=none; d=google.com; s=arc-20160816; b=fjtxwta8GlmRYkobz70OMZP2oY8GO8uAyXw2bwqwtrsF6zSnHOYSVgHu9/qjcHVLyX DLQMkOtMk2nHuiIgJgUd+cT3jTRtjVm/03sTMZCJg64nCX7wqnBNK0waNH+N0qUe4l3G WYVjB2gI/l+FJrpGFOJsQUGb1IbTjaWuI1TTWd1AeA/S6tPB1LZnhw272t6HFK3yUyfC 4JXULoOG0OeGGoLjMLPH90VZ+UOUV5ooIc+oMX9eu1+eRHlmUU6uFPdsiStiWbH+6rQX vZjy+xdzHWvHUio4tX8Ayqkmdu4Chhh/2P3BowoREFfTJE8da9t+fiEpWO6gqWx4gcxm QqoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:to :from:subject:dkim-signature; bh=tggQNXprZ2KXMcjjAudcZ47jW995L9WF7pjIIOpjVVo=; b=N5tuaR42JtW33/CE2QRx843Qd4CR2nTBqg2Q3kRhd4i1OK0Lpatiq0dW0uCT1jMGTf 963MJOkGL8ZRYouAg/QiZ6/RMB2X7MNtdQ1U6k007nlcaGZEc5E/NsxroeknOTaiPIwh IqgNOWPmSjAlDByotN++NiTo+g9FgWdHuBMQJt7za4DeQW4Ihg7pI3clCGlk2/LgsHJm 381t8BlJeJiv7GCcLa7iRx3hPvALTVGeMWtWSP8pbPCvYuum1dNugwSwhSLkvI2r2yEU EJJI9yjyxf0M0xCPBmuprwK88C98DrUR/kiKpIO73py1YAyDAhEQXeQcmm/XKUKDcK2R Xa0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gYzxcdGG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d8si11755589ilo.3.2021.05.23.13.08.38; Sun, 23 May 2021 13:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gYzxcdGG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231934AbhEWUJP (ORCPT + 99 others); Sun, 23 May 2021 16:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbhEWUJO (ORCPT ); Sun, 23 May 2021 16:09:14 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E533C061574; Sun, 23 May 2021 13:07:46 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id n2so26429677wrm.0; Sun, 23 May 2021 13:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=tggQNXprZ2KXMcjjAudcZ47jW995L9WF7pjIIOpjVVo=; b=gYzxcdGGsjSXGl3H4eyLnY/jFZHQqFtP44csh7My3pbTf+k8L0bIkRF89rL64E1TT8 YYbIF3Dg38u55WdN2r/4JauWsDN0wlV1THrFf1nVt9B5Lyp/zT0RiiSFIFL16Qpvi22B VIiTrsMQFiqqXW0bfpQzp1aqpoWyPtKYsIRtMktAcjhbaNPEHwX+pQsvstqLaZqVPBFJ ubWRlh+5JId3DhqPY/Ru+zq+/Wb971KmOq931y5OrTn45miCVW7JYE3OYl5ByKIvQ+dn f34Fg82nus3l/J5oKKz2OwkqF7JZyYkjcZosUCLB6M5Ol9h40jF9hIvel6zOTLuewCgT zAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=tggQNXprZ2KXMcjjAudcZ47jW995L9WF7pjIIOpjVVo=; b=Z5KNvJBJ4AKpJgYhZetJk4H8wBAYJp7/2jZDsaK9otdM1x8AKCCYqImKaK3N1yks7v G+HgysQGClxvylwaHPZ5bDH1paJHQA8IDMrNIMwLD7cS166lbDUfb62L8eyf9QVW+mRv oDBB8Fiev+UBdQnT67UDtfOjM5KAxcSuZX4cSoVNJ7mvECXq4EltP6I4MCSJQhKokQrr aEKa7YlhRbuwLVD+TsWF4no9TOiTUY1m+0LvHSjSVL5o3PUlaYjnveCBSBrIZ2/M0Rwp QUecYkRp8UMHFVbvRbLu3EeLnineGdfh7xLtw3Ph9PGyriMCtqx0vGxBKfVFmcZ5mSbZ X3cg== X-Gm-Message-State: AOAM531AOq7wLMSn9Hdq2dFFFhUvoduLEQsrIWs+NtCInBGMqzN8eeED b4/Goyv4Ajepop/lHTZwNB4= X-Received: by 2002:a05:6000:118c:: with SMTP id g12mr18727886wrx.320.1621800464833; Sun, 23 May 2021 13:07:44 -0700 (PDT) Received: from [192.168.8.197] ([185.69.145.65]) by smtp.gmail.com with ESMTPSA id r17sm5889582wmh.25.2021.05.23.13.07.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 23 May 2021 13:07:44 -0700 (PDT) Subject: =?UTF-8?B?UmU6IOWbnuWkjTogW3N5emJvdF0gS0FTQU46IHVzZS1hZnRlci1mcmVl?= =?UTF-8?Q?_Read_in_io=5fworker=5fhandle=5fwork?= From: Pavel Begunkov To: "Zhang, Qiang" , syzbot , "axboe@kernel.dk" , "io-uring@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "syzkaller-bugs@googlegroups.com" References: <0000000000008224bf05c2a8a78b@google.com> Message-ID: <7243f420-58c5-60e4-6c8f-c16a90766c0c@gmail.com> Date: Sun, 23 May 2021 21:07:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/22/21 1:55 AM, Pavel Begunkov wrote: > On 5/21/21 9:45 AM, Zhang, Qiang wrote: > [...] >> It looks like >> thread iou-wrk-28796 in io-wq(A) access wqe in the wait queue(data->hash->wait), but this wqe has been free due to the destruction of another io-wq(B). >> >> Should we after wait for all iou-wrk thread exit in the io-wq, remove wqe from the waiting queue (data->hash->wait). prevent some one wqe belonging to this io-wq , may be still existing in the (data->hash->wait)queue before releasing. > > The guess looks reasonable, it's likely a problem. > Not sure about the diff, it seems racy but I need to > take a closer look to say for sure It looks sensible, please send a patch >> look forward to your opinion. >> >> --- a/fs/io-wq.c >> +++ b/fs/io-wq.c >> @@ -1003,13 +1003,17 @@ static void io_wq_exit_workers(struct io_wq *wq) >> struct io_wqe *wqe = wq->wqes[node]; >> >> io_wq_for_each_worker(wqe, io_wq_worker_wake, NULL); >> - spin_lock_irq(&wq->hash->wait.lock); >> - list_del_init(&wq->wqes[node]->wait.entry); >> - spin_unlock_irq(&wq->hash->wait.lock); >> } >> rcu_read_unlock(); >> io_worker_ref_put(wq); >> wait_for_completion(&wq->worker_done); >> + for_each_node(node) { >> + struct io_wqe *wqe = wq->wqes[node]; >> + >> + spin_lock_irq(&wq->hash->wait.lock); >> + list_del_init(&wq->wqes[node]->wait.entry); >> + spin_unlock_irq(&wq->hash->wait.lock); >> + } >> put_task_struct(wq->task); >> wq->task = NULL; >> } > -- Pavel Begunkov