Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp262147pxb; Thu, 12 Aug 2021 16:01:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznAgemayjoRxOKPq0Vjcg4OYWPgXMMcgAF9uDX49Xiu+AnHkYGENvcy8+px0k+x7mVzIaf X-Received: by 2002:a50:9b06:: with SMTP id o6mr8646692edi.284.1628809291619; Thu, 12 Aug 2021 16:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628809291; cv=none; d=google.com; s=arc-20160816; b=nxr6VJIbG5Wi8MemO0C3uHMo0jLi0V0o3fkUDkD6ucXM3DLSn7F1Uggw06wxx8xPgV 6uupWxQzRd4DYp2LFcqa9DcQGb3AkA9jVbaRENtgsEx57qago0fGnkfSJeJ1R5paGQCM PBr28o3tyCBzIeAs7AP4g/IGa5gWSVmoVoNjpSAPfBuwqKTYCp3SV/IwrDm9tHn5XViU WwLh+DbfCyO0noxIxWBHPa5UBssDMqcPiSX7s9XiJ9kIPrf8rpnPfwF3CR21uhlIBeJa tHa09uT2UxTbRgtFqVgQvjmUycZTsLBVxuMYxEMM2Oeihw0Unwi858FZ1r+OnOYjKKGt A9FA== 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=upThvrJktw867ikGFPLTe/BWF/fMzJPTIHqRuOZ9wiQ=; b=Qs4wbFkPn5WxA6Iesk58aI/4BM51WY5nZPSefCeLKmpxCzF/dT2MZ/PjxC01TVmbXM I4jc24Pdi4/l1hGSdmEs7uJjDh2ZjtQXlr0ORpA7aWMPZilU+VpMOHe15YxUzIh+EgW4 iZoVhDTQ32mFvu5UXa0YH0DRxGfiOdujbosgD9BguBrLFzurFGkzRFnso5MSI7u1g7fu +7HLBbFa6oiHyRuRLTZr6eI4o7jbOwmoWwZLXmEXiS+95EnAi+X/r48mn0AVa0kntMeM 327f9vaMLsAUrBt2eUnUxOzZEidwFGw4Y4omEuuLTjulbiVGhDb6qiiKwucBaovYJ1Xg 1wHg== 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 hp6si3802963ejc.477.2021.08.12.16.01.01; Thu, 12 Aug 2021 16:01:31 -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 S237901AbhHLVlh (ORCPT + 99 others); Thu, 12 Aug 2021 17:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233260AbhHLVlg (ORCPT ); Thu, 12 Aug 2021 17:41:36 -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 29CEBC061756; Thu, 12 Aug 2021 14:41:11 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id B80341F41890 From: Gabriel Krisman Bertazi To: amir73il@gmail.com, jack@suse.com Cc: linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, khazhy@google.com, dhowells@redhat.com, david@fromorbit.com, tytso@mit.edu, djwong@kernel.org, repnop@google.com, Gabriel Krisman Bertazi , kernel@collabora.com, Jan Kara Subject: [PATCH v6 11/21] fanotify: Allow file handle encoding for unhashed events Date: Thu, 12 Aug 2021 17:40:00 -0400 Message-Id: <20210812214010.3197279-12-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210812214010.3197279-1-krisman@collabora.com> References: <20210812214010.3197279-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 an unhashed event. Allow passing a NULL hash to fanotify_encode_fh and avoid calculating the hash if not needed. Signed-off-by: Gabriel Krisman Bertazi Reviewed-by: Jan Kara --- 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 acf78c0ed219..50fce4fec0d6 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -403,8 +403,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