Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp503080pxb; Mon, 25 Oct 2021 12:33:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKbDYaMbVi18eW2ULNy2uss/9Cwie6MmBW/NKQZzd2uB0byx4zWSvwkdQb2W+NNcdO8uKG X-Received: by 2002:a63:7881:: with SMTP id t123mr14908730pgc.150.1635190400532; Mon, 25 Oct 2021 12:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635190400; cv=none; d=google.com; s=arc-20160816; b=tdnq4lOhVMxCDDhSPyjjocbJ7/ZRGlmDeSvlyotVltFTFjBY2wOjt1rawQk8dmWojn lxnOD/ZEWlUyZzVIY2uPYhCvOjVT9QPuh7FRTFJmI3ytmIbECH0N+EMyZLElhJEzwTuu UYwmeNvzxnxe69oT/YjvNW6HNDZp65DC8MMFWDxVMbRo7etugfkmpsvMimSZN4L2Bqjp ZYDLhSKYvL8KFRYttwJzQnciu7U341CsrZJss/34mxJrDSI0SBrdMSUW/ZMvi8mqbuAG /G2/+iP2y1aKE4oNXLVZ8Ezh4XemdNQLGJnObd4TDiBvzqw37hS0O9AD8ikq+OEULiof 0AyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FBOPNZCCgl485CLadKlqAGuBijQCzR5CUhgNZyc8h3A=; b=d7zpjjlYc9mAOWHKPusoPJ2QdWnbrl3e2s7hYU3bxq49MCRpbyQ/+dBl9XSHv991AZ h1Ov1NxYXeySAwlFe+4Qs14dambJSj0Pl3fd90/0nh5erxd2rxk4LjoZWFf1rOlMUYpe 2FMWy1N2FcF+1ekTLgKQhrpZqitai9Gpl1twrbaydV4CdhZ2zJVfP/pJKis2A9n1tyX6 S+rUqEW4iVQ8oAWUA1Km0G2/JTMwEsI7oUbzCQRPV6jSYA0sMLGgsnmRigZhuXH/StOC bgH/xn4cqIXztsf1e2GNuk5mmbPId1N9D666t+oThW0SY5Grsdw8MdGjIP2NTvKoPw/9 Gs7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt24si13664870pjb.62.2021.10.25.12.32.49; Mon, 25 Oct 2021 12:33:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235970AbhJYTcs (ORCPT + 99 others); Mon, 25 Oct 2021 15:32:48 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58232 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235958AbhJYTar (ORCPT ); Mon, 25 Oct 2021 15:30:47 -0400 Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1002]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: krisman) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id A27451F430E8; Mon, 25 Oct 2021 20:28:22 +0100 (BST) From: Gabriel Krisman Bertazi To: amir73il@gmail.com, jack@suse.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com, Jan Kara Subject: [PATCH v9 04/31] fsnotify: Don't insert unmergeable events in hashtable Date: Mon, 25 Oct 2021 16:27:19 -0300 Message-Id: <20211025192746.66445-5-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211025192746.66445-1-krisman@collabora.com> References: <20211025192746.66445-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Some events, like the overflow event, are not mergeable, so they are not hashed. But, when failing inside fsnotify_add_event for lack of space, fsnotify_add_event() still calls the insert hook, which adds the overflow event to the merge list. Add a check to prevent any kind of unmergeable event to be inserted in the hashtable. Fixes: 94e00d28a680 ("fsnotify: use hash table for faster events merge") Reviewed-by: Amir Goldstein Reviewed-by: Jan Kara Signed-off-by: Gabriel Krisman Bertazi --- Changes since v2: - Do check for hashed events inside the insert hook (Amir) --- fs/notify/fanotify/fanotify.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 057abd2cf887..310246f8d3f1 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -702,6 +702,9 @@ static void fanotify_insert_event(struct fsnotify_group *group, assert_spin_locked(&group->notification_lock); + if (!fanotify_is_hashed_event(event->mask)) + return; + pr_debug("%s: group=%p event=%p bucket=%u\n", __func__, group, event, bucket); @@ -779,8 +782,7 @@ static int fanotify_handle_event(struct fsnotify_group *group, u32 mask, fsn_event = &event->fse; ret = fsnotify_add_event(group, fsn_event, fanotify_merge, - fanotify_is_hashed_event(mask) ? - fanotify_insert_event : NULL); + fanotify_insert_event); if (ret) { /* Permission events shouldn't be merged */ BUG_ON(ret == 1 && mask & FANOTIFY_PERM_EVENTS); -- 2.33.0