Skip to content

Commit 1734dee

Browse files
LinoSanfilippo333eparis
authored andcommitted
fanotify: Dont allow a mask of 0 if setting or removing a mark
In mark_remove_from_mask() we destroy marks that have their event mask cleared. Thus we should not allow the creation of those marks in the first place. With this patch we check if the mask given from user is 0 in case of FAN_MARK_ADD. If so we return an error. Same for FAN_MARK_REMOVE since this does not have any effect. Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de> Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent fa218ab commit 1734dee

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/notify/fanotify/fanotify_user.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,8 +769,10 @@ SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags,
769769
if (flags & ~FAN_ALL_MARK_FLAGS)
770770
return -EINVAL;
771771
switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_FLUSH)) {
772-
case FAN_MARK_ADD:
772+
case FAN_MARK_ADD: /* fallthrough */
773773
case FAN_MARK_REMOVE:
774+
if (!mask)
775+
return -EINVAL;
774776
case FAN_MARK_FLUSH:
775777
break;
776778
default:

0 commit comments

Comments
 (0)