Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5060673pxb; Thu, 14 Oct 2021 18:18:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0/FsOweInMBUoOqRr891tUtixdfjan2Xqdu4VIyZOBVLQ/U4J1HHCuGQ7dBmPjoj5y2wb X-Received: by 2002:a17:902:c94e:b0:13f:1b02:e539 with SMTP id i14-20020a170902c94e00b0013f1b02e539mr8120411pla.72.1634260707023; Thu, 14 Oct 2021 18:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634260707; cv=none; d=google.com; s=arc-20160816; b=H+D8CKsfstEQGv2rAIy7ATTNpwV1ZLl4/EC9rH19viY2GWoUDuQV/qpS8p+8bVTTye mTMxTE+fCigqBji637akVSfTVnBAyg02+j6qpp0PKpSORcZXGD9fg+ITEBJFfMwI78Hy kRpjYs+02NHFzTf8ewwDbabVUaX7uMWx6bXn20pprXM7CtI9YWkyGq7iMAAPxO5WYl53 ye3pY8FI9w1e2pjkRQRDJo6fKXBG0c9qlXaj1GP7mgnTOcd6NsVGAwgjq5QsW8wjHN/I QPr3z+M13x6XdQ8+OruQUrfC46EzAtFQ7rt6POAhfdRMpYr/7hAYlarQTDXtsMQfTHyQ jRTA== 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=SlnW/WpDowDowO3A2UIfJnIyhuHO/F5dMcL0R3n64JQftf7+W7w2d3IQPwVdKNZukx QbtrLKzdyGEICeoazSZPkQlGrLBcuPBfhINXHdhA9w/yWusQw4aaKg/ldpyRAP7l8asA 0vPykhaGQko3OCAHftJNMbuZrrJpFHPiwqqOs4rAdFLJAVRG5T6WMJj4tszY/jfEoDus fZagTWXd9osg0dsUryBcFAlub94XAJUTpE4HJ0h31YpywrapnPMMp2aHdeZ6dNm1xoSd ERRCV+5FQk59Wz4xmyhCw8J5kY09XylQbk0jfE2sdhrvxybNAIr2ZuuifWDvyA1oilBr kbOA== 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 c24si5715060plo.107.2021.10.14.18.18.14; Thu, 14 Oct 2021 18:18:27 -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 S233383AbhJNVjg (ORCPT + 99 others); Thu, 14 Oct 2021 17:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233361AbhJNVjf (ORCPT ); Thu, 14 Oct 2021 17:39:35 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D80DAC061753; Thu, 14 Oct 2021 14:37:29 -0700 (PDT) Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1007]) (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 3B6611F44F72; Thu, 14 Oct 2021 22:37:27 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, repnop@google.com, Gabriel Krisman Bertazi , kernel@collabora.com, Jan Kara Subject: [PATCH v7 04/28] fsnotify: Don't insert unmergeable events in hashtable Date: Thu, 14 Oct 2021 18:36:22 -0300 Message-Id: <20211014213646.1139469-5-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211014213646.1139469-1-krisman@collabora.com> References: <20211014213646.1139469-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