• Amir Goldstein's avatar
    fanotify: no external fh buffer in fanotify_name_event · f35c4156
    Amir Goldstein authored
    The fanotify_fh struct has an inline buffer of size 12 which is enough
    to store the most common local filesystem file handles (e.g. ext4, xfs).
    For file handles that do not fit in the inline buffer (e.g. btrfs), an
    external buffer is allocated to store the file handle.
    
    When allocating a variable size fanotify_name_event, there is no point
    in allocating also an external fh buffer when file handle does not fit
    in the inline buffer.
    
    Check required size for encoding fh, preallocate an event buffer
    sufficient to contain both file handle and name and store the name after
    the file handle.
    
    At this time, when not reporting name in event, we still allocate
    the fixed size fanotify_fid_event and an external buffer for large
    file handles, but fanotify_alloc_name_event() has already been prepared
    to accept a NULL file_name.
    
    Link: https://lore.kernel.org/r/20200716084230.30611-11-amir73il@gmail.comSigned-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
    Signed-off-by: default avatarJan Kara <jack@suse.cz>
    f35c4156
fanotify.h 7.42 KB