]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fanotify: don't skip extra event info if no info_mode is set
authorJosef Bacik <josef@toxicpanda.com>
Fri, 15 Nov 2024 15:30:17 +0000 (10:30 -0500)
committerJan Kara <jack@suse.cz>
Tue, 10 Dec 2024 11:03:16 +0000 (12:03 +0100)
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.  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@toxicpanda.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/afcbc4e4139dee076ef1757918b037d3b48c3edb.1731684329.git.josef@toxicpanda.com
fs/notify/fanotify/fanotify_user.c

index 919ff59cb8026225a09399f92b9902cbc60635a6..8fca5ec442e421b9e2855e2fd5f40ff614f9d625 100644 (file)
@@ -158,9 +158,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;
 
@@ -754,12 +751,10 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
        buf += FAN_EVENT_METADATA_LEN;
        count -= FAN_EVENT_METADATA_LEN;
 
-       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);