From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9730D31E84F; Wed, 14 Oct 2026 21:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792014866; cv=none; b=G/jFbkFG9Lt0CKFbmCLbHHhgksB059igYk9pIQ0msPMSrbgu6r11Vsw+pMAbXs5YkFS9f1eLpLgQY/Z9IKHEqcy+MmKd34w+uHbfKcJxzzun/pBKHkdISCVv9woZyAX4hCaP7hToGePBgMhl++Hv7oEeAiABw5dzuSyUcnvHdJI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792014866; c=relaxed/simple; bh=s6KomrzHrI2PEJkyWcVSNfoZb9g7ktlVe3DeMz3fBNo=; h=Date:To:From:Subject:Message-Id; b=o53NnQ+lywhVMcai+4TG8rFk2VsCgWKxTb+jcW5NsFIIh1rxel828q+kwJZS50P68QXjBAr5HNG2TwKHCgPnSz8GiAwQDXBSOyRilMVFyxU0LZs0wagt0cu/zdvqT1S9absR1/FnCVFuZjh8Cl9Taq0Z6mYoiMjEAZxcGlgWmr0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=e6cPVhzk; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="e6cPVhzk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F6FC1F000C4; Wed, 14 Oct 2026 21:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1792014865; bh=WMAjqhu3xICWwqjJ1EfNqwIQ1XQQwgqI06nYrM1fAB0=; h=Date:To:From:Subject; b=e6cPVhzkFKo4Sm61yYTEq3J1xiCBCSN97i2RUPWQuriB2aw/ksPZ9q9w7oye4afSp ghQjaDCM8kTqVSxOm9XkDMJVJUW/WnPA2aAKtJ9XWu+DVvQ95lAd7ymw3YPCPd7a7H bCNBHwiAuFD8n2OhQmAZEhs+2+YBvf8ededO6VtU= Date: Wed, 14 Oct 2026 14:54:24 -0700 To: mm-commits@vger.kernel.org,stable@vger.kernel.org,mark@fasheh.com,jlbec@evilplan.org,heming.zhao@suse.com,joseph.qi@linux.alibaba.com,akpm@linux-foundation.org From: Andrew Morton Subject: + ocfs2-dlm-hold-the-lookup-reference-across-convert-ast-enqueue.patch added to mm-nonmm-unstable branch Message-Id: <20261014215425.4F6FC1F000C4@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: ocfs2/dlm: hold the lookup reference across convert AST enqueue has been added to the -mm mm-nonmm-unstable branch. Its filename is ocfs2-dlm-hold-the-lookup-reference-across-convert-ast-enqueue.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/ocfs2-dlm-hold-the-lookup-reference-across-convert-ast-enqueue.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Joseph Qi Subject: ocfs2/dlm: hold the lookup reference across convert AST enqueue Date: Wed, 14 Oct 2026 19:23:21 +0800 dlm_convert_lock_handler() drops the reference it took when it found the lock on res->granted at its leave label, one statement before it calls dlm_queue_ast(). dlm_free_dead_locks() takes res->spinlock and drops the list and base references, so a peer death landing in that gap leaves the handler's own put as the one that frees the lock, and __dlm_queue_ast() then reads lock->lockres from freed memory. The handler is registered next to dlm_create_lock_handler(), so a convert message buffered on a dying peer's socket arrives on the same o2net receive work that o2net_disconnect_node() does not wait for. The two can interleave as follows, with the reference counts as they are before this fix: Socket data-ready Node-down thread Receive worker ----------------- ---------------- -------------- o2net_data_ready() select sc under callback read lock o2net_disconnect_node() queue shutdown begin flush; new color queue sc_rx_work in the new color release callback lock shutdown socket flush returns read buffered convert_lock dlm_convert_lock_handler() find lock on res->granted dlm_lock_get() refs = 3 lock res->spinlock __dlmconvert_master() call_ast = 1 unlock res->spinlock DLM node-down cleanup lock res->spinlock dlm_free_dead_locks() unlink lock put list ref refs = 2 put base ref refs = 1 unlock res->spinlock dlm_lock_put() refs = 0 free lock dlm_queue_ast() __dlm_queue_ast() read lock->lockres (use-after-free) __dlmconvert_master() only moves the lock between lists, so the count entering the gap is base, list and lookup. Drop the lookup reference after the AST is queued instead of before it and the race ends with the one __dlm_queue_ast() took, which dlm_flush_asts() releases later with ast_pending cleared and ast_list unlinked. No extra get is needed, and the normal case ends with the same count as before. dlmconvert_master() has the same shape but is only reached from dlmlock() for a lock this node owns, which dlm_free_dead_locks() never matches. Link: https://lore.kernel.org/20261014112321.2955584-1-joseph.qi@linux.alibaba.com Fixes: 2c5c54aca9d0 ("ocfs2/dlm: Add missing dlm_lock_put()s") Signed-off-by: Joseph Qi Signed-off-by: Andrew Morton Reviewed-by: Heming Zhao Cc: Mark Fasheh Cc: Joel Becker Cc: --- fs/ocfs2/dlm/dlmconvert.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/fs/ocfs2/dlm/dlmconvert.c~ocfs2-dlm-hold-the-lookup-reference-across-convert-ast-enqueue +++ a/fs/ocfs2/dlm/dlmconvert.c @@ -534,15 +534,19 @@ int dlm_convert_lock_handler(struct o2ne } leave: - if (lock) - dlm_lock_put(lock); - /* either queue the ast or release it, if reserved */ if (call_ast) dlm_queue_ast(dlm, lock); else if (ast_reserved) dlm_lockres_release_ast(dlm, res); + /* + * Keep the lock alive through AST enqueue: a concurrent + * dlm_free_dead_locks() drops the list and base references. + */ + if (lock) + dlm_lock_put(lock); + if (kick_thread) dlm_kick_thread(dlm, res); _ Patches currently in -mm which might be from joseph.qi@linux.alibaba.com are ocfs2-reserve-metadata-for-a-new-xattr-block-and-its-value-tree.patch ocfs2-reserve-value-tree-metadata-when-moving-an-xattr-into-the-inode.patch ocfs2-reserve-xattr-value-tree-metadata-only-once.patch ocfs2-deal-with-legacy-signed-dir-index-name-hash-values.patch ocfs2-use-the-stored-hash-when-checking-xattr-bucket-collision.patch ocfs2-deal-with-legacy-signed-xattr-name-hash-values.patch ocfs2-dlm-hold-the-lookup-reference-across-convert-ast-enqueue.patch