From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f193.google.com ([209.85.215.193]:40373 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726499AbeKUDPP (ORCPT ); Tue, 20 Nov 2018 22:15:15 -0500 Date: Tue, 20 Nov 2018 08:45:09 -0800 From: Guenter Roeck To: Greg Kroah-Hartman Cc: Ming Lei , Jens Axboe , linux-block@vger.kernel.org, "jianchao.wang" , stable@vger.kernel.org Subject: Re: [PATCH 4.21 V3] blk-mq: not embed .mq_kobj and ctx->kobj into queue instance Message-ID: <20181120164509.GA32433@roeck-us.net> References: <20181120014435.3339-1-ming.lei@redhat.com> <20181120075150.GF15276@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181120075150.GF15276@kroah.com> Sender: stable-owner@vger.kernel.org List-ID: On Tue, Nov 20, 2018 at 08:51:50AM +0100, Greg Kroah-Hartman wrote: > On Tue, Nov 20, 2018 at 09:44:35AM +0800, Ming Lei wrote: > > Even though .mq_kobj, ctx->kobj and q->kobj share same lifetime > > from block layer's view, actually they don't because userspace may > > grab one kobject anytime via sysfs. > > > > This patch fixes the issue by the following approach: > > > > 1) introduce 'struct blk_mq_ctxs' for holding .mq_kobj and managing > > all ctxs > > > > 2) free all allocated ctxs and the 'blk_mq_ctxs' instance in release > > handler of .mq_kobj > > > > 3) grab one ref of .mq_kobj before initializing each ctx->kobj, so that > > .mq_kobj is always released after all ctxs are freed. > > > > This patch fixes kernel panic issue during booting when DEBUG_KOBJECT_RELEASE > > is enabled. > > > > Reported-by: Guenter Roeck > > Cc: "jianchao.wang" > > Cc: Guenter Roeck > > Cc: Greg Kroah-Hartman > > Cc: stable@vger.kernel.org > > Signed-off-by: Ming Lei > > --- > > V3: > > - keep to allocate q->queue_ctx via percpu allocator, so one extra > > pointer reference can be saved for getting ctx > > V2: > > - allocate 'blk_mq_ctx' inside blk_mq_init_allocated_queue() > > - allocate q->mq_kobj directly > > Not tested, but seems sane from a kobject point-of-view: > > Reviewed-by: Greg Kroah-Hartman Tested-by: Guenter Roeck with v4.14.y and v4.19.y. The patch is marked for v4.21. I would kindly suggest to not wait for v4.21 but apply it to v4.20. This would let us enable DEBUG_KOBJECT_RELEASE with syzbot on upstream and stable kernels. Greg, applying the patch to v4.14.y will require a backport due to a minor context conflict. I'll send that to you after the patch is available in mainline. Thanks, Guenter