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=-5.3 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,URIBL_BLOCKED,USER_AGENT_SANE_1 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 E93FFC0650F for ; Thu, 8 Aug 2019 09:00:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB6622186A for ; Thu, 8 Aug 2019 09:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565254829; bh=SRqtwHkeZ7xZQv9nJbXGMQt5Wm1SZ4F/TAG6xDWQXKI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=pJT44ckXk+BBC87pIGFQsfs9LrlCuFI7UyxEy3cmiW5g1QTO36BXF/bfCloL3Xsfg /zxVlFqeeNijaV123BgVIGvg8aZrmAdQwEteRCpXN8y9K6L6+cxfm1a8EWPOmizO1V WGm5w1rv6EQCa1tZKsUcKoocYt5efWIThMBSk4gI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731038AbfHHJA3 (ORCPT ); Thu, 8 Aug 2019 05:00:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:56572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731031AbfHHJA3 (ORCPT ); Thu, 8 Aug 2019 05:00:29 -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 D63AB217F4; Thu, 8 Aug 2019 09:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565254828; bh=SRqtwHkeZ7xZQv9nJbXGMQt5Wm1SZ4F/TAG6xDWQXKI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kuH9kJKeSM8oFMqyAyrDwvFTEciUq7x1sfRT5G5JfNnNWY9QeDPYNNWpJEsebVjnM ouc8NK6xc5o9gPKPiWriQgXTwyJMQ16v68Fqgv3iA/zcNPkiJIpoyv1YaIGyVpzUAo o01qt5Pju6n/EOIATncfRTrUwkv3VmlYsHqs7Mks= Date: Thu, 8 Aug 2019 11:00:25 +0200 From: Greg Kroah-Hartman To: Guenter Roeck Cc: stable@vger.kernel.org, xiao jin , Jens Axboe Subject: Re: [PATCH v4.4.y, v4.9.y] block: blk_init_allocated_queue() set q->fq as NULL in the fail case Message-ID: <20190808090025.GB1265@kroah.com> References: <1565032365-7089-1-git-send-email-linux@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1565032365-7089-1-git-send-email-linux@roeck-us.net> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, Aug 05, 2019 at 12:12:45PM -0700, Guenter Roeck wrote: > From: xiao jin > > commit 54648cf1ec2d7f4b6a71767799c45676a138ca24 upstream > > We find the memory use-after-free issue in __blk_drain_queue() > on the kernel 4.14. After read the latest kernel 4.18-rc6 we > think it has the same problem. > > Memory is allocated for q->fq in the blk_init_allocated_queue(). > If the elevator init function called with error return, it will > run into the fail case to free the q->fq. > > Then the __blk_drain_queue() uses the same memory after the free > of the q->fq, it will lead to the unpredictable event. > > The patch is to set q->fq as NULL in the fail case of > blk_init_allocated_queue(). > > Fixes: commit 7c94e1c157a2 ("block: introduce blk_flush_queue to drive flush machinery") > Cc: > Reviewed-by: Ming Lei > Reviewed-by: Bart Van Assche > Signed-off-by: xiao jin > Signed-off-by: Jens Axboe > [groeck: backport to v4.4.y/v4.9.y (context change)] > Signed-off-by: Guenter Roeck > --- > This patch was not applied to v4.4.y and v4.9.y due to a context conflict. > See https://lore.kernel.org/stable/1536310209129100@kroah.com/ and > https://lore.kernel.org/stable/153631018011582@kroah.com/ for details. > It was applied to v4.14.y and to v4.18.y. > > Please consider applying this backport. It is relevant because it fixes > CVE-2018-20856. Now queued up, thanks. greg k-h