Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp208454pxt; Wed, 4 Aug 2021 09:08:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXlwHZPJxmwPdrXU5LCWW1TKCHWUAKJCcVJi1+dagZF0Nl8ALr4zNEpFSAszL8hhQfuUw9 X-Received: by 2002:a02:5bc5:: with SMTP id g188mr219132jab.136.1628093327478; Wed, 04 Aug 2021 09:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628093327; cv=none; d=google.com; s=arc-20160816; b=mddPKq41eXMwYfmrA2JQCS8G1glCNCPknuiSRvKZuFu94LrEaIsEmgWyiSmHwkBat5 9zQ049RlG+imX+EfWslKdl5kJNKG65dOmXZwfUg/1rknVkjZeYvbdTgwvKPpGIpBxN4o O3K+FgP0iLiEOSTjqACq2XtGxGs/c24JfQhh9s0VqmrUJbLbYpQb7xVkioIA3PfoTKIW 6oOlrVMabWePvsAGx95SJ0msQKQs6z2hxeZ//VCq9yDMarCPJna/FN/Th+gElLNxCIxJ 8FJIyz3+ZP8gkAeeutS+ldHZxwM0H5PyGDm+CsytgJjZaeQEiKdTAxUDGeGtZE7MeMe2 CifA== 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=mhExO0xAU0EPr5BZpbBEcz2P2b/DdeZNMwB6CeY03pE=; b=L178hbkB0Ob2GbmT63hwmn3IYv5C6JAy+DHJzs7VVzNq99PU74zivwvC8gNHxLROC0 xt7ZFPat7AoqDsC/rfKtA2LGhj3zooNDgDsH0FQC+R16OIBuClpgM3aehzamiPSewJm2 LGQn2ZIvr37oQtLEg5dqZ+dKdy349rsMT0mtcQrQDpZd8NQDzo0Dl02ULGpw7QWPyjCO uppbxJzOXkXgckY72czLkVzR3pR5NKZbJKIMvvImleQTf5RzuFeQs27Nvamkal/deEYu 0zjws6hTIkJmBSzwS9wHy6Sp5i3Txcz9ozfDLrlp+pRiIzOoDaqoRLox1Mom+6Qz4CLw kAWg== 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 g2si3297933ioo.75.2021.08.04.09.08.17; Wed, 04 Aug 2021 09:08:47 -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 S232723AbhHDQHj (ORCPT + 99 others); Wed, 4 Aug 2021 12:07:39 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42034 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232634AbhHDQHd (ORCPT ); Wed, 4 Aug 2021 12:07:33 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 97A301F4080F 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 Subject: [PATCH v5 13/23] fanotify: Allow file handle encoding for unhashed events Date: Wed, 4 Aug 2021 12:06:02 -0400 Message-Id: <20210804160612.3575505-14-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 FAN_FS_ERROR will report a file handle, but it is a unhashed event.n Allow passing a NULL hash to fanotify_encode_fh and avoid calculating the hash if not needed. Signed-off-by: Gabriel Krisman Bertazi --- fs/notify/fanotify/fanotify.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index a015822e29d8..0d6ba218bc01 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -385,8 +385,12 @@ static int fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, fh->type = type; fh->len = fh_len; - /* Mix fh into event merge key */ - *hash ^= fanotify_hash_fh(fh); + /* + * Mix fh into event merge key. Hash might be NULL in case of + * unhashed FID events (i.e. FAN_FS_ERROR). + */ + if (hash) + *hash ^= fanotify_hash_fh(fh); return FANOTIFY_FH_HDR_LEN + fh_len; -- 2.32.0