Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9092507pxu; Mon, 28 Dec 2020 06:27:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJz3o2d/8oZcdtYKWin3gNZaRsIYWYwRcxk1dbong8P78qKWftLsTCXxghR9WdRwpVtr8dUU X-Received: by 2002:a17:906:4e46:: with SMTP id g6mr24051117ejw.243.1609165646381; Mon, 28 Dec 2020 06:27:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165646; cv=none; d=google.com; s=arc-20160816; b=NDBuWJzAwwuz9Z71E/lF/9TXOoBTsjpIxeA04gugm6ds17stilAnaNMoBfN5viOw0+ 1H7/hoPpcqz1yIDtAGyF9y06ZQx6AhB4iQHK+/AzS8FS607FM1jGRcXPjUiprXlNGuta uqx/CEVbjH4rAMFQ9m0gbMTLKa3UXEnNL8pdNgjCx+jrtujHdx2wa5DWMmGp+W1CeWhJ Lsvoe4sYy+4Bu7/Hqg0Vq8I1mLsYLOyoKvj9BoS5mmCaqbtplGVGZGnE6ZOkje/R9gIO dUZxfMQKD+CZQeEh/One9wUaLb6h5qYH1ZlrizRriNmcjP03Us0etEBe6E7knNbWOU/M 6hJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=66iJSDzMGgI5PFziJID0Rce82tYNUEHQqjw2Tkq8qcI=; b=shRv7uPV+FCycmlOJoXMtdHFXu6vwQuC5N2tsWo/RMEBo9ZG/sVJNTNY/4EQuxLzQZ +HqB01YxXn/4itxXxVFwqB4iOHv61YU/Iak3LMIGnsHUn0tuJCmzQfzClL892fd/KN6S S77wVX4xgKubwibGIaPZ5dqAVTjYQXWzvx1/GH8zWHnSEA0RYi5n64IdMHIHkFSPEuhJ rp6ENi4nJLfszdOIQYpmiSd6zh/fN8SCSDZzgpKZfcEuHVEEw0ARyWh7/GbIgU/DGy71 IW7Ho1IzwGQ4CVf7JC3w9OzVKR1deAKsrqTsGwIm+Hdj5zoJJwMvoWr/Qy39nLITnx4M QTMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j2Yx0v3N; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si18508211ejw.16.2020.12.28.06.27.03; Mon, 28 Dec 2020 06:27:26 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=j2Yx0v3N; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503175AbgL1OZB (ORCPT + 99 others); Mon, 28 Dec 2020 09:25:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:60706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503157AbgL1OYz (ORCPT ); Mon, 28 Dec 2020 09:24:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C9163229C4; Mon, 28 Dec 2020 14:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165480; bh=vqdLYbClBal+Jud/e7Od8n3nHS7UoXrCHd/ag/RUQxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j2Yx0v3NOH7iP7JE/Pi2qcUqxoNkHKwsWnQ+SiuPcvOrxqKl29lKf7sMqjF2v0e2i g+yo1zcEBZMjaThrbfetTHbSDqj9qbBbOZ0ntzj4b6ShezYRriFVnjdLkHaOMtkPwJ EOHpOeflRKkwH5I6jTtrYQHXNLvBz/mIhX9OrUdM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaoguang Wang , Pavel Begunkov , Jens Axboe Subject: [PATCH 5.10 516/717] io_uring: fix io_wqe->work_list corruption Date: Mon, 28 Dec 2020 13:48:34 +0100 Message-Id: <20201228125045.676509466@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaoguang Wang commit 0020ef04e48571a88d4f482ad08f71052c5c5a08 upstream. For the first time a req punted to io-wq, we'll initialize io_wq_work's list to be NULL, then insert req to io_wqe->work_list. If this req is not inserted into tail of io_wqe->work_list, this req's io_wq_work list will point to another req's io_wq_work. For splitted bio case, this req maybe inserted to io_wqe->work_list repeatedly, once we insert it to tail of io_wqe->work_list for the second time, now io_wq_work->list->next will be invalid pointer, which then result in many strang error, panic, kernel soft-lockup, rcu stall, etc. In my vm, kernel doest not have commit cc29e1bf0d63f7 ("block: disable iopoll for split bio"), below fio job can reproduce this bug steadily: [global] name=iouring-sqpoll-iopoll-1 ioengine=io_uring iodepth=128 numjobs=1 thread rw=randread direct=1 registerfiles=1 hipri=1 bs=4m size=100M runtime=120 time_based group_reporting randrepeat=0 [device] directory=/home/feiman.wxg/mntpoint/ # an ext4 mount point If we have commit cc29e1bf0d63f7 ("block: disable iopoll for split bio"), there will no splitted bio case for polled io, but I think we still to need to fix this list corruption, it also should maybe go to stable branchs. To fix this corruption, if a req is inserted into tail of io_wqe->work_list, initialize req->io_wq_work->list->next to bu NULL. Cc: stable@vger.kernel.org Signed-off-by: Xiaoguang Wang Reviewed-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io-wq.h | 1 + 1 file changed, 1 insertion(+) --- a/fs/io-wq.h +++ b/fs/io-wq.h @@ -59,6 +59,7 @@ static inline void wq_list_add_tail(stru list->last->next = node; list->last = node; } + node->next = NULL; } static inline void wq_list_cut(struct io_wq_work_list *list,