Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp475238pxb; Fri, 15 Oct 2021 09:16:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyClRCe7vMcHUks9DzkCW5f3qpGctRMQHY80Agf0JETYnizCJ+CATDiBXiyObsdCi1nsnYV X-Received: by 2002:a17:90a:11:: with SMTP id 17mr14415477pja.238.1634314616611; Fri, 15 Oct 2021 09:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634314616; cv=none; d=google.com; s=arc-20160816; b=BYYrJhj2wasnjQL/WniBj8SsbQwpUQhv0lG9/9ehNyTH67zW/zUKn6hoURmfS2PGBy +cdmiDiqjIsUBxi0Xku7nAKt2rnkpjaujhnEihsrLkZ3oYVspeb8bDcPdHVeApVjEImx PnAPgUfsLaIM+ZIoW8Wo+WBC/iihjG/TrrXjz4f6YvSi6mwpMB4I2h4i4pxfGNPx25NT o2s4oJBvQ3DFqi2/8fzuC+k2JbjjGdlY9bzuqLvyOD+YH+9yCyv1hm90hV8wh39OpvnH +RANzZV1Z5s1JR2id6STgW7hdhrs9LyuAX1OveD3PnrwbdNaqMqNEA5HvUOc6lHU053a zsRQ== 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=+YccwefQA5p8o06eHm8nEC8qUU7yt3FVWxnzswl0XFE=; b=y2ASRAjXl+3WgRLLWxtQ1xmxKoWM5DV0qiTAAkmxTO8ysvGZKi34eaJhi/yV6W+FmO +RDVykhbTIQzCgFn9KAB/Xe4cO5idw6OFnQ9wtbNa4Ivl6WVJgkucP7o4tT75eRbQgjH E4igweafb9Iyjpb9uWx0yp+mtliNMpAdVF6eEhXuD2t9ipK37BpJ6IFNxAfJ0nqj9JHY 0UYk3X31Yc6KwY/QTFuejNbCF2FhnP46ZxrB24lot3QbpmDgW5AvWXP7nXO8V5ILALbX VKVFltJqQ+E8rfycPE5fR0BqU0rlJ810IJd1dTUwKLuT4FBKBq0uF/9Rp0vbpkVxIkuu S9lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=J8WqOR0R; dkim=neutral (no key) header.i=@suse.cz header.b=02wjcBJ1; 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 i14si8544518pgk.326.2021.10.15.09.16.43; Fri, 15 Oct 2021 09:16:56 -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=J8WqOR0R; dkim=neutral (no key) header.i=@suse.cz header.b=02wjcBJ1; 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 S237442AbhJOJev (ORCPT + 99 others); Fri, 15 Oct 2021 05:34:51 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:59790 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232499AbhJOJen (ORCPT ); Fri, 15 Oct 2021 05:34:43 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 963D41FD39; Fri, 15 Oct 2021 09:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1634290356; 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=+YccwefQA5p8o06eHm8nEC8qUU7yt3FVWxnzswl0XFE=; b=J8WqOR0RWF2uisr6/AavIvpO/251h/xi378DxfvXNit8fA5NJtvVsnEAx5MJMQ0F6Vqwth TSGTPBCFiNOR1m9rfm0+TUUr/k9oQDyn+Z8PUu0w+CMvhcj0+9RDNhZ4vnpuK1VKOYJUYa WaRjJNKrJckOlQXKJbBBdVGM2BTKsa4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1634290356; 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=+YccwefQA5p8o06eHm8nEC8qUU7yt3FVWxnzswl0XFE=; b=02wjcBJ1ls+YxORLx5INXml9B5H76rP9oWk+roFVzVuawHLAKS77bk8CAB0URGG+1m45cT JWoGWhNjk7JyxtAA== Received: from quack2.suse.cz (unknown [10.100.200.198]) by relay2.suse.de (Postfix) with ESMTP id 83124A3B83; Fri, 15 Oct 2021 09:32:36 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 6445F1E0A40; Fri, 15 Oct 2021 11:32:36 +0200 (CEST) Date: Fri, 15 Oct 2021 11:32:36 +0200 From: Jan Kara To: Gabriel Krisman Bertazi Cc: jack@suse.com, amir73il@gmail.com, djwong@kernel.org, tytso@mit.edu, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, repnop@google.com, kernel@collabora.com Subject: Re: [PATCH v7 14/28] fanotify: Encode empty file handle when no inode is provided Message-ID: <20211015093236.GG23102@quack2.suse.cz> References: <20211014213646.1139469-1-krisman@collabora.com> <20211014213646.1139469-15-krisman@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211014213646.1139469-15-krisman@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu 14-10-21 18:36:32, Gabriel Krisman Bertazi wrote: > Instead of failing, encode an invalid file handle in fanotify_encode_fh > if no inode is provided. This bogus file handle will be reported by > FAN_FS_ERROR for non-inode errors. > > Signed-off-by: Gabriel Krisman Bertazi Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > Changes since v6: > - Use FILEID_ROOT as the internal value (jan) > - Create an empty FH (jan) > > Changes since v5: > - Preserve flags initialization (jan) > - Add BUILD_BUG_ON (amir) > - Require minimum of FANOTIFY_NULL_FH_LEN for fh_len(amir) > - Improve comment to explain the null FH length (jan) > - Simplify logic > --- > fs/notify/fanotify/fanotify.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c > index ec84fee7ad01..c64d61b673ca 100644 > --- a/fs/notify/fanotify/fanotify.c > +++ b/fs/notify/fanotify/fanotify.c > @@ -370,8 +370,14 @@ static int fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, > fh->type = FILEID_ROOT; > fh->len = 0; > fh->flags = 0; > + > + /* > + * Invalid FHs are used by FAN_FS_ERROR for errors not > + * linked to any inode. The f_handle won't be reported > + * back to userspace. > + */ > if (!inode) > - return 0; > + goto out; > > /* > * !gpf means preallocated variable size fh, but fh_len could > @@ -403,6 +409,7 @@ static int fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, > fh->type = type; > fh->len = fh_len; > > +out: > /* > * Mix fh into event merge key. Hash might be NULL in case of > * unhashed FID events (i.e. FAN_FS_ERROR). > -- > 2.33.0 > -- Jan Kara SUSE Labs, CR