Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp207326pxt; Wed, 4 Aug 2021 09:07:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyV1z9d+ezVIW/JeZf/wahxm/4JwHZVxW//FUzk+WmU6ps7LWySsUMVkD+2osJHcl5s6Eqn X-Received: by 2002:a05:6402:30a2:: with SMTP id df2mr529538edb.363.1628093249084; Wed, 04 Aug 2021 09:07:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628093249; cv=none; d=google.com; s=arc-20160816; b=k4ql/gL040H6QxRpqow4CAZ2UsnTg7V2UhfCoxB6kYlhJzCDsRcrAokrRDTLJzKdvS JUR9XpZj9jzUpr7i0Rb5Dxfh3pZSCMJwjPvlbFly2jMCcKaKuuniUBaNSxjBdcS/8yDo 8mv8j2Z8nnBYupWPYSI8hSdD/HM51caJmmaQqAfRSpvykny0WlHkmooIhhHBtXFhRVB6 JWUAC00XsfPTNx7a2bmihFzXXIqokKN+nHA5rkp9mC/DI6K+hwK63cI/kq/ikaM+ltd+ 6wnhmY+9ChMcO+OF3PFLeQL7GEloRMi/5vIm3ulOy0ZHFkX6cww55davrTDAgngn4EVL TOrg== 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=llanoVI1PI8Q+VxWNnPiCRFNjHwSUshQZh6QJojUUQk=; b=yjgrXKm9Xo+qYoEX8abSyvOMBQ595S1mR/2Mxo3weOL7MOOOACbsR61bArO0seJG4W Dj1Mi7PJMUorumAqnGOa7X4TpyYEct4XKdlItIGi7bW4loqDNPUWgI8E+Ve6MlLQ8F4i v7R67fcREVb66mT0NMCzua+X1WTR/LppdjUeW/bC+Nqjay2ZxgmW4vFdvl7r4NrAUljr OZtbzfILPmDluTOcY0v3pETGF6ToPBHBlGUVJXppJAt4X2rlWFy32LCOzibMVDJS0mvV ulX+74HDoMS13OSY3i3WY9egRKqEvH3v/UTrxd1gsGWjgNWHxTnBlrx0H6FVBdayGEir +Zng== 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 u5si2403076eds.141.2021.08.04.09.07.01; Wed, 04 Aug 2021 09:07:29 -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 S231287AbhHDQGv (ORCPT + 99 others); Wed, 4 Aug 2021 12:06:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbhHDQGp (ORCPT ); Wed, 4 Aug 2021 12:06:45 -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 9EB71C0613D5; Wed, 4 Aug 2021 09:06:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 6344E1F415A2 From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com, Jan Kara Subject: [PATCH v5 01/23] fsnotify: Don't insert unmergeable events in hashtable Date: Wed, 4 Aug 2021 12:05:50 -0400 Message-Id: <20210804160612.3575505-2-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210804160612.3575505-1-krisman@collabora.com> References: <20210804160612.3575505-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.32.0