Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8925617rwb; Tue, 13 Dec 2022 12:17:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf4iectaXqzVy9gNYR9QAHLBaewqXvWaxlbz9O33V1nxMZ/fapHVs1yIdqM3DvtD2oDhAZjL X-Received: by 2002:aa7:d2d6:0:b0:46b:34a:3945 with SMTP id k22-20020aa7d2d6000000b0046b034a3945mr17641605edr.31.1670962641407; Tue, 13 Dec 2022 12:17:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670962641; cv=none; d=google.com; s=arc-20160816; b=PS0OuZF4BxnjDbGWwQBOXAR48QJ2fuonSy+M1QtDrrd1YmaNr/+xcdcu288cy6uCjM iFk+Z9mNNjGjOks8pROFDJQ9hzt5yyQ9DNvG+jVvECNAn4GqcFgS/x6dbxMrdV5/tE+6 qIX36PnOFJ7jaNTwO/6m91xxiQtmdVpdY5qFJ/1a4iAZQCA7uCc21H7kfWaFzbB3LqA8 DtGQ09FGITGoJT/m6+Qv2FnmbluQmRHm2rlLjXPrFaMoqyTPqapSMx81YwWJoJX/JCcf f2iQTtOgeJNBIZ3LHgd1S3N9Ea1HUXWA6LHnD2RAgI2ZJ3bjlWuDE2S383WmKwWPzq8G RO0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Q04pXB0nuaw4NyeT98qJ4CK1uIQuz5FaT/xQVCDx6WM=; b=GniaRx30iykXKkJbq+owKkkK/lStobKQ96Re0S+WkQ8HDlNdCR4N5zydtpT0tzQ5qf 93v6IVxSMv6Pl5bvWlM23Kc3V35wuJw/6C2GySRd5FECqn4Po95unZFB84EEja10TRNI OvsTWVkap1R3ZERfW5nMsWWLcMrZXNsNx9SxocasbFbLlFmCCU+IQ6T7ncap48IXHrIp dT7AFDOFdyQ1ZPTZevzxHplonwiq2Z3EuSiw3lTqaKS3M0rJg9rr+bUdIgNxklNr0dYp IEflDjMG/as+VyuD4C2BKEmJnZSLeguy6/w76X+/z5E72X7Gui85e42jj8EFPUkEkEc3 2YJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GYdQW+Yj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id er23-20020a056402449700b00471fbcb7004si32478edb.552.2022.12.13.12.17.01; Tue, 13 Dec 2022 12:17:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GYdQW+Yj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236638AbiLMTyv (ORCPT + 72 others); Tue, 13 Dec 2022 14:54:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236536AbiLMTys (ORCPT ); Tue, 13 Dec 2022 14:54:48 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68A322719 for ; Tue, 13 Dec 2022 11:54:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670961239; 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: in-reply-to:in-reply-to:references:references; bh=Q04pXB0nuaw4NyeT98qJ4CK1uIQuz5FaT/xQVCDx6WM=; b=GYdQW+YjY6dlAfqQTo6aClVMki1Rni+dh8KcuPslGDYbksz4FPWb43hMwf00nCnL5Akiki Id911GjjipQUqM0RngHD8DebeFVZBJekS4mQdO7QfAzaI8nWk5sbIEC1fiAdyXSWIv6gwI GINVTuzh5T9K7Lteq24RHqVYbhdYrLM= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-418-mkDnArbIMqqYOe1_pd7cpA-1; Tue, 13 Dec 2022 14:53:56 -0500 X-MC-Unique: mkDnArbIMqqYOe1_pd7cpA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6C4E1C0756D; Tue, 13 Dec 2022 19:53:55 +0000 (UTC) Received: from [10.22.32.205] (unknown [10.22.32.205]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3446492C14; Tue, 13 Dec 2022 19:53:54 +0000 (UTC) Message-ID: <34a8c4a7-a58d-63fc-4599-accf1cbb6aae@redhat.com> Date: Tue, 13 Dec 2022 14:53:52 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH-block v3 1/2] bdi, blk-cgroup: Fix potential UAF of blkcg Content-Language: en-US To: Tejun Heo Cc: Jens Axboe , Josef Bacik , Zefan Li , Johannes Weiner , Andrew Morton , cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, =?UTF-8?Q?Michal_Koutn=c3=bd?= , "Dennis Zhou (Facebook)" , Yi Zhang References: <20221213184446.50181-1-longman@redhat.com> <20221213184446.50181-2-longman@redhat.com> From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 On 12/13/22 14:29, Tejun Heo wrote: > On Tue, Dec 13, 2022 at 01:44:45PM -0500, Waiman Long wrote: >> Commit 59b57717fff8 ("blkcg: delay blkg destruction until after >> writeback has finished") delayed call to blkcg_destroy_blkgs() to >> cgwb_release_workfn(). However, it is done after a css_put() of blkcg >> which may be the final put that causes the blkcg to be freed as RCU >> read lock isn't held. >> >> Another place where blkcg_destroy_blkgs() can be called indirectly via >> blkcg_unpin_online() is from the offline_css() function called from >> css_killed_work_fn(). Over there, the potentially final css_put() call >> is issued after offline_css(). >> >> By adding a css_tryget() into blkcg_destroy_blkgs() and warning its >> failure, the following stack trace was produced in a test system on >> bootup. > This doesn't agree with the code anymore. Otherwise > > Acked-by: Tejun Heo Sorry, I overlooked the commit log in my update. I will update it if I need another version, or Jens can make the following edit: css_tryget() -> percpu_ref_is_zero(). Thanks, Longman