Thread (54 messages) read the whole thread 54 messages, 4 authors, 2021-08-19

Re: [PATCH v6 12/21] fanotify: Encode invalid file handle when no inode is provided

From: Jan Kara <jack@suse.cz>
Date: 2021-08-16 16:11:51
Also in: linux-ext4, linux-fsdevel

On Mon 16-08-21 18:54:58, Amir Goldstein wrote:
On Mon, Aug 16, 2021 at 5:07 PM Jan Kara [off-list ref] wrote:
quoted
Dunno, it still seems like quite some complications (simple ones but
non-trivial amount of them) for what is rather a corner case. What if we
*internally* propagated the information that there's no inode info with
FILEID_ROOT fh? That means: No changes to fanotify_encode_fh_len(),
fanotify_encode_fh(), or fanotify_alloc_name_event(). In
copy_info_to_user() we just mangle FILEID_ROOT to FILEID_INVALID and that's
all. No useless padding, no specialcasing of copying etc. Am I missing
something?
I am perfectly fine with encoding "no inode" with FILEID_ROOT internally.
It's already the value used by fanotify_encode_fh() in upstream.

However, if we use zero len internally, we need to pass fh_type to
fanotify_fid_info_len() and special case FILEID_ROOT in order to
take FANOTIFY_FID_INFO_HDR_LEN into account.

And special case fanotify_event_object_fh_len() in
 fanotify_event_info_len() and in copy_info_records_to_user().
Right, this will need some tweaking. I would actually leave
fanotify_fid_info_len() alone, just have in fanotify_event_info_len()
something like:

-	if (fh_len)
+	if (fh_len || fanotify_event_needs_fsid(event))

and similarly in copy_info_records_to_user():

-	if (fanotify_event_object_fh_len(event)) {
+	if (fanotify_event_object_fh_len(event) ||
+	    fanotify_event_needs_fsid(event)) {

And that should be all that's needed as far as I'm reading the code.

								Honza
-- 
Jan Kara [off-list ref]
SUSE Labs, CR
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help