Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3692141pxb; Mon, 24 Jan 2022 15:31:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxe3mu2NmiKPmnKRk1UwSAzO664ZJ7Od5R9gmGuOlc62Nfddqmh8rtbK6Fktbf29S6Qu28H X-Received: by 2002:a63:af48:: with SMTP id s8mr13309611pgo.615.1643066955431; Mon, 24 Jan 2022 15:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066955; cv=none; d=google.com; s=arc-20160816; b=EWyK85vcbeuGJU24yjqDyCnPHWKweq6r5np1DJKthzQcDmtvvk7wGw5GauGJvdchk/ hu2Rd+qpbh8WeO+DHVo8KiO3hCVVr9g3ONK8+eFNW6bkWyzK2io6yXSq5E8v9k60rVZ0 cojH8u3+QmoMRITOc2eFmn0frH7HXJFwhurCmClcnOYNO9UNAFCKT1tXDI06wSFVThGR C7pLqAI/1NKGlbfrQFvUPhBDHP+0tb+TT3AZfzhu9DBSxQWqxgrgzb40A+WQppAXCloU t1NIHcy3WgvtLrQ7IlDvaF8i6uCVTXGyyPvVV5yrxsIEkJgwjQXV65N1kTI+EisRzuKZ pLTA== 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=AeYzbj9Yf3Vcs5dO1xj8yhBOKbXn5rmOOrKw2cuTsu8=; b=v5E2R9qumdzFtACI8wHB374g2a2oU8c8tmtIjUvpn+aL0BSjS3LfX21VClF2DE5Sme KggAcnGyzztHVbJVE1ECmaazc8xO2UDih/tzfNhuqcaBAFpL+DDMeUsBr3yihrlzEBvn Rj4iKRhCMcAI7zruxO+n/2IVT4bYVdiYw1/OUKW7L8DToNrb60Ksa+innif76Lqjys0z zHBGaBgN9vxRdSm7I1w1tozfDeXSCbt6Tu4H/iQRaKMXm4sRq4HQKfVKfeipshLODQ2Q Rt4gulLBNeusn4iXCZptV8GLHStT+T94u/GQLXCV0dHnJSprdkOHZOAKrkM3hXLgscWA F75g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xgt1qOug; 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 nl7si699778pjb.178.2022.01.24.15.29.02; Mon, 24 Jan 2022 15:29:15 -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=xgt1qOug; 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 S1351128AbiAXXX7 (ORCPT + 99 others); Mon, 24 Jan 2022 18:23:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1588119AbiAXWbj (ORCPT ); Mon, 24 Jan 2022 17:31:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A0A2C02B868; Mon, 24 Jan 2022 12:56:05 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CB2A560C60; Mon, 24 Jan 2022 20:56:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 933CBC340E5; Mon, 24 Jan 2022 20:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057764; bh=FRJ1sEdX/ouz9H8PhmcqYykcpScjvm5uCXoa1Ym69nI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xgt1qOug0IMXoIPiEiAxXaHh0zwWTAaHNSkG6EIvKKCpvyfmHXCVXGoodIj1W+XMY 2HghDfWRs0rtWg06MNUvHQM3nixzUNZEvgZ1vHOdmZncTZufizipUwYIiSZxpqzB0q jkRGrvi+oPb6Dob0Z451JR01eZ1CivzpEzRYThHw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hao Xu , Jens Axboe Subject: [PATCH 5.16 0071/1039] io_uring: fix no lock protection for ctx->cq_extra Date: Mon, 24 Jan 2022 19:31:00 +0100 Message-Id: <20220124184127.559922995@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Hao Xu commit e302f1046f4c209291b07ff7bc4d15ca26891f16 upstream. ctx->cq_extra should be protected by completion lock so that the req_need_defer() does the right check. Cc: stable@vger.kernel.org Signed-off-by: Hao Xu Link: https://lore.kernel.org/r/20211125092103.224502-2-haoxu@linux.alibaba.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6544,12 +6544,15 @@ static __cold void io_drain_req(struct i u32 seq = io_get_sequence(req); /* Still need defer if there is pending req in defer list. */ + spin_lock(&ctx->completion_lock); if (!req_need_defer(req, seq) && list_empty_careful(&ctx->defer_list)) { + spin_unlock(&ctx->completion_lock); queue: ctx->drain_active = false; io_req_task_queue(req); return; } + spin_unlock(&ctx->completion_lock); ret = io_req_prep_async(req); if (ret) {