From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A238C4332F for ; Tue, 13 Dec 2022 19:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236645AbiLMTyx (ORCPT ); Tue, 13 Dec 2022 14:54:53 -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 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