Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp722927pxt; Thu, 12 Aug 2021 08:13:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC9gIerm/A/B2oLybH7v2EbUYV+kJvs8GcvDMM5N0kLq0V2qGwDoL/Z+RTzWtXM8TSpAnm X-Received: by 2002:a5d:4290:: with SMTP id k16mr4651337wrq.224.1628781223785; Thu, 12 Aug 2021 08:13:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628781223; cv=none; d=google.com; s=arc-20160816; b=eT/Ln9h4df6d2vqgC4auX8DKQBKIScxZPQbvYhp6HA3C6AzckMcStyYxEj/Eu8qQpv LzUZOQRneRmnbfa0rcIgCFXI8r1VwmbNYPvBBgVG8QVxe/I+ZDyzMxtPVuJ9zzyehvah QI+trNl3EFEyenelFMu4tcan/6WtGe31jL+x82YzcTqeK3KHic+h548VXYP2p45Awuw0 oUh9p0z0WDAOb0l6RQmW/5f69zkVJQJgznEE5w9E8VtyHAMMZbz1iup16MyacLlAk73S EfiM8So1TUVUpW2DkpN+sGJUQyE9PaOSjvDrsqNX88FGXmchl+fG538ITw4pG6zeuOKN OxhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=EClbvh9H+h5jyqo9gR5SEvG/Auimr/66D2NFteFl1D8=; b=C3ZG82avreUIWiIxOpKPt7NEtyp0hXGGZbp5GRVTg8dHVIRrgalXyzKEO986t2zCBw +bDZv0evT5O7KCtYwOYsv1JrUctW/e63ir8uACwcAfqbFtR1sQ46/DZyHexftt7XGJXc vSCyCgQsl+1ziINh+cJg1yOBL/tdNqwC/ywzeMChWDuvKNlyLrmWbF2hOdtBNYNydWYm DJnrCP5+Kkhe7W5/ZHBZnIcyTaq/arVQxMsKnaw2C3t1Y7wuJunrPf0XVv6NumDnMB/c ypod/NHpGf8WiQGyk+YvCGqAyyFLuRsEDuLMy6KVCgrsnX28T+tWdV1OuFmoH49iLO0o FEWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lV2elbtY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=uAC8kh+3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s12si2429922ejc.488.2021.08.12.08.13.14; Thu, 12 Aug 2021 08:13:43 -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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lV2elbtY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=uAC8kh+3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237926AbhHLOVO (ORCPT + 99 others); Thu, 12 Aug 2021 10:21:14 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:52930 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237341AbhHLOVO (ORCPT ); Thu, 12 Aug 2021 10:21:14 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1C581221FF; Thu, 12 Aug 2021 14:20:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1628778048; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EClbvh9H+h5jyqo9gR5SEvG/Auimr/66D2NFteFl1D8=; b=lV2elbtYUDc84fX/o5rXKWB/zott34AxpZXY6uRtGS+5sm4816iMxnMkJvpmtAvP/8xhlx HStjguATPwUnhtbaWej9MlkiYPdN6jZuhVWq2Tq/ngnl823VW0WoJoZrmF+VkdxdCPYaR8 b3bk5IP9Hax9He7QiI8UaHyr52Rgt/s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1628778048; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EClbvh9H+h5jyqo9gR5SEvG/Auimr/66D2NFteFl1D8=; b=uAC8kh+39aQAVX9rctu7o6GTL2p468GQ2NLM65o535WUQyksmoVofTdIQafrFK9aaNAB9j xyLLAfzqlwxNrFBA== Received: from quack2.suse.cz (unknown [10.100.224.230]) by relay2.suse.de (Postfix) with ESMTP id F10B2A3F5B; Thu, 12 Aug 2021 14:20:47 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id B7F771F2BA7; Thu, 12 Aug 2021 16:20:47 +0200 (CEST) Date: Thu, 12 Aug 2021 16:20:47 +0200 From: Jan Kara To: Gabriel Krisman Bertazi Cc: Jan Kara , jack@suse.com, amir73il@gmail.com, 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, kernel@collabora.com Subject: Re: [PATCH v5 14/23] fanotify: Encode invalid file handler when no inode is provided Message-ID: <20210812142047.GG14675@quack2.suse.cz> References: <20210804160612.3575505-1-krisman@collabora.com> <20210804160612.3575505-15-krisman@collabora.com> <20210805095618.GF14483@quack2.suse.cz> <87fsvf65zu.fsf@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87fsvf65zu.fsf@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed 11-08-21 17:12:05, Gabriel Krisman Bertazi wrote: > Jan Kara writes: > >> @@ -376,14 +371,24 @@ static int fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, > >> fh->flags |= FANOTIFY_FH_FLAG_EXT_BUF; > >> } > >> > >> - dwords = fh_len >> 2; > >> - type = exportfs_encode_inode_fh(inode, buf, &dwords, NULL); > >> - err = -EINVAL; > >> - if (!type || type == FILEID_INVALID || fh_len != dwords << 2) > >> - goto out_err; > >> - > >> - fh->type = type; > >> - fh->len = fh_len; > >> + if (inode) { > >> + dwords = fh_len >> 2; > >> + type = exportfs_encode_inode_fh(inode, buf, &dwords, NULL); > >> + err = -EINVAL; > >> + if (!type || type == FILEID_INVALID || fh_len != dwords << 2) > >> + goto out_err; > >> + fh->type = type; > >> + fh->len = fh_len; > >> + } else { > >> + /* > >> + * Invalid FHs are used on FAN_FS_ERROR for errors not > >> + * linked to any inode. Caller needs to guarantee the fh > >> + * has at least FANOTIFY_NULL_FH_LEN bytes of space. > >> + */ > >> + fh->type = FILEID_INVALID; > >> + fh->len = FANOTIFY_NULL_FH_LEN; > >> + memset(buf, 0, FANOTIFY_NULL_FH_LEN); > >> + } > > > > Maybe it will become clearer later during the series but why do you set > > fh->len to FANOTIFY_NULL_FH_LEN and not 0? > > Jan, > > That is how we encode a NULL file handle (i.e. superblock error). Amir > suggested it would be an invalid FILEID_INVALID, with a zeroed handle of > size 8. I will improve the comment on the next iteration. Thanks for info. Then I have a question for Amir I guess :) Amir, what's the advantage of zeroed handle of size 8 instead of just 0 length file handle? Honza -- Jan Kara SUSE Labs, CR