Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2603477rdb; Fri, 22 Sep 2023 03:42:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7OuFqaeOVR27o1v5S1kL3LLfOLYysQt7E9G5bdVVHFWANwF6tqwJzrUTdeIjpTjdCc1tU X-Received: by 2002:a05:6a00:851:b0:68a:5e5b:e450 with SMTP id q17-20020a056a00085100b0068a5e5be450mr8580958pfk.26.1695379351242; Fri, 22 Sep 2023 03:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695379351; cv=none; d=google.com; s=arc-20160816; b=n7XGJM+xtKmsno3HVRuFxrI6nTsbWvyKjG3mL5p9uKdmP5Ax9/g4P+g7q5Axv8vQEK 9uqwev5PiW3JEIt5JnUsXZ+pAW4PXFCBdiu7k4pZck1zZqIKXoVd70ptxrUkvirugg7A 3n+qRhe7t6In7AbqKpm6OFNgYAJhmCs9jVyoWZY0ByetCJjhUoubg/NyXF7h3L1nTOhi IcYDnqf8Te4QvwUjbqdC0Q1bE1rHSWLJziAg+/WPNvF9GnWvxFLAO3wEB6lcMjWM1XA7 hn36g2fNjSLlprqGWqqZVb+6KE3+zzkPP0enHnMuuHTT5dVVWZ936dRVl/FWbvUqGhAR dglA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5iS6CWzTyuOQJNRQKFDCK1OE1IeJNZtT4RnBAvbu1ew=; fh=sg46ptRS7UY+girVeM5S23oO/JN9eU9z6sQWI8OFApg=; b=l6FTmeK01etofJ4VKTBIb15MyWCIvPeyN72ZZQGdY1c0rKm6N0cJ4r9VLLOat6enGn AGqv5MlnaKNSRFD/nnK/Jc0eRS9xY2TKTYA/DrblssI51iFKlBlYye2f29+/O41MlbT1 zcswxVc9t2jgpT7iKgmdguTEN8/d16Yb/pJFvtz/G/+34p4dAP2yV0CsO/jiL9R8xZNp k4pr5iDXtgNjgEn+Y1snGLXicxN6VKWbslL6ZIfn/u7JQs8PuTzjmUvy3B0uzo3iy4Dk OIAU6asLO7zOp/g/dl19T4gcdglE7PioYpuXm1S+5DhmatvtOxWZgaPsK6xmyatbsOQb vwYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WsZ6FYLl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id f20-20020a637554000000b00565e2f4ad4esi3526715pgn.213.2023.09.22.03.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 03:42:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WsZ6FYLl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 78F9783348B1; Fri, 22 Sep 2023 02:26:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232517AbjIVJ0c (ORCPT + 99 others); Fri, 22 Sep 2023 05:26:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232332AbjIVJ0a (ORCPT ); Fri, 22 Sep 2023 05:26:30 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 107C3197; Fri, 22 Sep 2023 02:26:24 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EC56C433C7; Fri, 22 Sep 2023 09:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695374783; bh=CiplfnZWE0N96tT0Pqsa0UEZgTjTPzci1ZYFdLmLu34=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WsZ6FYLlqZJ0Wx9wj3oJWpkWzElbpXmmVhOT05kNCZRqqstYlKXj1B60PruPBESXx StdNK6XAXeDh7iImU1cuqe1zuYd7iJyCylBZTBVko2JYVYrFqUYtbbwzXrnTgSl82f aQzDl8nITFW6K8KN2zhfv0Kwnon8Nz3Cu/3WH2z8= Date: Fri, 22 Sep 2023 11:26:22 +0200 From: Greg KH To: Saranya Muruganandam Cc: Jens Axboe , Tejun Heo , Ming Lei , stable@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Zhang Wensheng , Zhong Jinghua , Hillf Danton , Yu Kuai , Dennis Zhou Subject: Re: [PATCH] block: fix use-after-free of q->q_usage_counter Message-ID: <2023092258-clothing-passerby-e0f2@gregkh> References: <20230921182012.3965572-1-saranyamohan@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230921182012.3965572-1-saranyamohan@google.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 02:26:31 -0700 (PDT) On Thu, Sep 21, 2023 at 11:20:12AM -0700, Saranya Muruganandam wrote: > From: Ming Lei > > commit d36a9ea5e7766961e753ee38d4c331bbe6ef659b upstream. > > For blk-mq, queue release handler is usually called after > blk_mq_freeze_queue_wait() returns. However, the > q_usage_counter->release() handler may not be run yet at that time, so > this can cause a use-after-free. > > Fix the issue by moving percpu_ref_exit() into blk_free_queue_rcu(). > Since ->release() is called with rcu read lock held, it is agreed that > the race should be covered in caller per discussion from the two links. > > Backport-notes: Not a clean cherry-pick since a lot has changed, > however essentially the same fix. > > Reported-by: Zhang Wensheng > Reported-by: Zhong Jinghua > Link: https://lore.kernel.org/linux-block/Y5prfOjyyjQKUrtH@T590/T/#u > Link: https://lore.kernel.org/lkml/Y4%2FmzMd4evRg9yDi@fedora/ > Cc: Hillf Danton > Cc: Yu Kuai > Cc: Dennis Zhou > Fixes: 2b0d3d3e4fcf ("percpu_ref: reduce memory footprint of percpu_ref in fast path") > Signed-off-by: Ming Lei > Link: https://lore.kernel.org/r/20221215021629.74870-1-ming.lei@redhat.com > Signed-off-by: Jens Axboe > Signed-off-by: Saranya Muruganandam > --- > block/blk-core.c | 2 -- > block/blk-sysfs.c | 2 ++ > 2 files changed, 2 insertions(+), 2 deletions(-) What stable kernel(s) are you expecting this backport to be applied to? thanks, greg "not a mind reader" k-h