Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2295290pxp; Mon, 21 Mar 2022 16:09:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3+MUE0gGdu54iP9xehSblJdxrEIgKotbKvpAY+KtFP7Dlehm9fP0t9PI55n03Yx+xsIBr X-Received: by 2002:a17:902:e801:b0:154:19ec:53a2 with SMTP id u1-20020a170902e80100b0015419ec53a2mr15016851plg.151.1647904153898; Mon, 21 Mar 2022 16:09:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647904153; cv=none; d=google.com; s=arc-20160816; b=k4t+qzzKGA9wHVWShcOcJXXE/rRDH+ejqU0HbgDpyO8XoSFgmNPG8fbPs5Jt9dD038 smrdYr3GBAke2/YIXbCd1BN6ULi2YNWflZJ387KaMz33U0khjr3DkwEGKQxijt5D46Qv J1eTRtKzEHockdqXjaqKEdtlZ6Ja7FVKipN6BCUryIpbpTtvbAYXFRgi+AV8FNgGu+Hz Q8GG2sBtJaE4KlL05yHjkZIYpjCiSNjRcBObTDkMXR+NBUySD1ypOx7uqzHMtbUtAl9v MXTwI4KDjdC6H0M0h0aPIjk+i3Q+usOsDOR07YnuVRv31eKYpJR2uEGJR59Z9FeU8dON DkGw== 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=fur5XoozKk9kS2NCawxMfrIFpPDCDb1kFm04VoUJNI0=; b=bbwVTOOx46ZWOZjG3+5+YHFJm+US59I8C+9o0XFFRlzcMFFS9r8MvqzLH6CcXr+km1 Pdh7gSodqB22CQRfSg/9FAVjnAF3y0bmxioUHkce1FJp6cvyspPOcpXsWbRMqmZ/48Q+ fBHAlllCsv2h4LbQ8gdmTCZt7dA6jTfub5UXPhnekwZ5mAxU+qUO5uiXkUK7ayRGWJV4 g5KpN5rPZEMAuIFoBJKUVWevxbaTbcjCt3wCESS1AdUfLUKRiHpOEl99BpYiba/NEtl9 v7JsCmeQhU6YVaWQRvXfWewdLHZ7P4J0BkIn6HJgEPIEKOz+1HfqPefhFX/y5iRLdH5u vmvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NQh0yM0b; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q24-20020a63e958000000b003816043f006si13906244pgj.507.2022.03.21.16.09.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:09:13 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NQh0yM0b; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 22AE3426350; Mon, 21 Mar 2022 15:07:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351693AbiCUOLa (ORCPT + 99 others); Mon, 21 Mar 2022 10:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348802AbiCUODx (ORCPT ); Mon, 21 Mar 2022 10:03:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6091D18114A; Mon, 21 Mar 2022 07:01:13 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id 0413DB816CE; Mon, 21 Mar 2022 14:01:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65531C340ED; Mon, 21 Mar 2022 14:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871270; bh=aZf76KE9DN5cxUeQ8w5mlraiAepMF2EIiwiv9GroYyk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NQh0yM0bJ+jxkhzJ9501otf9GGxI2Es3tIvKc/y62zUfxqdlLJwrPdLrchBI/pWpX GtUCByu7jeKiBel8rzyklHlr/UtY6tBBVRkvw97d/uuBbbGCinkxCgmG5CbI2NPfbE GnyfwguyT0ccMkIsjDD5kT/bF9kzbDqD3vWUtXUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , syzbot+b42749a851a47a0f581b@syzkaller.appspotmail.com, Ming Lei , Bart Van Assche , Jens Axboe Subject: [PATCH 5.15 04/32] block: release rq qos structures for queue without disk Date: Mon, 21 Mar 2022 14:52:40 +0100 Message-Id: <20220321133220.691523932@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133220.559554263@linuxfoundation.org> References: <20220321133220.559554263@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei commit daaca3522a8e67c46e39ef09c1d542e866f85f3b upstream. blkcg_init_queue() may add rq qos structures to request queue, previously blk_cleanup_queue() calls rq_qos_exit() to release them, but commit 8e141f9eb803 ("block: drain file system I/O on del_gendisk") moves rq_qos_exit() into del_gendisk(), so memory leak is caused because queues may not have disk, such as un-present scsi luns, nvme admin queue, ... Fixes the issue by adding rq_qos_exit() to blk_cleanup_queue() back. BTW, v5.18 won't need this patch any more since we move blkcg_init_queue()/blkcg_exit_queue() into disk allocation/release handler, and patches have been in for-5.18/block. Cc: Christoph Hellwig Cc: stable@vger.kernel.org Fixes: 8e141f9eb803 ("block: drain file system I/O on del_gendisk") Reported-by: syzbot+b42749a851a47a0f581b@syzkaller.appspotmail.com Signed-off-by: Ming Lei Reviewed-by: Bart Van Assche Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20220314043018.177141-1-ming.lei@redhat.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/blk-core.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/block/blk-core.c +++ b/block/blk-core.c @@ -49,6 +49,7 @@ #include "blk-mq.h" #include "blk-mq-sched.h" #include "blk-pm.h" +#include "blk-rq-qos.h" struct dentry *blk_debugfs_root; @@ -380,6 +381,9 @@ void blk_cleanup_queue(struct request_qu */ blk_freeze_queue(q); + /* cleanup rq qos structures for queue without disk */ + rq_qos_exit(q); + blk_queue_flag_set(QUEUE_FLAG_DEAD, q); blk_sync_queue(q);