Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp102394pxb; Fri, 15 Oct 2021 01:23:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyjyk4yz1N6pWvrTvjziCMYocSiEPx2zlVsj4DK+MxDeH8xMC+YO+O4Bxx//zD/th7Lc17 X-Received: by 2002:a17:907:3e03:: with SMTP id hp3mr5192397ejc.183.1634286231881; Fri, 15 Oct 2021 01:23:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634286231; cv=none; d=google.com; s=arc-20160816; b=AZOgVQlIBSCl5E6P1YP+AQ/v5xIT0ComgbwkxIuRX0wYOOsFcS8dV3jdhCDZJYBV53 mKWHPmy/wU1X3yxU6LZG7cZvb0eqGpUMNmrqTjpHa+rf33mMjUai66yxZCPbF1f03yJX UQtDcNmRTYEyJSRhjSopM6EQP0mdzZure1ktpWE4wDPUrtntome+GKEOF4Y7UuT5wtsj B8B4UmWghn9ZFPt2Rj2j4NSRLUkOHmi+o0n93/Bu7BYML08oOKZoZ/+szFi6ywRQi0Xk M3Gw0Eyr9z4sKsFHN6oHPm7oZB6P2niJFGuBIzopn3+ndKRgXIYdOk/gC6QZfIs7eNS2 ZhOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8/S51zX4pr2QU+J9qft8HmXq8g/X9xnf7JRaBK+P4tU=; b=st15cn+mfZS4x28Ol52Xz5AtN9i/0JKTEdESpl8Gjzp61UUCFvSew0eBIvvGew037x R0akOPcsWDmK8NUbc/+WaALGFTIjHfEIJXoFwSTwj/L8tTSu4OdBpMsPJe12KwotzXZQ ZIy6if0cq2JE5Cx+ZWodk+yKw4Oo7KwPPeUDnS+h7HWCCi78GLgp3hTceMysmkz2hjc3 IEaXutlebc6MZG3n/rpgNYeqb58gk60ie2mi0HSouTImCaO9RPk3Bqys2oNY2EWo/ALp JXJB4bdx7prKhVHSq1z/y3gKgJarzpdBmJt4g7C4OGzuuZEylZYcqBXiyZAcq3H99KSA oThA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HfrAZKgu; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la10si7840469ejc.550.2021.10.15.01.23.28; Fri, 15 Oct 2021 01:23:51 -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=@gmail.com header.s=20210112 header.b=HfrAZKgu; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231495AbhJOGFF (ORCPT + 99 others); Fri, 15 Oct 2021 02:05:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbhJOGFE (ORCPT ); Fri, 15 Oct 2021 02:05:04 -0400 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A0D0C061570; Thu, 14 Oct 2021 23:02:58 -0700 (PDT) Received: by mail-il1-x12c.google.com with SMTP id s3so6099959ild.0; Thu, 14 Oct 2021 23:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8/S51zX4pr2QU+J9qft8HmXq8g/X9xnf7JRaBK+P4tU=; b=HfrAZKguB+raI1O2TivEjBgSqziGJGdG3VnAhvQizw/RB3JxOnzLcfiuJEoxzJm8k0 qjYv5Bh4W7fC5nGfXowWhnWO81e0IaaDyW/3AbcddWoe7rhy91VHE04inlDJw+nv6/9Y dnv8cvMZDyyyAobFQ81fXBgIkZktx4iDyml3yXO/A5iUQdACYAqK2TMiFmFt/VUOZYL7 A6yvEl9O0IL8QSLtqVboRdZY7r9sd5T5IRa0kq0Xgnh91wMcPzXhqrnlrFXtyKOLRHDq xm/CRnK1SMxPZu3Q0sODpaLNBhsllYGczfIH7gW42WuqggIL9G81jDM0195k9/jpMOGP 6TFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8/S51zX4pr2QU+J9qft8HmXq8g/X9xnf7JRaBK+P4tU=; b=u7c51z8CcTZvwdDBLR59aR2GFS4GHofH+SDcRrCSYgudVQqO19zDTUAnx6I+ilgNrt J0J5CWbMjny/3VRq9uOCcfolV/gnCLRKtjxNaa/BFRLGj46YReGZqnLT6bPARfhLX8LL Y8xD47/85wR7QlNKBSv2MrDIf0mmdkQsqMgdJAMiL3nzqSj8pH0uKdiwjZROs+JkRyLd +mijdYZoNNHDjx4deH04xpXV0+CrxjNIRRpKLsBiI4FMd6eQoa2Ed8CkgkxPBKfMvfTy cmA9D5hPon+05YiQlb36iBE9V98ZRBsTAW+osXc0tnd0EFVHUqk4sCDLjMvHa4zF8Iwf H0Yg== X-Gm-Message-State: AOAM530tzLiZtxTYa7TiKKktgQFHc5QH4sZQAPEoaEE5vEbzhjy+dKCI Lvgjf4PxjL21QMo5Ee3lJG5cdetgba4965WviTU= X-Received: by 2002:a05:6e02:1be8:: with SMTP id y8mr2522282ilv.24.1634277777880; Thu, 14 Oct 2021 23:02:57 -0700 (PDT) MIME-Version: 1.0 References: <20211014213646.1139469-1-krisman@collabora.com> <20211014213646.1139469-15-krisman@collabora.com> In-Reply-To: <20211014213646.1139469-15-krisman@collabora.com> From: Amir Goldstein Date: Fri, 15 Oct 2021 09:02:47 +0300 Message-ID: Subject: Re: [PATCH v7 14/28] fanotify: Encode empty file handle when no inode is provided To: Gabriel Krisman Bertazi Cc: Jan Kara , "Darrick J. Wong" , Theodore Tso , David Howells , Khazhismel Kumykov , linux-fsdevel , Ext4 , Linux API , Matthew Bobrowski , kernel@collabora.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Oct 15, 2021 at 12:38 AM 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 Reviewed-by: Amir Goldstein > > --- > 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 >