@@ -121,6 +121,8 @@ struct kmem_cache *fanotify_perm_event_cachep __ro_after_init;
121
121
sizeof(struct fanotify_event_info_pidfd)
122
122
#define FANOTIFY_ERROR_INFO_LEN \
123
123
(sizeof(struct fanotify_event_info_error))
124
+ #define FANOTIFY_RANGE_INFO_LEN \
125
+ (sizeof(struct fanotify_event_info_range))
124
126
125
127
static int fanotify_fid_info_len (int fh_len , int name_len )
126
128
{
@@ -180,6 +182,9 @@ static size_t fanotify_event_len(unsigned int info_mode,
180
182
if (info_mode & FAN_REPORT_PIDFD )
181
183
event_len += FANOTIFY_PIDFD_INFO_LEN ;
182
184
185
+ if (fanotify_event_has_access_range (event ))
186
+ event_len += FANOTIFY_RANGE_INFO_LEN ;
187
+
183
188
return event_len ;
184
189
}
185
190
@@ -516,6 +521,30 @@ static int copy_pidfd_info_to_user(int pidfd,
516
521
return info_len ;
517
522
}
518
523
524
+ static size_t copy_range_info_to_user (struct fanotify_event * event ,
525
+ char __user * buf , int count )
526
+ {
527
+ struct fanotify_perm_event * pevent = FANOTIFY_PERM (event );
528
+ struct fanotify_event_info_range info = { };
529
+ size_t info_len = FANOTIFY_RANGE_INFO_LEN ;
530
+
531
+ if (WARN_ON_ONCE (info_len > count ))
532
+ return - EFAULT ;
533
+
534
+ if (WARN_ON_ONCE (!pevent -> ppos ))
535
+ return - EINVAL ;
536
+
537
+ info .hdr .info_type = FAN_EVENT_INFO_TYPE_RANGE ;
538
+ info .hdr .len = info_len ;
539
+ info .offset = * (pevent -> ppos );
540
+ info .count = pevent -> count ;
541
+
542
+ if (copy_to_user (buf , & info , info_len ))
543
+ return - EFAULT ;
544
+
545
+ return info_len ;
546
+ }
547
+
519
548
static int copy_info_records_to_user (struct fanotify_event * event ,
520
549
struct fanotify_info * info ,
521
550
unsigned int info_mode , int pidfd ,
@@ -637,6 +666,15 @@ static int copy_info_records_to_user(struct fanotify_event *event,
637
666
total_bytes += ret ;
638
667
}
639
668
669
+ if (fanotify_event_has_access_range (event )) {
670
+ ret = copy_range_info_to_user (event , buf , count );
671
+ if (ret < 0 )
672
+ return ret ;
673
+ buf += ret ;
674
+ count -= ret ;
675
+ total_bytes += ret ;
676
+ }
677
+
640
678
return total_bytes ;
641
679
}
642
680
0 commit comments