fanotify: Ensure consistent variable type for response
Subsystems (3)
PATCH 1/3 fanotify: Ensure consistent variable type for response
The user space API for the response variable is __u32. This patch makes sure that the whole path through the kernel uses __u32 so that there is no sign extension or truncation of the user space response.
Signed-off-by Steve Grubb <[email protected]>
--- fs/notify/fanotify/fanotify.h | 2 +- fs/notify/fanotify/fanotify_user.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
fs/notify/fanotify/fanotify.h +1 -1
@@ -165,7 +165,7 @@ FANOTIFY_PE(struct fanotify_event *event)struct fanotify_perm_event {struct fanotify_event fae;struct path path; -unsigned short response;/* userspace answer to the event */ +__u32 response;/* userspace answer to the event */ unsigned short state;/* state of the event */ int fd;/* fd we passed to userspace for this event */ };
fs/notify/fanotify/fanotify_user.c +2 -2
@@ -157,7 +157,7 @@ static int create_fd(struct fsnotify_group *group, struct path *path,*/ static void finish_permission_event (struct fsnotify_group *group,struct fanotify_perm_event *event, -unsigned int response) +__u32 response) __releases(&group->notification_lock) {bool destroy = false;
@@ -178,7 +178,7 @@ static int process_access_response(struct fsnotify_group *group, {struct fanotify_perm_event *event;int fd = response_struct->fd; -int response = response_struct->response; +__u32 response = response_struct->response;pr_debug ("%s: group=%p fd=%d response=%d\n" , __func__, group, fd, response);
Signature · 1 line
2.26.2
Jan Kara
maintainerQuoted 9 lines · Steve Grubb
The user space API for the response variable is
__u32. This patch makes sure that the whole path through the kernel uses__u32so that there is no sign extension or truncation of the user space response.Signed-off-by Steve Grubb <[email protected]>--- fs/notify/fanotify/fanotify.h | 2 +- fs/notify/fanotify/fanotify_user.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Looks good, just one nit below:
Quoted 14 lines
fs/notify/fanotify/fanotify_user.c +1
-1@@ -157,7 +157,7 @@ static int create_fd(struct fsnotify_group *group, struct path *path,*/ static void finish_permission_event (struct fsnotify_group *group,struct fanotify_perm_event *event, -unsigned int response) +__u32 response) __releases(&group->notification_lock) {bool destroy = false;
fs/notify/fanotify/fanotify_user.c static int process_access_response(struct fsnotify_group *group, · line 184
Quoted 8 lines
fs/notify/fanotify/fanotify_user.c +1
-1@@ -178,7 +178,7 @@ static int process_access_response(struct fsnotify_group *group, {struct fanotify_perm_event *event;int fd = response_struct->fd; -int response = response_struct->response; +__u32 response = response_struct->response;pr_debug ("%s: group=%p fd=%d response=%d\n" , __func__, group, fd, response);
You want to print the response with "%u" here I guess...
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR