Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp737137pxt; Thu, 12 Aug 2021 08:30:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIE/jsuLx+wwlGG4GburHE9DKvCySDoxmZr0d3ligWKzDniEvTPOFairHVlFnO6huKG8Rz X-Received: by 2002:aa7:da4a:: with SMTP id w10mr6161642eds.206.1628782249659; Thu, 12 Aug 2021 08:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628782249; cv=none; d=google.com; s=arc-20160816; b=cCniqmsRYlBGe5ErLylC/MJ5oJ6IUE2Gu5AiTXU3FUh1ayjqvZDVSfW6ds5R+wcPSn fYnxVokMChVoCBDGjh+l2oGi9CIO7BKq+NLyekkhWEQ3wmk6IgaR3b/s5GZoPbLDFcfK 8ODr/04o8Qq/oVD1TkSFuaZJ3R00/qZqMT4+aSl9ZbP1n8l7ws2fSUYudhww8mIXCW0B qtH9is+f4mLHICZjM9TFchXWDGTUd7trQnC4+esfwMxxP1kw08CB+rI3JPxGxyWIR+cY /P/G3f76930lfcWsp6SfvhAx88sZiEKw3aa5pwjNUxlyCwaxfODsGv/eF4sx/Vh5FgNY lueQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:organization:subject:cc:to:from; bh=TkCDBBIvYaeN1Mk1BQMsWBWfsDMHNwHKsyWEVSdmD4k=; b=ThezGVc/kdMdtk2byWiQh41RBGDDTrTLUf8V6kXlMS8qoDoYQG/84EXHRhY96Ar/aM 48HHzsFrkQbcgJQtYpEojVh7bY+DFftglet1HO8eYcmfmFBb/K/45pFYv8UpBguI56JB z4qxaawbytivRqoHmiNymVX8X2lf2HLAoEazMrs2LrJQTWuUF9QtdB+rVQ2lh67kgzmv 3CTOaZHZkVl5sGT9ksAAMzhf3Ha2f3TZJflDRm39WuQ76rgFRYIWIfdYhn/wVwO0n8CE WxIIqteUGKX4JVsduuk+VL8F/sj0vMbVaOQB4/k19vFcmzu5qUvSGcS+1BEdVjHsg6eO fT6g== 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 y18si2832361ejh.298.2021.08.12.08.30.24; Thu, 12 Aug 2021 08:30:49 -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 S233443AbhHLPPA (ORCPT + 99 others); Thu, 12 Aug 2021 11:15:00 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:41264 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbhHLPO7 (ORCPT ); Thu, 12 Aug 2021 11:14:59 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id BC09C1F44053 From: Gabriel Krisman Bertazi To: Jan Kara Cc: 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 Organization: Collabora References: <20210804160612.3575505-1-krisman@collabora.com> <20210804160612.3575505-15-krisman@collabora.com> <20210805095618.GF14483@quack2.suse.cz> <87fsvf65zu.fsf@collabora.com> <20210812142047.GG14675@quack2.suse.cz> Date: Thu, 12 Aug 2021 11:14:29 -0400 In-Reply-To: <20210812142047.GG14675@quack2.suse.cz> (Jan Kara's message of "Thu, 12 Aug 2021 16:20:47 +0200") Message-ID: <875ywa66ga.fsf@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Jan Kara writes: > 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? Jan, Looking back at the email from Amir, I realize I misunderstood his original suggestion. Amir suggested it be FILEID_INVALID with 0-len OR FILEID_INO32_GEN with zeroed fields. I mixed the two suggestions. The advantage of doing FILEID_INO32_GEN with zeroed field is to avoid special casing the test program. But I don't have a good reason to use FILEID_INVALID with a len > 0. I'm sending a v6 with everything, including this, addressed. testcase and man pages will be updated as well. -- Gabriel Krisman Bertazi