From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YMbxR9d+" Received: from mail-oo1-xc2f.google.com (mail-oo1-xc2f.google.com [IPv6:2607:f8b0:4864:20::c2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45F2B10B for ; Sun, 10 Dec 2023 05:24:12 -0800 (PST) Received: by mail-oo1-xc2f.google.com with SMTP id 006d021491bc7-59064bca27dso2091511eaf.0 for ; Sun, 10 Dec 2023 05:24:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702214651; x=1702819451; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=X++IaS3u8l0Oe7uSZY8tik/EztLEZ/j0FuQZXVJm6uk=; b=YMbxR9d+MHI6KFMqxdteetRv03IXi8s448lo/PV/7VASg3SRaCuO0blw02ewSjhP5P i+YeapisKLA8Xv3VSXkBpiD13yaaSXLs8NOR2H5qXz6XIiFeattjWKkJSTSHPNpWZQd8 bB3pA2bCCnLmf5r+bru+0XKOSKJV5al/4aVIxxuPUVJ8aswD+6G1MseIi6qH/UVjLbYO j7hSxlT7VbOJJ9kW1d4ml0H+GLZQvEGTPmuFClIkDg0GiJr4BmODdlXTTTAfCwt9/LJ8 VDbZEZ3oT+RHTJ/wQZvwKknJduLy/wP8KFRor9Fvyy6UlwARKSl3Ryn+yWq+EHyMS5id ARSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702214651; x=1702819451; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=X++IaS3u8l0Oe7uSZY8tik/EztLEZ/j0FuQZXVJm6uk=; b=ZgqoOjdst2lSNFWoITyQvTpVYB4Kt/GcvTNjjtbISMejK+EX08TukKKXSbAr21HIb3 BkZQGC7s+Izymi89LM3gqoTOX/DBE6yFWPWekbJfLIh49hrEoghcaNUbqO8FsALJUnN7 hcrp6iC0+V3QBs2u+GTaWTBQ8ftZIWgX32v0g21smoq2S/xVzj4FE0hXi45cWqA8Za6D PRqWJd5z5Qnu0Vj5I/3CwqJDo21mVZO7WJgpxtg4rybQVudPX46yjfSb/EvaGBLaUoR/ ko9tagnNbSdfJwLvmC9JWrz0aPjIXHXTCoY49x5nFl5VCNrAIcYv2KSlFUIU0fdOxPVl hOOg== X-Gm-Message-State: AOJu0YwDVN7WUKYdjPz9a87bkPahpL/cebHLg/K8KyUYHuCnPWgzshcG /9Oho9fGWPGIK7JA8LHgrbY98dmcR/BTlFD703MsyYYGB88= X-Google-Smtp-Source: AGHT+IHgy+Fnkk3m7IDJi424KLpdHiSxrYVrhBH8z7LBNsg2/k1VY9vKRQr/hMS2Lp83s3Ob/Y7FGVZoLeZr4YvVnpI= X-Received: by 2002:a05:6358:4291:b0:16e:783a:eb66 with SMTP id s17-20020a056358429100b0016e783aeb66mr2477034rwc.0.1702214651396; Sun, 10 Dec 2023 05:24:11 -0800 (PST) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231207123825.4011620-1-amir73il@gmail.com> <20231207123825.4011620-5-amir73il@gmail.com> <20231208185302.wkzvwthf5vuuuk3s@quack3> In-Reply-To: From: Amir Goldstein Date: Sun, 10 Dec 2023 15:24:00 +0200 Message-ID: Subject: Re: [PATCH 4/4] fsnotify: pass access range in file permission hooks To: Jan Kara Cc: Christian Brauner , Jeff Layton , Josef Bacik , Christoph Hellwig , David Howells , Jens Axboe , Miklos Szeredi , Al Viro , linux-fsdevel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" > > > diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h > > > index 0a9d6a8a747a..45e6ecbca057 100644 > > > --- a/include/linux/fsnotify.h > > > +++ b/include/linux/fsnotify.h > > > @@ -103,7 +103,8 @@ static inline int fsnotify_file(struct file *file, __u32 mask) > > > /* > > > * fsnotify_file_perm - permission hook before file access > > > */ > > > -static inline int fsnotify_file_perm(struct file *file, int perm_mask) > > > +static inline int fsnotify_file_perm(struct file *file, int perm_mask, > > > + const loff_t *ppos, size_t count) > > > { > > > __u32 fsnotify_mask = FS_ACCESS_PERM; > > > > Also why do you actually pass in loff_t * instead of plain loff_t? You > > don't plan to change it, do you? > > No I don't. Please note that the pointer is to const loff_t. > > I used NULL to communicate "no range info" to fanotify. > It is currently only used from iterate_dir(), but filesystems may need to > use that to report other cases of pre-content access with no clear range info. Correction. iterate_dir() is not the only case. The callers that use file_ppos(), namely ksys_{read,write}, do_{readv,writev}() will pass a NULL ppos for an FMODE_STREAM file. The only sane behavior I could come up with for those cases is to not report range_info with the FAN_PRE_ACCESS event. > > I could leave fsnotify_file_perm(file, mask) for reporting events without > range info and add fsnotify_file_area(file, mask, pos, count) for reporting > access permission with range info. > I renamed the hook in v2 to fsnotify_file_area_perm() and added a wrapper: static inline int fsnotify_file_perm(struct file *file, int perm_mask) { return fsnotify_file_area_perm(file, perm_mask, NULL, 0); } Thanks, Amir.