Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3500442pxb; Mon, 18 Oct 2021 17:01:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFungVVw29/TtZm+KrMFCObPBnizlEM9rJlVO5xu4UwMV7z7+nib7PdF4XJtsI9l+a3jAj X-Received: by 2002:a17:906:134e:: with SMTP id x14mr32858943ejb.72.1634601694673; Mon, 18 Oct 2021 17:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634601694; cv=none; d=google.com; s=arc-20160816; b=EtfmmsjgO3aOIGmZDi3uOwDwn0FkBCf0RrWoJUOEIYnU6cdjFDEcroxL5QkQyd4+3e O3S3IoD1vPJw9BC4O5PFO7u9RH73XRJmZMe1JErXlga9+3rIrBcdEpdx9jCssaxJP3+r xR4/UAME7JadofLGodWrIZRZ1rHx01cuC0Liz22vKG9v8R1gyNAvUpH2gJxohJkecdMq kJLoMrxZXc7LNAevgSAZrT6hBnK8h/K3GmNAKcQYkFFjljSy5AcqYC12rRlKWG6btNRw f3pgPxenPUtepUdnyiiUN+Ppi3JW0r7SoEr0eiM9d6KIDHvAyLc3RFyIGS/Enitvt1OS 9h+A== 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=AgRWCz3vul/A16q33iM+D29r7oiZRfQuZ/lW4b9TeeOYIO3p4HXQGdkwh9qeZ85ZEy vLjUPQ/3aNcB0tVbkqELDbIX6BBCTTVNMyh7VQKnGlqXMLh3P1RQjZhdLCsytDza2RII vo4zkw/mbCf4gm9uNqC6yVayRjdf0URA1Ps+2Ie9Idl9QBUEPptvqY+2NQxVtNSeN+dQ AGoEYEgmCZ7V5tFYHPbSgT4Ig8qS0At+grOuyRzOZozr+vmbKHp2Q5Tauapwgy13HD1i GtNlqcl6/tLtnDoE2uNKdsJOafbHfmMQ2daPaif2mieJlo/B7yG/vo1nHy9Ov41fkxJ8 fbgw== 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 11si20698681edx.477.2021.10.18.17.01.11; Mon, 18 Oct 2021 17:01:34 -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 S233452AbhJSADD (ORCPT + 99 others); Mon, 18 Oct 2021 20:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbhJSADC (ORCPT ); Mon, 18 Oct 2021 20:03:02 -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 0EDBDC06161C; Mon, 18 Oct 2021 17:00:51 -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 8704A1F41A9C; Tue, 19 Oct 2021 01:00:49 +0100 (BST) 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 v8 04/32] fsnotify: Don't insert unmergeable events in hashtable Date: Mon, 18 Oct 2021 20:59:47 -0300 Message-Id: <20211019000015.1666608-5-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211019000015.1666608-1-krisman@collabora.com> References: <20211019000015.1666608-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