Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3504130pxb; Mon, 18 Oct 2021 17:05:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPkiGOb9as8EAjUrPD0ruFF65lHkEwB6xe+dJMYkBugGD2Bkq2onDtkpi95zrWpAKQ+zr0 X-Received: by 2002:aa7:cd99:: with SMTP id x25mr48737236edv.266.1634601955143; Mon, 18 Oct 2021 17:05:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634601955; cv=none; d=google.com; s=arc-20160816; b=sZIpEBoXrqKAcy9htlxAksLzuKT5UP2PKrx822YOR+Zi/7O2q+mG3Gvy1f2T7UeSV9 qlIktKd3bjnzDr7G2tJXS4wSVfqf5lOl1+4tIg0XM2HPRUzYKdlcoyC2P3E0Ne+BpeLh Aebs0cjcoMLg44qaKpz/QLoACt80TceQJm6phEtRMgZui5p0zaHXawFR2nZ8WumxWRa/ hXxkHto0i2qB8F1qnuy2uKYBFGC6VK1Katj0uQxwkHqIoEDLeXHNNEf2lXpTDgcVlDEF zmS9NldXzIaJ+UuVjbJDNDIE63aEt020r0vsm57iR3dW2xzAkvBlb1Sv/8ihaDMYJA37 qC4Q== 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=CAUIofNETA7LOhsHR5tl0GvqPkCOPcMrQDsOVq3CtTk=; b=GquyekBeTZJ/f+gOTKCLnvcxVZ1/9GHNiCYb5iKyMTj9mw/HBjazSi6milQBMJhxZl bhatqytAgkdn4g8TTiqhnxnOZkUVdIaNDRKMidfwCN+piNK+8g5KZzl/aroSpWeQ7Jtf Pc7Hwq/BfUAPZTjPFhIurJEzNWtrgJRRXCDHrA+SKA+mmVw15Deaifd4LNUQ4cLeolo5 nbARMGHgZ0p8firdxlrUYPmIKSPqJIcfkIYtZMRtkIaZjCMvxgkvGfAzoMZ75sFMJV97 XDmLRYtUn6Zg1aXdP7ilkXwxwb6ZvF/0MMtJ2b6Q2JkApJ/ZUlLocZfKuoOis7a7igeq iaQA== 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 mu47si7643164ejc.609.2021.10.18.17.05.30; Mon, 18 Oct 2021 17:05:55 -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 S233803AbhJSAF7 (ORCPT + 99 others); Mon, 18 Oct 2021 20:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbhJSAF7 (ORCPT ); Mon, 18 Oct 2021 20:05:59 -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 8BE15C06161C; Mon, 18 Oct 2021 17:03:47 -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 DFB4B1F43440; Tue, 19 Oct 2021 01:03:45 +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 Subject: [PATCH v8 25/32] fanotify: Report fid entry even for zero-length file_handle Date: Mon, 18 Oct 2021 21:00:08 -0300 Message-Id: <20211019000015.1666608-26-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 Non-inode errors will reported with an empty file_handle. In preparation for that, allow some events to print the FID record even if there isn't any file_handle encoded Even though FILEID_ROOT is used internally, make zero-length file handles be reported as FILEID_INVALID. Signed-off-by: Gabriel Krisman Bertazi --- fs/notify/fanotify/fanotify_user.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index ae848306a017..cd962deefeb7 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -339,9 +339,6 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh, pr_debug("%s: fh_len=%zu name_len=%zu, info_len=%zu, count=%zu\n", __func__, fh_len, name_len, info_len, count); - if (!fh_len) - return 0; - if (WARN_ON_ONCE(len < sizeof(info) || len > count)) return -EFAULT; @@ -376,6 +373,11 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh, handle.handle_type = fh->type; handle.handle_bytes = fh_len; + + /* Mangle handle_type for bad file_handle */ + if (!fh_len) + handle.handle_type = FILEID_INVALID; + if (copy_to_user(buf, &handle, sizeof(handle))) return -EFAULT; -- 2.33.0