Message ID | 20211019000015.1666608-26-krisman@collabora.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | file system-wide error monitoring | expand |
On Tue, Oct 19, 2021 at 3:03 AM Gabriel Krisman Bertazi <krisman@collabora.com> wrote: > > Non-inode errors will reported with an empty file_handle. In > preparation for that, allow some events to print the FID record even if > there isn't any file_handle encoded > > Even though FILEID_ROOT is used internally, make zero-length file > handles be reported as FILEID_INVALID. > > Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> > --- > fs/notify/fanotify/fanotify_user.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c > index ae848306a017..cd962deefeb7 100644 > --- a/fs/notify/fanotify/fanotify_user.c > +++ b/fs/notify/fanotify/fanotify_user.c > @@ -339,9 +339,6 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh, > pr_debug("%s: fh_len=%zu name_len=%zu, info_len=%zu, count=%zu\n", > __func__, fh_len, name_len, info_len, count); > > - if (!fh_len) > - return 0; > - > if (WARN_ON_ONCE(len < sizeof(info) || len > count)) > return -EFAULT; > > @@ -376,6 +373,11 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh, > > handle.handle_type = fh->type; > handle.handle_bytes = fh_len; > + > + /* Mangle handle_type for bad file_handle */ > + if (!fh_len) > + handle.handle_type = FILEID_INVALID; > + > if (copy_to_user(buf, &handle, sizeof(handle))) > return -EFAULT; > > -- > 2.33.0 >
On Mon 18-10-21 21:00:08, Gabriel Krisman Bertazi wrote: > Non-inode errors will reported with an empty file_handle. In > preparation for that, allow some events to print the FID record even if > there isn't any file_handle encoded > > Even though FILEID_ROOT is used internally, make zero-length file > handles be reported as FILEID_INVALID. > > Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> I suppose you need to move fanotify_has_object_fh() change from patch 27 here. Otherwise the change looks good so feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > fs/notify/fanotify/fanotify_user.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c > index ae848306a017..cd962deefeb7 100644 > --- a/fs/notify/fanotify/fanotify_user.c > +++ b/fs/notify/fanotify/fanotify_user.c > @@ -339,9 +339,6 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh, > pr_debug("%s: fh_len=%zu name_len=%zu, info_len=%zu, count=%zu\n", > __func__, fh_len, name_len, info_len, count); > > - if (!fh_len) > - return 0; > - > if (WARN_ON_ONCE(len < sizeof(info) || len > count)) > return -EFAULT; > > @@ -376,6 +373,11 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh, > > handle.handle_type = fh->type; > handle.handle_bytes = fh_len; > + > + /* Mangle handle_type for bad file_handle */ > + if (!fh_len) > + handle.handle_type = FILEID_INVALID; > + > if (copy_to_user(buf, &handle, sizeof(handle))) > return -EFAULT; > > -- > 2.33.0 >
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index ae848306a017..cd962deefeb7 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -339,9 +339,6 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh, pr_debug("%s: fh_len=%zu name_len=%zu, info_len=%zu, count=%zu\n", __func__, fh_len, name_len, info_len, count); - if (!fh_len) - return 0; - if (WARN_ON_ONCE(len < sizeof(info) || len > count)) return -EFAULT; @@ -376,6 +373,11 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh, handle.handle_type = fh->type; handle.handle_bytes = fh_len; + + /* Mangle handle_type for bad file_handle */ + if (!fh_len) + handle.handle_type = FILEID_INVALID; + if (copy_to_user(buf, &handle, sizeof(handle))) return -EFAULT;
Non-inode errors will reported with an empty file_handle. In preparation for that, allow some events to print the FID record even if there isn't any file_handle encoded Even though FILEID_ROOT is used internally, make zero-length file handles be reported as FILEID_INVALID. Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> --- fs/notify/fanotify/fanotify_user.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)