Message ID | 20231221150444.1e47a0377f80.If7e8ba721ba2956f12c6e8405e7d61e154aa7ae7@changeid |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-8549-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp444063dyi; Thu, 21 Dec 2023 06:23:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFO3329NBdhuUtT0sWS7xC0bOGCBQffN3RfTzU5c/g+zoIbtAOr3WkNj3bHS1K+Q6RhhOVI X-Received: by 2002:a17:90a:9406:b0:280:c98f:2092 with SMTP id r6-20020a17090a940600b00280c98f2092mr8842477pjo.33.1703168605139; Thu, 21 Dec 2023 06:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703168605; cv=none; d=google.com; s=arc-20160816; b=H2VYvwoo/90X8oDnDIyQN0cgqe4h+YU0daYWQCclBfcDe+Oez9D4V+HfkTM7o8GdEl cAAnVuWCBW46ng6otrGOd/xI3T0d9vcu/1JGffENDd5uEa5mTh7ziMV9Fs82vcPoqrSZ OiukCgVe07Vvb147Z6ZWWP160E7MOoL0I6ShT6WE2MgRzXhl2r6ep5ELqiuNN9fylZC3 13+JIK0qHb6EhuCP0grJORZ4Gh8U7d75KzA9SRgsiwf1m65J1ArnfyXeM4q3UMdpSZ69 WtSL2Olp8kVud4Zw+dIq3vBescSbV2KJzReuPjKDqIZR7dk6c8PBb8SmlczaLQhCe8Wv Fegg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=eIaYI0ct3kzN+uIpwX8VkuvulkFIVBzGuvKucGJ7sP4=; fh=kv6lwvgFPQvTyO5DLJ36U+RDFfFxbw4DsctUkaN8k8A=; b=UQg09UqE5CnDq1edKtuZ23i5Q4Am3zKXYJnLwLogfO/Uhg7lGu/CJcSTXV8TYC9nLv cEwHySEi0ogD8blKD0vAla1fQAGw2mVYIcu5ZMNgEekuN+utgNVUkJe5ZizIzRjzZuJT 8unZqpv0s5K4XvT+H3v0wjq5rqe1HjH4jbIu8x8n0G2arD/yzdVvE1zfJAw2B3hcj+3u OxkBxrOCaETCRMfoAxK68eh5UaEAzIByBfNlrBKlhqLyuAIUbbA98MQCxBAiODt5VdOn VkjxMFq7fyPTNXdKtZEf3X0bEINzvnyacethvz+F2dSh2y800DydCSrLTViARFe9UoqX rl1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b="uC6jk/c5"; spf=pass (google.com: domain of linux-kernel+bounces-8549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8549-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e5-20020a17090ab38500b0028bd42e0ca5si1576421pjr.176.2023.12.21.06.23.24 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 06:23:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b="uC6jk/c5"; spf=pass (google.com: domain of linux-kernel+bounces-8549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8549-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4DECBB2930B for <ouuuleilei@gmail.com>; Thu, 21 Dec 2023 14:07:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14E43539E3; Thu, 21 Dec 2023 14:05:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="uC6jk/c5" X-Original-To: linux-kernel@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B332360A1 for <linux-kernel@vger.kernel.org>; Thu, 21 Dec 2023 14:05:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=eIaYI0ct3kzN+uIpwX8VkuvulkFIVBzGuvKucGJ7sP4=; t=1703167522; x=1704377122; b=uC6jk/c5VTe/lfpbjdwn22RBn3Gm5TRTVHsQLt05glL6bWWIcFClVPkLM/CoxhJ3tXFee0olggL mIuVKxLoFRHtO6Poxwf0nG4tJ2W73a0kl+zsAWlHnpejdZAcL7V4JA0AiS66o+ovjlMJ74PqUAk9w nGiST2/FXLC7qGLyyz0vcNWfF6I0nilGz2B4mI7GtPUMDe5zZfnyaS6brCS+LQgQF88r8WmrM8X5j NU/EV1QkApn7Y7IiGWNhsYMZaqB9GZgNsBTDpx3dq4hV1uaypZd6rjIkAGjVfa4ac4+vnY1usGmRU b7eyjjFAy/Fhlz6h6IZPDpn5JDEBIJA0FBcA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from <johannes@sipsolutions.net>) id 1rGJfk-00000002t3A-20p8; Thu, 21 Dec 2023 15:05:12 +0100 From: Johannes Berg <johannes@sipsolutions.net> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Johannes Berg <johannes.berg@intel.com>, Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Subject: [PATCH] debugfs: initialize cancellations earlier Date: Thu, 21 Dec 2023 15:04:45 +0100 Message-ID: <20231221150444.1e47a0377f80.If7e8ba721ba2956f12c6e8405e7d61e154aa7ae7@changeid> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785901722930986209 X-GMAIL-MSGID: 1785901722930986209 |
Series |
debugfs: initialize cancellations earlier
|
|
Commit Message
Johannes Berg
Dec. 21, 2023, 2:04 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com> Tetsuo Handa pointed out that in the (now reverted) lockdep commit I initialized the data too late. The same is true for the cancellation data, it must be initialized before the cmpxchg(), otherwise it may be done twice and possibly even overwriting data in there already when there's a race. Fix that, which also requires destroying the mutex in case we lost the race. Fixes: 8c88a474357e ("debugfs: add API to allow debugfs operations cancellation") Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Johannes Berg <johannes.berg@intel.com> --- fs/debugfs/file.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On Thu, Dec 21, 2023 at 03:04:45PM +0100, Johannes Berg wrote: > From: Johannes Berg <johannes.berg@intel.com> > > Tetsuo Handa pointed out that in the (now reverted) > lockdep commit I initialized the data too late. As the patch isn't in any tree, what is this against? confused, greg k-h
On Thu, 2023-12-21 at 18:05 +0100, Greg Kroah-Hartman wrote: > On Thu, Dec 21, 2023 at 03:04:45PM +0100, Johannes Berg wrote: > > From: Johannes Berg <johannes.berg@intel.com> > > > > Tetsuo Handa pointed out that in the (now reverted) > > lockdep commit I initialized the data too late. > > As the patch isn't in any tree, what is this against? Hm? You mean the lockdep patch? It's not relevant, but I then continued and wrote: > > The same is true for the cancellation data, [...] and then the patch goes and changes the cancellation data initialization? Or do you mean the patch mentioned in the fixes? > > Fixes: 8c88a474357e ("debugfs: add API to allow debugfs operations cancellation") That *is* in Linus's tree, as of -rc4. Not sure I understand the question. johannes
On Thu, Dec 21, 2023 at 06:10:17PM +0100, Johannes Berg wrote: > On Thu, 2023-12-21 at 18:05 +0100, Greg Kroah-Hartman wrote: > > On Thu, Dec 21, 2023 at 03:04:45PM +0100, Johannes Berg wrote: > > > From: Johannes Berg <johannes.berg@intel.com> > > > > > > Tetsuo Handa pointed out that in the (now reverted) > > > lockdep commit I initialized the data too late. > > > > As the patch isn't in any tree, what is this against? > > Hm? You mean the lockdep patch? It's not relevant, but I then > continued and wrote: > > > > The same is true for the cancellation data, [...] > > and then the patch goes and changes the cancellation data > initialization? > > Or do you mean the patch mentioned in the fixes? > > > > Fixes: 8c88a474357e ("debugfs: add API to allow debugfs operations cancellation") > > That *is* in Linus's tree, as of -rc4. > > Not sure I understand the question. But this doesn't apply against Linus's tree, or my driver-core-next branch now, where should it go? still confused, greg k-h
On Thu, 2023-12-21 at 18:17 +0100, Greg Kroah-Hartman wrote: > > But this doesn't apply against Linus's tree, Hmm. It does for me? $ git checkout linux/master ... $ curl -s https://lore.kernel.org/lkml/20231221150444.1e47a0377f80.If7e8ba721ba2956f12c6e8405e7d61e154aa7ae7@changeid/raw | git am - Applying: debugfs: initialize cancellations earlier $ > or my driver-core-next branch now, Right, it doesn't apply there, that was branched out from v6.7-rc3. > where should it go? I think/hope to 6.7 still, since it fixes something that only got there. Looks like you routed that other debugfs patch (the lockdep revert I was talking about) through char-misc? johannes
On Thu, Dec 21, 2023 at 07:55:13PM +0100, Johannes Berg wrote: > On Thu, 2023-12-21 at 18:17 +0100, Greg Kroah-Hartman wrote: > > > > But this doesn't apply against Linus's tree, > > Hmm. It does for me? > > $ git checkout linux/master > ... > $ curl -s https://lore.kernel.org/lkml/20231221150444.1e47a0377f80.If7e8ba721ba2956f12c6e8405e7d61e154aa7ae7@changeid/raw | git am - > Applying: debugfs: initialize cancellations earlier > $ > > > or my driver-core-next branch now, > > Right, it doesn't apply there, that was branched out from v6.7-rc3. Ah, yes. > > where should it go? > > I think/hope to 6.7 still, since it fixes something that only got there. > > Looks like you routed that other debugfs patch (the lockdep revert I was > talking about) through char-misc? I did, sorry for the confusion, too many branches/trees... I'll queue this up in the morning, thanks. greg k-h
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 5063434be0fc..6d7c1a49581f 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -104,12 +104,14 @@ int debugfs_file_get(struct dentry *dentry) ~DEBUGFS_FSDATA_IS_REAL_FOPS_BIT); refcount_set(&fsd->active_users, 1); init_completion(&fsd->active_users_drained); + INIT_LIST_HEAD(&fsd->cancellations); + mutex_init(&fsd->cancellations_mtx); + if (cmpxchg(&dentry->d_fsdata, d_fsd, fsd) != d_fsd) { + mutex_destroy(&fsd->cancellations_mtx); kfree(fsd); fsd = READ_ONCE(dentry->d_fsdata); } - INIT_LIST_HEAD(&fsd->cancellations); - mutex_init(&fsd->cancellations_mtx); } /*