Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2102573pxb; Fri, 5 Mar 2021 07:20:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxH9U5JESnvlqxsVARvKC9bV52JprDrP/le29co8oyqLgajN9gQJhMZqdDlTJE9rjrysxNl X-Received: by 2002:a50:9d0b:: with SMTP id v11mr9696739ede.308.1614957655675; Fri, 05 Mar 2021 07:20:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614957655; cv=none; d=google.com; s=arc-20160816; b=hDwbBZaF3FuKM3U2gwiuChi0g3PrFq9eQCtPl/kM+Wn53aI/b3QLMR59gCkkeVxvkm cmc2l+YTcMAaO12xgE9beh3U81AGZvHJH/HO/PTNjwjAduWBBwBR4W3qW3cSaHO4RgJX NAth/kznNFuUaDCVlE5VOhtF6e4bKO5kQRqGDuOFvY442IdjP01eqCiXGejw2kefrGjq LMb/ufbJDdAKkUu5TyKMh/kNRr8n+xl/SUU94JmOjKLP83R9ItVNm8MP7+WFhp25N3EK EtuwQ/wA/L1Dq6CDTUNj4cjod047GsV5c9MycDL0URIT8BQN4uFyGLQHFvopMUvqRbDO 2Otw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=FdjXtWWMdbF9gfvE3s+FL2HGOeHNrRNwfQ3G+uO7n/Q=; b=XFa0JNQWgdAYDizrVLm3Hy8X3DwMfVA4dD9PCkx9f9qNVHM9Sru1pJnYLkk9ojgtVD QpUrGJG0dxUIAC4/U5yR0zl7jUAg+QBx/KMaYJoYxb4Z3SRNWioGN/VkvKV6MXp+HevM dtjPB76wNaB8wW5JJ2ePljBz8SsIKsPykwfqbLxEr0PRt6FQ1yWSMXdmdyBG4S1gvNej ERcRTV7qCWHIlwioa5jujennCJK6Tb3QuevDL7KKqcjRPxusOu6e1KooYVEX+6j20nzx YMK6dj1GMv1v55jxUsxM/DrAJhpOAk1pq2+Je3cFETTZ/6LkQJkMwDdTHRu1HyHJ7zTJ assA== 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 s14si1408373edx.521.2021.03.05.07.20.27; Fri, 05 Mar 2021 07:20:55 -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 S229892AbhCEPTc (ORCPT + 99 others); Fri, 5 Mar 2021 10:19:32 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:12698 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229922AbhCEPTU (ORCPT ); Fri, 5 Mar 2021 10:19:20 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DsWYZ2X5XzlSk3; Fri, 5 Mar 2021 23:17:06 +0800 (CST) Received: from localhost.localdomain (10.69.192.58) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Fri, 5 Mar 2021 23:19:07 +0800 From: John Garry To: , , , , CC: , , , , , John Garry Subject: [RFC PATCH v3 0/3] blk-mq: Avoid use-after-free for accessing old requests Date: Fri, 5 Mar 2021 23:14:51 +0800 Message-ID: <1614957294-188540-1-git-send-email-john.garry@huawei.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.58] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series aims to tackle the various UAF reports, like: [0] https://lore.kernel.org/linux-block/8376443a-ec1b-0cef-8244-ed584b96fa96@huawei.com/ [1] https://lore.kernel.org/linux-block/5c3ac5af-ed81-11e4-fee3-f92175f14daf@acm.org/T/#m6c1ac11540522716f645d004e2a5a13c9f218908 [2] https://lore.kernel.org/linux-block/04e2f9e8-79fa-f1cb-ab23-4a15bf3f64cc@kernel.dk/ [3] https://lore.kernel.org/linux-block/b859618aeac58bd9bb620d7ebdb24b90@codeaurora.org/ Details are in the commit messages. The issue addressed in patch 1/3 is pretty easy to reproduce, 2+3/3 not so much, and I had to add mdelays in the iters functions to recreate in sane timeframes. A regards patch 1/3, if 2+3/3 are adopted, then this can simplified to simply clear the tagset requests pointers without using any atomic operations. However, this patch on its own seems to solve the problem [3], above. So the other 2x patches are really for extreme scenarios which may never be seen in practice. As such, it could be considered to just accept patch 1/3 now. Differences to v2: - Add patch 2+3/3 - Drop patch to lockout blk_mq_queue_tag_busy_iter() when exiting elevator John Garry (3): blk-mq: Clean up references to old requests when freeing rqs blk-mq: Freeze and quiesce all queues for tagset in elevator_exit() blk-mq: Lockout tagset iterator when exiting elevator block/blk-mq-sched.c | 2 +- block/blk-mq-tag.c | 7 ++++++- block/blk-mq.c | 21 +++++++++++++++++++-- block/blk-mq.h | 2 ++ block/blk.h | 23 +++++++++++++++++++++++ include/linux/blk-mq.h | 1 + 6 files changed, 52 insertions(+), 4 deletions(-) -- 2.26.2