Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3803432ybi; Mon, 29 Jul 2019 12:57:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzf92nC2BpK2PZH6Efa1SiF86D9r1MBGDUn+D5hE//wUSyZ/2NN7Jz5B7Hnsj7iGOietXr/ X-Received: by 2002:a17:90a:d814:: with SMTP id a20mr113905289pjv.48.1564430252327; Mon, 29 Jul 2019 12:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430252; cv=none; d=google.com; s=arc-20160816; b=lYdGgfQ4nBnAzz3azwGzwhKLa9K8yOkAGFP6t8DON0wRr8TKPlvdTx/0L7ek53WFx7 MQoN9Bb3yOkrJh90rEENKgeLljCol7dgucMONxrRvRFvsK/LxcLGG/18YPxCtClus0e8 gHWaR9+5ELWKVfaf7IrksLprFhKuF2OIjw35827kqLk6aRRwyVovBCKxDHIkDHbJruZB RdPSQX7nABf+J6KZX4sAj6e5YCumEzed6siwYcYpmpVIZRc7/6z23bS63Ulcv7vh6HP2 jBtmP2y69MRTPtUbfY89NrKGR+6zMd7RlyF4m5svRfhPpsp+lelU5/TcT22Fqf3jVzD1 z4JQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yDRP434Q5if7NP7BuM4yaKWFVtMSYPVa7b8pMrUxsVI=; b=t6jdAoqjyJ7i5luLrZhvmq9nib8qbv1zoyczgTBmgXdaouNNiRPFv2Fpno68TeQWNb 1Tx283EqfUIS2xFe94NmzslrIZDH3d9sLc2jnQ7eFLeHyf5QRM9mu3Nv9BKHX/ScPwec NpAHs1QVOxVl9yMKMgZvA9FXXNQWAk8JelDcM8ikZHgdVviyZ6AwZ5bYX2nwepWlNSED YfzxG1pfJuwCUjORPHPLAnW9ssFQzXfxvrM+uDFmuZ3KDWNoKWAkMQhGeKFVG18YTmCD SBY5jDF4SP0tMr0WI01q9Lzzddo0ayQl18VMJlbYbgND2w2TU+FASOwIOLvwAMsieF69 /8tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MPK2Rn1J; 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 n128si27601400pgn.82.2019.07.29.12.57.17; Mon, 29 Jul 2019 12:57:32 -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; dkim=pass header.i=@kernel.org header.s=default header.b=MPK2Rn1J; 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 S2404321AbfG2T4J (ORCPT + 99 others); Mon, 29 Jul 2019 15:56:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:49006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404315AbfG2T4H (ORCPT ); Mon, 29 Jul 2019 15:56:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F27F321655; Mon, 29 Jul 2019 19:56:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430166; bh=O3KG9Nz1k06UKZGcnzV3zAkp4uWNexemALwHWlzerqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MPK2Rn1JzBsf9EJUm8zKXmkEgqPOhRMCOaZeBhrW5V9Vz3p9OvZSuUm166A6n39vP VO1QMrOW0sni4ELjQFK29wUkX0Dheb99nLPvwDOvBYQ3ei7l1ptW54f32wADfTT5QO NKrIqX8UdlvNjsNzSyMrovBF5rxIke248Gn8abE0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhengyuan Liu , Jens Axboe Subject: [PATCH 5.2 201/215] io_uring: fix the sequence comparison in io_sequence_defer Date: Mon, 29 Jul 2019 21:23:17 +0200 Message-Id: <20190729190814.779830632@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhengyuan Liu commit dbd0f6d6c2a11eb9c31ca9cd454f95bb5713e92e upstream. sq->cached_sq_head and cq->cached_cq_tail are both unsigned int. If cached_sq_head overflows before cached_cq_tail, then we may miss a barrier req. As cached_cq_tail always follows cached_sq_head, the NQ should be enough. Cc: stable@vger.kernel.org Fixes: de0617e46717 ("io_uring: add support for marking commands as draining") Signed-off-by: Zhengyuan Liu Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -425,7 +425,7 @@ static inline bool io_sequence_defer(str if ((req->flags & (REQ_F_IO_DRAIN|REQ_F_IO_DRAINED)) != REQ_F_IO_DRAIN) return false; - return req->sequence > ctx->cached_cq_tail + ctx->sq_ring->dropped; + return req->sequence != ctx->cached_cq_tail + ctx->sq_ring->dropped; } static struct io_kiocb *io_get_deferred_req(struct io_ring_ctx *ctx)