Re: [PATCH 01/10] fanotify: don't skip extra event info if no info_mode is set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu 25-07-24 14:19:38, Josef Bacik wrote:
> Previously we would only include optional information if you requested
> it via an FAN_ flag at fanotify_init time (FAN_REPORT_FID for example).
> However this isn't necessary as the event length is encoded in the
> metadata, and if the user doesn't want to consume the information they
> don't have to.

So I somewhat disagree with this statement because historically there was
fanotify userspace that completely ignored event length reported in the
event and assumed particular hardcoded constant that was working for years.
That's why we are careful and add info to *existing* events only if
userspace explicitely asks for it (by which it obviously also acknowledges
that it is ready to parse/skip it). Now here we are adding range info only
to new events so preexisting userspace isn't a problem in this case. And I
agree it is kind of pointless to add a new flag, just to be able to tell
you want info without which these events are pointless.

Also as far as I can tell these changes will not result in any new info
records to be generated for existing events. So I would just change the
description to something like:

New pre-content events will be path events but they will also carry
additional range information. Remove the optimization to skip checking
whether info structures need to be generated for path events. This results
in no change in generated info structures for existing events.

								Honza

>  With the PRE_ACCESS events we will always generate range
> information, so drop this check in order to allow this extra
> information to be exported without needing to have another flag.
> 
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
> ---
>  fs/notify/fanotify/fanotify_user.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
> index 9ec313e9f6e1..2e2fba8a9d20 100644
> --- a/fs/notify/fanotify/fanotify_user.c
> +++ b/fs/notify/fanotify/fanotify_user.c
> @@ -160,9 +160,6 @@ static size_t fanotify_event_len(unsigned int info_mode,
>  	int fh_len;
>  	int dot_len = 0;
>  
> -	if (!info_mode)
> -		return event_len;
> -
>  	if (fanotify_is_error_event(event->mask))
>  		event_len += FANOTIFY_ERROR_INFO_LEN;
>  
> @@ -740,12 +737,10 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
>  	if (fanotify_is_perm_event(event->mask))
>  		FANOTIFY_PERM(event)->fd = fd;
>  
> -	if (info_mode) {
> -		ret = copy_info_records_to_user(event, info, info_mode, pidfd,
> -						buf, count);
> -		if (ret < 0)
> -			goto out_close_fd;
> -	}
> +	ret = copy_info_records_to_user(event, info, info_mode, pidfd,
> +					buf, count);
> +	if (ret < 0)
> +		goto out_close_fd;
>  
>  	if (f)
>  		fd_install(fd, f);
> -- 
> 2.43.0
> 
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux