Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4176059pxf; Tue, 23 Mar 2021 04:51:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTAF8+O2TW2w2y5ulblelvsGF6fVO5kToom2Geu7xI1Sj2oUrNu9BnK+tHe4jfpIZSFydA X-Received: by 2002:a17:906:9501:: with SMTP id u1mr4604811ejx.324.1616500296893; Tue, 23 Mar 2021 04:51:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616500296; cv=none; d=google.com; s=arc-20160816; b=QghLmqoH+vW4/KR3vI/9qJZ+knlDRxXRlueNKyxekELWedc+/24v9XgRhEYhuVDYLY VggWok1fv6uky1dWrbu2b+3Ls4y4FVbejdE862oYlb8b8v6wNHrd7fzX4mRIw6iqyGZ4 SjDXFpFsYu8uIWOjYZfykhs/iEhan3bZmXtyCZdgTuyBkk9BapNEONVdSUd1+yWbVBYw E5wBOxJ2JzLu7EtVy+tyvXXCX+P23hA5nQwGVAP30UAapaHR9fMZn3iMqgcf0S5ZxNAh qR3eySHXmDUTDi54ze3qbXlN8aj1CJanc9vuIE3PyVxkYnThDfL00xrrDGGbQ4oHiU0K GgWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Npv76KkPJw9jO4Ft8/M9YyDbnr+j3tl96yB10yNzbfM=; b=ViCy0wKV07WY6PFaf6qn7ND1ylu9cRz7x6d32OLYW/DDCNoyR1SlTh1TVd2/l0gPpr eHCT+ZlQA9z2yoZaDjTqLsOzvtHtaFLtVLKl7Pj2Wo/lWN9m0SgvXPvXkEkJ9/iQ4TS1 lqIAwUqzTJwxzFeZtWQWgVY4VAqAwf1YlqaA9qSoVJTepzQK4/Z3mGXBhGVhysof+SsS opuk9ZaSFKEP9B5nH8aptIg6oJB+vCzN/LXzco51n2szgWuuMGIJV0og89GSVeKifqMf 2GXRCuXDKYGDcS6DEq0JO132MsBY9gwIfmT/lvBUXVEZ9jZ6xiFHdbwcJs1Esj/yqkrc 16GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@veeam.com header.s=mx4 header.b=QtXYXdUD; 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=REJECT sp=REJECT dis=NONE) header.from=veeam.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si12857316ejw.222.2021.03.23.04.51.13; Tue, 23 Mar 2021 04:51:36 -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=@veeam.com header.s=mx4 header.b=QtXYXdUD; 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=REJECT sp=REJECT dis=NONE) header.from=veeam.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229452AbhCWLtn (ORCPT + 99 others); Tue, 23 Mar 2021 07:49:43 -0400 Received: from mx4.veeam.com ([104.41.138.86]:34984 "EHLO mx4.veeam.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbhCWLtI (ORCPT ); Tue, 23 Mar 2021 07:49:08 -0400 Received: from mail.veeam.com (prgmbx01.amust.local [172.24.0.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx4.veeam.com (Postfix) with ESMTPS id 5A68C114A89; Tue, 23 Mar 2021 14:49:05 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=veeam.com; s=mx4; t=1616500145; bh=Npv76KkPJw9jO4Ft8/M9YyDbnr+j3tl96yB10yNzbfM=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=QtXYXdUD6Z4oZ0WlqJ18CJYfFgKn2ciVKdlg4PXNK0sl8g2oxVzIkogP3jzgi8oaj +7k2r6mL77S+/UWWJhKDgs6MQYN3NlmC3flQAx8uVoQV05clLlnwaYhYflTH5Ra2D9 rn9N31tk2nUwH7BzezovCCPCfT/+A4TYBBySKhFA= Received: from prgdevlinuxpatch01.amust.local (172.24.14.5) by prgmbx01.amust.local (172.24.0.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.721.2; Tue, 23 Mar 2021 12:49:03 +0100 From: Sergei Shtepa To: Jens Axboe , , CC: , Subject: [PATCH 1/1] block: fix potential infinite loop in the negative branch in __submit_bio_noacct_mq() Date: Tue, 23 Mar 2021 14:48:36 +0300 Message-ID: <1616500116-3411-2-git-send-email-sergei.shtepa@veeam.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1616500116-3411-1-git-send-email-sergei.shtepa@veeam.com> References: <1616500116-3411-1-git-send-email-sergei.shtepa@veeam.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.24.14.5] X-ClientProxiedBy: prgmbx01.amust.local (172.24.0.171) To prgmbx01.amust.local (172.24.0.171) X-EsetResult: clean, is OK X-EsetId: 37303A29D2A50B586D7D62 X-Veeam-MMEX: True Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the blk_crypto_bio_prep() function returns false, the processing of the bio request must end. Repeated access to blk_crypto_bio_prep() for this same bio may lead to access to already released data, since in this case the bio_endio() function was already called for bio. The changes allow to leave the processing of the failed bio and go to the next one from the bio_list. The error can only occur when using inline encryption on request-based blk-mq devices and something went wrong in the __blk_crypto_bio_prep(). Signed-off-by: Sergei Shtepa --- block/blk-core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index fc60ff208497..825df223b01d 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1005,13 +1005,12 @@ static blk_qc_t __submit_bio_noacct_mq(struct bio *bio) if (unlikely(bio_queue_enter(bio) != 0)) continue; - if (!blk_crypto_bio_prep(&bio)) { + if (blk_crypto_bio_prep(&bio)) + ret = blk_mq_submit_bio(bio); + else { blk_queue_exit(disk->queue); ret = BLK_QC_T_NONE; - continue; } - - ret = blk_mq_submit_bio(bio); } while ((bio = bio_list_pop(&bio_list[0]))); current->bio_list = NULL; -- 2.20.1