Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5401981pxv; Wed, 21 Jul 2021 04:42:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwr1MU+YaFjy0keciquCqDOEDn7e/+0scxqvCQNgu60rbEtVhXdLWdOKadytiK9obx01FGC X-Received: by 2002:a05:6638:192:: with SMTP id a18mr30570393jaq.47.1626867726410; Wed, 21 Jul 2021 04:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626867726; cv=none; d=google.com; s=arc-20160816; b=gy3EPitbOF2HypYpJJBGIin1ZTpU51XjbPnH81Yb6GP/RmHKQiZlU3mCd2Xxeh8JBI egCZc5Zq+JkJOjQKT/l453Gpcr3j7SGglLBIVIEvr0g/xNyshyifNtaShgH039ewAIjH ne84208EaNh5YMn37MJ2QFEV5RO7nzPqvB64Y5M58jRUKjd/K0Vg0HAqa7s04dtqTIOE sEKn9XhewraZUdlBIXYLFVOx60w0LG7HyCF1CxNmMHMBns/AsYhWWW8gIYTd3K7KMN4f qxf3l5Zh7KNUGnFiiuj1GUKO6fMtlZeXStOT5R6BrELFEm6HQ94v3U6xeptzeLIAm3rO nJcA== 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=/eWsRGllUzLqAn3QbQZfnxuKMNEbqxDRU/GGjKw1hZ4=; b=dGc0zXW3GDnlqQ0s2YDdebjPdln2MggMEmETc4f4VaKA//TS3SEPOs0OzymOGkogLg RIt9VBZxGESX5DWt4bgj1OQGbFyMLWqyKGNpctIDZn6BDH2AuBMh59BrN7RDxdf2/7IB Icoo5HakdLdfbGleg194IbCV6cYt9YHczaqyeok52vJdDAbufS0PR+zbCL7pd1iu5osU dxvDKuIWS8ckfbEMzuGhtGnFHQTvCPlgAWg4imLXykgecQL5iMTssORoghI232HwT7/O PomdcH1Wx0QbTSBjnDONyYRBXYUrLeLH0qjctZ0i0mLj6Qzs6RFbwsa4lxnV8vjLfpIj g1gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1UZh1i8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q14si26458106ils.147.2021.07.21.04.41.54; Wed, 21 Jul 2021 04:42:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1UZh1i8U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S238262AbhGULA0 (ORCPT + 99 others); Wed, 21 Jul 2021 07:00:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:46880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239453AbhGUKtz (ORCPT ); Wed, 21 Jul 2021 06:49:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16F6E60FED; Wed, 21 Jul 2021 11:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626867031; bh=LdfjugS48dS+nRJKJaM5T5js8ElP2wpZ0Stt/chye58=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=1UZh1i8UWofDwaM8TulKCVQinJZZPH2JCRJw7prirEbtDhmt+UX4vUqTQjxk1mxDH 2Wmlh7vH6oAY6HVi5AnY22IvbCwImKWt90XZAbC7j1v4KuJCx4DSp6WQ1sAPUxmiHK GRasP1jL4IJayZj/eLNd4lpNLJWCpxpNx8dpSsDo= Date: Wed, 21 Jul 2021 13:30:29 +0200 From: Greg KH To: Luis Chamberlain Cc: Tejun Heo , rafael@kernel.org, davem@davemloft.net, kuba@kernel.org, ast@kernel.org, andriin@fb.com, daniel@iogearbox.net, atenart@kernel.org, alobakin@pm.me, weiwan@google.com, ap420073@gmail.com, jeyu@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, minchan@kernel.org, axboe@kernel.dk, mbenes@suse.com, jpoimboe@redhat.com, tglx@linutronix.de, keescook@chromium.org, jikos@kernel.org, rostedt@goodmis.org, peterz@infradead.org, linux-block@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] sysfs: fix kobject refcount to address races with kobject removal Message-ID: References: <20210623215007.862787-1-mcgrof@kernel.org> <20210625215558.xn4a24ts26bdyfzo@garbanzo> <20210701224816.pkzeyo4uqu3kbqdo@garbanzo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210701224816.pkzeyo4uqu3kbqdo@garbanzo> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 01, 2021 at 03:48:16PM -0700, Luis Chamberlain wrote: > On Fri, Jun 25, 2021 at 02:56:03PM -0700, Luis Chamberlain wrote: > > On Thu, Jun 24, 2021 at 01:09:03PM +0200, Greg KH wrote: > > > thanks for making this change and sticking with it! > > > > > > Oh, and with this change, does your modprobe/rmmod crazy test now work? > > > > It does but I wrote a test_syfs driver and I believe I see an issue with > > this. I'll debug a bit more and see what it was, and I'll then also use > > the driver to demo the issue more clearly, and then verification can be > > an easy selftest test. > > OK my conclusion based on a new selftest driver I wrote is we can drop > this patch safely. The selftest will cover this corner case well now. > > In short: the kernfs active reference will ensure the store operation > still exists. The kernfs mutex is not enough, but if the driver removes > the operation prior to getting the active reference, the write will just > fail. The deferencing inside of the sysfs operation is abstract to > kernfs, and while kernfs can't do anything to prevent a driver from > doing something stupid, it at least can ensure an open file ensure the > op is not removed until the operation completes. Ok, so all is good? Then why is your zram test code blowing up so badly? Where is the reference counting going wrong? thanks, greg k-h