Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1044395pxv; Thu, 1 Jul 2021 15:52:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPS2iMyxOdcWcgddxrvgrWrwU0BF3zZckmX0j5qFbY0cxJai/jV8MriPNJVMi4iNl96Ekn X-Received: by 2002:a05:6402:1c8e:: with SMTP id cy14mr2810090edb.271.1625179921077; Thu, 01 Jul 2021 15:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625179921; cv=none; d=google.com; s=arc-20160816; b=wQiDguudxt86WgZvVdSUxTF2AXHQsLZdIGTgWGd/mnWr6Fg7y23t7Lwy5gbSKqJVbO IhZuXi3sVBRWrPB5q/d6SfKGo/elS78G+R1+VF6U3zeRj+90Cy6yxB0e93hXiCFnDVeA kxvgZ/t60umaKzPEGa/iZzHAeJZCOmq34Jp9tF8VRR3zk0ccT+bt+cSv/sFWZMQh/B0T Z7ZqWZWXRZ1i8shXiWatpXUYzcPicBGAR+7QiFUIM4TMh0+nX8ofWOSojnFXai03DoP7 Iy8bjGl/XktIgzBKd2FpKZi7sOvHLbmY6UnYGLK9gEC7EmrqTyNbFeTvkyhK1AH/ovOP 7QuA== 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; bh=KfsC1NU2036YELOEEz9l1d7vjRPdhLZ2pXf4rmwWMGc=; b=GH9RScKAUHgY7BGwWmXuK0rpxSLZmXP8e1LZ5jqGprSAf4SI7QFZ7r+07LTE/1dERY py1rpv1vimhPNOepdqclv5F8lrm7htCsOsUUQQhq1EBnvXeawzA4cuWzAT4An79GeNe2 z63BJzfZa0Cn0fGCDmppLQ+w0ICJM0KNdnXWdzRsv0z1NgxOaMS7FgDlVdXyGuKqcUcI z0cx/J3Zzs6eS4xN8hart2s1YWhHFHBSOZW8NsOHu7VwxBcP+XJ8dtgr9GIiJ/mi8ybE csFmX9E0mcGthD0MLBtiTGksRtCuEuILf/idvlTJ1Mr2D2gflN6dSVZG9SV7bYCRIpgi 3qZA== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z62si1249023ede.71.2021.07.01.15.51.37; Thu, 01 Jul 2021 15:52:01 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233852AbhGAWuy (ORCPT + 99 others); Thu, 1 Jul 2021 18:50:54 -0400 Received: from mail-pj1-f43.google.com ([209.85.216.43]:53165 "EHLO mail-pj1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232807AbhGAWux (ORCPT ); Thu, 1 Jul 2021 18:50:53 -0400 Received: by mail-pj1-f43.google.com with SMTP id kt19so5247368pjb.2; Thu, 01 Jul 2021 15:48:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KfsC1NU2036YELOEEz9l1d7vjRPdhLZ2pXf4rmwWMGc=; b=ju34z1ax1MVfsx1dBGDdlPHjbntOmpU4VJpHBh3qT8F/79BzhbyBJqb9o66eNzGqLp C4lzc2RLC4ufOv/IxN4C8JFlYoSHPv0+0fwBBLJXV04KLQSsmigMgM0xZKGGufxeAp0S zAbsneS58b+eMSfas7iaT7ajxOAQshvGTM+9PZEIpnxRr+/RglH6aOUUK8SYzRUJ4BiH Q21V4+9xwohJYQy7yuhx5YfGFFrnUEaSSczDA+SbIBz0B9jGoH1f8N0epbvOL+FbsgJd DMR62ls2hR6FsFxme6m1vGwH8gnKMQSJ7yJzSByliR2IrSYmfpy40h7oSXAN0ZoZKvzu EZKQ== X-Gm-Message-State: AOAM533CLOtOThIfc+LlLA8sTlA5TweVg1N8g81eqD/4V1AyYYPsqhi7 Uj8CX7A5KrS0ihpS0qGrd4U= X-Received: by 2002:a17:902:c245:b029:128:e566:111d with SMTP id 5-20020a170902c245b0290128e566111dmr1810667plg.77.1625179701819; Thu, 01 Jul 2021 15:48:21 -0700 (PDT) Received: from garbanzo ([191.96.121.144]) by smtp.gmail.com with ESMTPSA id j205sm1136597pfd.4.2021.07.01.15.48.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jul 2021 15:48:20 -0700 (PDT) Date: Thu, 1 Jul 2021 15:48:16 -0700 From: Luis Chamberlain To: Greg KH , Tejun Heo Cc: 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: <20210701224816.pkzeyo4uqu3kbqdo@garbanzo> References: <20210623215007.862787-1-mcgrof@kernel.org> <20210625215558.xn4a24ts26bdyfzo@garbanzo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210625215558.xn4a24ts26bdyfzo@garbanzo> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Luis