Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6397077rwi; Tue, 18 Oct 2022 11:51:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6gr54VLD5Sps2s6nv/KEvB1+Rh1WjxYkDZLoBl+zDtRc6hm3UPHa4s//fF8IDzplNEOs+r X-Received: by 2002:a17:906:4795:b0:787:434f:d761 with SMTP id cw21-20020a170906479500b00787434fd761mr3594647ejc.597.1666119069011; Tue, 18 Oct 2022 11:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666119069; cv=none; d=google.com; s=arc-20160816; b=AowKhPh/UNnDhCZy3wONPx/3JGED0l1eFwVxK6p3X7Zz0xa8sJGMq8P077sFMERUWu M8BKtV/N3hiPH6+5RLUGuMMwxv1LjWA/hGydM633cekuV/xKvuNo8dG13n5HcwQRfOzY 9Ojm32p733wfsJPNoHONUkstqq7PlYkeS3hnMHmyH4arXzPvFtkbFEvUK0NjIUKdvIzD fHKtBoJO5U+9izj1n+IpMZx++NfQv14wCXUVgwQl7W5eEPScjKTq0oayB+QbZiSpSv4o O2Hsh+1YlKYr5wEqL+fz1jCitSg8R37RsxL7zEquyIFAHw27cM1JcUg+MlnNxZKbRRPI FBPg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1SF9LNu8SQg1wb93/h/8qhWp5y7wXmi8PBkNV8b+3TY=; b=nMIph07HdXif2YemBYYPbeo/H8epuMFfKVauZ2vC519bsYt9a+mq2C8YreTM4PzhNU PHsPfqM4FW3fazdPsbhVJKHywvebEbOrRQ3m3IKi/TX45qtdI5s7gcWUngsvHai4xuUD dRf+dYx+vcgXKTthzvVEXlq8T5WYuSZnZmsvaIY8M4sN2aX/j1/RRHQjcUrDxKrVnO/p Rnn+wQDa9IE/xjZwICqgwCyY27lFd+TMqPX7hMT6j2X6ql3FO36ov2UWO6fYUUIqqNT4 SlOkxfV2wORJ9eKIy2mgFbf5L6ND4o2icogiCjloHR7jpwPHblzb6nfVlecaqRJFn3ay yWYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AWRBtFwi; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a39-20020a509eaa000000b0045919a1a07esi11041331edf.126.2022.10.18.11.50.41; Tue, 18 Oct 2022 11:51:08 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=AWRBtFwi; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbiJRSSJ (ORCPT + 99 others); Tue, 18 Oct 2022 14:18:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbiJRSSH (ORCPT ); Tue, 18 Oct 2022 14:18:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F4DF7E02C; Tue, 18 Oct 2022 11:18:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4E708B820EE; Tue, 18 Oct 2022 18:18:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99F01C433D7; Tue, 18 Oct 2022 18:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666117084; bh=mYGOGutZ4Vo9ucN0Lly1KgID1pVGbynxDNJ2SMsrc98=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AWRBtFwibDL7vA8S9et14vdl9j53tVVFgZ4kXgQbNRnI7sUffRFTXNaoMeslrqmed qkner6nvIaNLRwWzTeIH4MPGXkESN45eZCBWc7ioNMNkyXK/R1YgNBozf+vedJRTT0 GkS3AKvn18CwSWywZEXs2JkTuZ0RcpipBI72oijQ= Date: Tue, 18 Oct 2022 20:18:01 +0200 From: Greg KH To: Yu Kuai Cc: hch@lst.de, axboe@kernel.dk, willy@infradead.org, martin.petersen@oracle.com, kch@nvidia.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, "yukuai (C)" Subject: Re: [PATCH RFC 1/2] kobject: add return value for kobject_put() Message-ID: References: <20221018131432.434167-1-yukuai3@huawei.com> <20221018131432.434167-2-yukuai3@huawei.com> <2f962069-8fd9-08df-aa00-062b94569c36@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2f962069-8fd9-08df-aa00-062b94569c36@huaweicloud.com> X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Tue, Oct 18, 2022 at 09:12:08PM +0800, Yu Kuai wrote: > > > 在 2022/10/18 21:00, Greg KH 写道: > > On Tue, Oct 18, 2022 at 09:14:31PM +0800, Yu Kuai wrote: > > > The return value will be used in later patch to fix uaf for slave_dir > > > and bd_holder_dir in block layer. > > > > Then the user will be incorrect, this is not ok, you should never care > > if you are the last "put" on an object at all. Hint, what happens right > > after you call this and get the result? > > > > I tried to reset the pointer to NULL in patch 2 to prevent uaf. That is not ok, sorry. > And the > whole kobject_put() and pointer reset is protected by a mutex, the mutex > will be used on the reader side before kobject_get as well. So, in fact, > I'm protecting them by the mutex... Still not ok. You never know who else has a reference on a kobject, that's the point of reference counted objects. > I can bypass it by using another reference anyway. But let's see if > anyone has suggestions on the other patch. > > > sorry, but NAK. > > I know the best way is too refactor the lifecycle of the problematic > bd_holder_dir/slave_dir, however, I gave that up because this seems > quite complicated and influence is very huge... Please fix it up properly, core changes like this should not be needed. thanks, greg k-h