From patchwork Tue Jun 16 15:33:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 224359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0960C433E0 for ; Tue, 16 Jun 2020 16:12:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7C6A2071A for ; Tue, 16 Jun 2020 16:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592323936; bh=3oWwutp/+uahJDtgiqiuL+cN+x0gcWJYmPHEXiNUFu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=1L9IowhB4Qfc7bN8wRYCOh/vqM68agl5nsAgAv7AcZPb++KbKGWUldLC4bRF0OUjv WyTYbtptk4SUkALIYjNmHTOAumPkyZ3KNrB6hMJjvCivlEYSrfIuvDBaJwjDOkaqVv b7h1DltZ/wU5r5KgB+f3Geg2q6DeWtluvqal4uFE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730167AbgFPQMP (ORCPT ); Tue, 16 Jun 2020 12:12:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:33724 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731883AbgFPPn7 (ORCPT ); Tue, 16 Jun 2020 11:43:59 -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 547092151B; Tue, 16 Jun 2020 15:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592322238; bh=3oWwutp/+uahJDtgiqiuL+cN+x0gcWJYmPHEXiNUFu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wtty6JQAOB8DoyL/En+hapHbETtg7v2XN6SBQIkrDuNBzNdgjtAXaLcxp8Hiky13o ypHxj0BdGwxHF1nttpRqnygOaz62U9OoURlo4r49jGCPadIjAJ8RcTI/TPpLr6jANi SGrrmVoKoaZWudslN+aawp20LndmJKfWnJxh+o48= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 5.7 053/163] io_uring: fix flush req->refs underflow Date: Tue, 16 Jun 2020 17:33:47 +0200 Message-Id: <20200616153109.386860739@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200616153106.849127260@linuxfoundation.org> References: <20200616153106.849127260@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pavel Begunkov commit 4518a3cc273cf82efdd36522fb1f13baad173c70 upstream. In io_uring_cancel_files(), after refcount_sub_and_test() leaves 0 req->refs, it calls io_put_req(), which would also put a ref. Call io_free_req() instead. Cc: stable@vger.kernel.org Fixes: 2ca10259b418 ("io_uring: prune request from overflow list on flush") Signed-off-by: Pavel Begunkov 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 @@ -7390,7 +7390,7 @@ static void io_uring_cancel_files(struct * all we had, then we're done with this request. */ if (refcount_sub_and_test(2, &cancel_req->refs)) { - io_put_req(cancel_req); + io_free_req(cancel_req); finish_wait(&ctx->inflight_wait, &wait); continue; }