From patchwork Sun Dec 11 22:20:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 13070672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 310B9C001B2 for ; Sun, 11 Dec 2022 22:21:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB0C28E0005; Sun, 11 Dec 2022 17:21:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A60F68E0002; Sun, 11 Dec 2022 17:21:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D9E18E0005; Sun, 11 Dec 2022 17:21:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7FAEF8E0002 for ; Sun, 11 Dec 2022 17:21:15 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 63061408C0 for ; Sun, 11 Dec 2022 22:21:15 +0000 (UTC) X-FDA: 80231447310.19.45FB6CD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id E906440003 for ; Sun, 11 Dec 2022 22:21:13 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KnQFdeff; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1670797274; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=pSMLLAxVMXnoWPwPea+ElcFQc/uDEfReQyP/onbm6ts=; b=pvVaTL3fgxmjAVPo/WjoonMO2W9kPrhmVlJ49rJKZ9qQr9eJhD2AZNEn0yGilHLH9cVbMJ kQDRpYrF0soQtq9FIrQPXFA+G9Zqw1hVqlafEO+E+j5SxNhzd8v2FkmmHaRYaw3A9NtDL4 eD/XFWfzyfkRjsUxh5u61OKYhJJLEF8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=KnQFdeff; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.hostedemail.com: domain of longman@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=longman@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670797274; a=rsa-sha256; cv=none; b=ksnVhnqWnrbg6qvUipc9ZzkCAQGP12UAI/Midexa7TAK033HGdu/dQCnh891jVyecSyNEr e7Kaewnq0mrVVVQQ7LW64tS50nxz/z5887d33DrFPHsnSv2a2LbQtURwYQhYZ/3iSDacDt EHvkLd7Cbp8oyRVPSLa5V7xVZEjudbE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670797273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pSMLLAxVMXnoWPwPea+ElcFQc/uDEfReQyP/onbm6ts=; b=KnQFdeff+5chuWd8wsL2UplGeNRbISEO8JDrxjyVb37wIm6usnAlT/ncf2eEIOb/JnzMnk DJ3SHnOhkn8D2v4S4i8DT9XGbCqt3oZWTCURmc8mRlCFBCdPm/ooCglxnriX258cC7w4yw 3WyZzZWqF6GoSnTpSCk5lmLCvEzDGWI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-cZw5i59hMJqVW7MRZaco6g-1; Sun, 11 Dec 2022 17:21:07 -0500 X-MC-Unique: cZw5i59hMJqVW7MRZaco6g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED062101A52A; Sun, 11 Dec 2022 22:21:06 +0000 (UTC) Received: from llong.com (unknown [10.22.16.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F8101121331; Sun, 11 Dec 2022 22:21:06 +0000 (UTC) From: Waiman Long To: Jens Axboe , Tejun Heo , Josef Bacik , Zefan Li , Johannes Weiner , Andrew Morton Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, =?utf-8?q?Michal_Koutn?= =?utf-8?q?=C3=BD?= , "Dennis Zhou (Facebook)" , Waiman Long Subject: [PATCH-block v2 0/3] blk-cgroup: Fix potential UAF & miscellaneous cleanup Date: Sun, 11 Dec 2022 17:20:55 -0500 Message-Id: <20221211222058.2946830-1-longman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E906440003 X-Stat-Signature: 5j99gew8ufohhdzyksixqfowprjaco8s X-HE-Tag: 1670797273-56955 X-HE-Meta: U2FsdGVkX1+dqLQnnyi5r7yGmJbWM5ojND89RkNYm+TrV7q4IkfUI90/Ub2Lc9Z9bXB3lcdrkpEh+B5Gu89M6bhtWlUmRhxpZDn/z6Z8W1198IZR6Y004vE5JWuYKN34TfpRth90t8ZLZgRUUM9KD/MVdlb5HwZqlXppoVsljkQAlIfrnl42wR//nkmQmpnyuyqFglLCsUVUOQ5hn0YYudY3IhEAiELHpO7BWc+YCsDRapHc7pBTvz2PfstfgQGVirqtE/j7Adu4oQCkMq7XFMIDSVizLipoWNfyXODkf5h6yLKOkJ9Y9A8VDdTvKCNynoJQcGjnlz+/8+mkMmCXEUOF/ta9N7vBLoCnWHvRjyzmSRUqF+1Fenbs4OCNFQOIgZhgGFD9UmXOZolazDdY88JMRfX/vM3qumV8QdQn5zLcfJak2l+lsSGf7h5nsjkPWBcF1Vne3107yx6VK1DQv5iKfLI3JxXwCVCqqPFHQzBybAMsYtM2E6yuREC9TehN8m/SRtIKSThLxjpgMPFlxhzKRM6gKagzCcCJDIT+vIlyBAHGvL63LSj6PC7uXD78fzOh3mHx1ITv4/QVjOsVK/nOqajL979GjheKgMWc6eZ3tuYmriaBdKj1Fn9G3aR/RA5NDrefX1isNV5Fjm3z0+vC1AOWvitT9Mcws/PKy2JgDBcL5WjkJtslJSFd26J0QYS6nS09PZyrMqcyipj7JiPnnGqciUpxhdsZRy7qqn0hPVMdqN9/tasd+d5d/ni31MwEwx1AGewAKe9awL4P8HNZ3VfEnzLm4ohlFp2Jh5ZMxDEkA252m2MvOT4GlbCFmy6ylR87df68M+L44cY+KW36WBJ3X+c5qGYgxgZXR77Q5PvsxgStUjEfQPaGUDX/ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: v2: - Remove unnecessary rcu_read_{lock|unlock} from cgroup_rstat_css_cpu_flush() in patch 3. It was found that blkcg_destroy_blkgs() may be called with all blkcg references gone. This may potentially cause user-after-free and so should be fixed. The last 2 patches are miscellaneous cleanups of commit 3b8cc6298724 ("blk-cgroup: Optimize blkcg_rstat_flush()"). Waiman Long (3): bdi, blk-cgroup: Fix potential UAF of blkcg blk-cgroup: Don't flush a blkg if destroyed blk-cgroup: Flush stats at blkgs destruction path block/blk-cgroup.c | 26 ++++++++++++++++++++++++++ include/linux/cgroup.h | 1 + kernel/cgroup/rstat.c | 18 ++++++++++++++++++ mm/backing-dev.c | 8 ++++++-- 4 files changed, 51 insertions(+), 2 deletions(-)