Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795037735; b=VHcFr3T/r+dpf9kq6fEd3FeKoZvin0+ouAS3TUiw2+wRMZpF0nGHRsw9ZacIajh0SMeF uth+c7mYGwRKX1FQDKIs5rz+/JFW2Ghs4xQSIMiXORWgUb54f9vhUkY65eBYb8y6R4oe/ 5/UoNa4l0YjmNBbazWuNrZxrn5aY6cxoMVBvcffIHDa1lNM0EGxcCpIEQs7tMYufP+MU1 P3OJ7LlWz8fRAMyHns/pawhJXqCSvbwzcpfml5rVQJnjBaFS5j/jvFAGzkvKqGJIkuZSR 0Dge5reS2ws68JgO9WoIq8rVbFWtLA6VpG4TTo5Q+pM6swg4iXcJZ6vVPBg84k6MAcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795037735; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=d5L6c7PrqIq55wrmI8QHU0mB0qxvQuAPZOfjgBRuPB8=; b=mwHhresxY7ph9pKncIz0jF6i4MpMnmReXQ/Ge3VPDwY3k9N1GmJh1yI5mpoKBs1wiLbr zPJMUSJlSiJtV7wqT7TVvdPyWGM45EhMpmmZOwd0Z5ATn95voBS9QO3zMe22+W4n4Xg7R fnS3ocn2M+/87pPWrHw5f8jHFsczdAFiqUfU38CQbaCSGDhcEgH90AaWcyxlfIvu/aMPM MWktQz8DU+km3ySx2gxWm21rR8vh5qAgicHcgkA/ubryda0YGu2gDHB7SqsC95kAotofX 5Z8Yjtbkcb82alHDWH70MTN6bFAE6f6VUtoouDQTxzkq8CSYlqlE1bqb2trYDYzyXxw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=1EsoxHem; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9C2A606A325; Wed, 18 Nov 2026 21:35:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=1EsoxHem Received: by smtp.kernel.org (Postfix) with ESMTPSA id 213661F000C4; Wed, 18 Nov 2026 21:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795037735; bh=d5L6c7PrqIq55wrmI8QHU0mB0qxvQuAPZOfjgBRuPB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1EsoxHemZxo/6Jb4/EVKoi4k+rQaUA+c910mqtTxXkF7QnbokCxO+FOStzbOVwY+G PqdZ3+o8F3WeTXZL8B5DPoQQHwVoswERog6Wfs2k+zKxB2pWUkMfjQGUbsmHJvg2uU fXqX9onnLQNPR9SiwFHadGCQdzc0nwiNqd3IwTvA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Amir Goldstein , Hungyu Lin , Jan Kara , Sasha Levin Subject: [PATCH 6.6 1500/3318] inotify: do not coalesce rename events Date: Wed, 18 Nov 2026 15:35:22 +0100 Message-ID: <20261118150405.916162655@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hungyu Lin [ Upstream commit 581230d2ec3c0380917d1255792508851e7c4627 ] inotify compares the mask, watch descriptor and name when coalescing adjacent unread events, but ignores their rename cookies. Distinct IN_MOVED_FROM events can therefore be coalesced, losing the cookie needed to match a later IN_MOVED_TO event. For example, watch two directories with IN_MOVE. Move an entry from the first directory into an unwatched directory, recreate it under the same name, then move it from the first directory into the second watched directory before reading the events. The second IN_MOVED_FROM is merged with the first, while the IN_MOVED_TO retains the second rename's cookie. Userspace can no longer pair the second rename's events. The original inotify implementation compared cookies before coalescing. The fsnotify conversion lost this comparison. Do not coalesce IN_MOVED_FROM or IN_MOVED_TO events, which carry the identity of their respective renames. Leave coalescing of other event types unchanged. Fixes: 63c882a05416 ("inotify: reimplement inotify using fsnotify") Cc: stable@vger.kernel.org Suggested-by: Amir Goldstein Signed-off-by: Hungyu Lin Reviewed-by: Amir Goldstein Link: https://patch.msgid.link/20261027192027.8617-1-dennylin0707@gmail.com Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/notify/inotify/inotify_fsnotify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c index 993375f0db673..ff0af29745a8c 100644 --- a/fs/notify/inotify/inotify_fsnotify.c +++ b/fs/notify/inotify/inotify_fsnotify.c @@ -36,7 +36,7 @@ static bool event_compare(struct fsnotify_event *old_fsn, old = INOTIFY_E(old_fsn); new = INOTIFY_E(new_fsn); - if (old->mask & FS_IN_IGNORED) + if (old->mask & (FS_IN_IGNORED | FS_MOVE)) return false; if ((old->mask == new->mask) && (old->wd == new->wd) && -- 2.53.0