Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1664189pxb; Mon, 8 Mar 2021 03:24:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBbQzAOCL+g384PdIWioSmV9NDeFHUPDaMMlsRwoniGJw+KsnTHSjSKkOmx7aP4smaihQd X-Received: by 2002:a05:6402:51d4:: with SMTP id r20mr21568263edd.112.1615202657708; Mon, 08 Mar 2021 03:24:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615202657; cv=none; d=google.com; s=arc-20160816; b=uk8ICsNP9m707px32WxrdjmronVOA1MeW+s/XgUB7BGntXCjLokDIKqoVGLYd2CH+h J9JkFNbjwoEbUsaULUPwlFxg83QPoylP611LZj3dnmKvZiYI6aZU3utewVI46FIsGzwv WTOkzG8PvbQr693jkvzOUnhF35uiBH6khM3UlPeFxXWxQCzqx686Xw3nZoUEQrP6SuNy FEN6zYSgOn8A0VhAdrHO0W4jKNxMPIP87sK1hdGzUNBcwjAzgaQap9MxubS2DLoSfuZY aK29AFroYK1lhTJ5UVmMBYIiEaTMFJQvYw67ngNIrslG7rj1XxdnQxkezODCl4gurTo5 AK8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=gHKRoVYpTiObsABdxZymQuEfHHwu4jSMUcohQFh24Zs=; b=PXNzU8aRlSDj8g/Gyp602cdfKZr0OKph5B/Oe/yrzAVvb45rPCG3iOO+e7jMNb2r2b RgYseOj6QqbC/LP3OtnpvDAa/ItDnpbKT3dzWrmZyf4uVI0aBIHjBViHkUA5KE3xAGXi FRHdrAX/BSr8DyTZZziOnLZy2rBQNzp9PRyXWTv68ZdQuRMKDoTQScPtk7oqRLOqQhzs XmA960RAN0jzdB6gJRGJcJPGkqBqv/CDpTX4IyEHJdvUycWzhTO+xw1yMHEV6alzHiMc wQUi44q8+3pqjFCm/KLg63g1jtesK1gK/qFO9JzjVZ0SVt7VzKOmByBRvcIZP/BL/mal 1wNQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox25si6699124ejb.183.2021.03.08.03.23.55; Mon, 08 Mar 2021 03:24:17 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231759AbhCHLVT (ORCPT + 99 others); Mon, 8 Mar 2021 06:21:19 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2652 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231760AbhCHLU7 (ORCPT ); Mon, 8 Mar 2021 06:20:59 -0500 Received: from fraeml745-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DvG2w4069z67wh2; Mon, 8 Mar 2021 19:15:04 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml745-chm.china.huawei.com (10.206.15.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 8 Mar 2021 12:20:58 +0100 Received: from [10.210.165.214] (10.210.165.214) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 8 Mar 2021 11:20:56 +0000 Subject: Re: [RFC PATCH v3 1/3] blk-mq: Clean up references to old requests when freeing rqs To: Khazhy Kumykov CC: , Bart Van Assche , , Jens Axboe , , , Linux Kernel Mailing List , , , References: <1614957294-188540-1-git-send-email-john.garry@huawei.com> <1614957294-188540-2-git-send-email-john.garry@huawei.com> From: John Garry Message-ID: <03e09428-b4e1-c77c-2e00-5b6fd53bf894@huawei.com> Date: Mon, 8 Mar 2021 11:18:57 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.1.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.210.165.214] X-ClientProxiedBy: lhreml739-chm.china.huawei.com (10.201.108.189) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/03/2021 02:52, Khazhy Kumykov wrote: > On Fri, Mar 5, 2021 at 7:20 AM John Garry wrote: >> >> It has been reported many times that a use-after-free can be intermittently >> found when iterating busy requests: >> >> - https://lore.kernel.org/linux-block/8376443a-ec1b-0cef-8244-ed584b96fa96@huawei.com/ >> - https://lore.kernel.org/linux-block/5c3ac5af-ed81-11e4-fee3-f92175f14daf@acm.org/T/#m6c1ac11540522716f645d004e2a5a13c9f218908 >> - https://lore.kernel.org/linux-block/04e2f9e8-79fa-f1cb-ab23-4a15bf3f64cc@kernel.dk/ >> >> The issue is that when we switch scheduler or change queue depth, there may >> be references in the driver tagset to the stale requests. >> >> As a solution, clean up any references to those requests in the driver >> tagset. This is done with a cmpxchg to make safe any race with setting the >> driver tagset request from another queue. > > I noticed this crash recently when running blktests on a "debug" > config on a 4.15 based kernel (it would always crash), and backporting > this change fixes it. (testing on linus's latest tree also confirmed > the fix, with the same config). I realize I'm late to the > conversation, but appreciate the investigation and fixes :) Good to know. I'll explicitly cc you on further versions. Thanks, John