linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fanotify: Dont allow a mask of 0 if setting or removing a mark
@ 2010-11-22 17:46 Lino Sanfilippo
  2010-11-23 19:54 ` Eric Paris
  0 siblings, 1 reply; 2+ messages in thread
From: Lino Sanfilippo @ 2010-11-22 17:46 UTC (permalink / raw)
  To: eparis; +Cc: linux-kernel, linux-fsdevel


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>
---
 
 fs/notify/fanotify/fanotify_user.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

This patch depends on patch "on group destroy allow all waiters to bypass permission 
check" i sent on Nov 19.

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 342d22e..207cdeb 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -780,8 +780,10 @@ SYSCALL_DEFINE(fanotify_mark)(int fanotify_fd, unsigned int flags,
 	if (flags & ~FAN_ALL_MARK_FLAGS)
 		return -EINVAL;
 	switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_FLUSH)) {
-	case FAN_MARK_ADD:
+	case FAN_MARK_ADD:		/* fallthrough */
 	case FAN_MARK_REMOVE:
+		if (!mask)
+			return -EINVAL;
 	case FAN_MARK_FLUSH:
 		break;
 	default:
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fanotify: Dont allow a mask of 0 if setting or removing a mark
  2010-11-22 17:46 [PATCH] fanotify: Dont allow a mask of 0 if setting or removing a mark Lino Sanfilippo
@ 2010-11-23 19:54 ` Eric Paris
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Paris @ 2010-11-23 19:54 UTC (permalink / raw)
  To: Lino Sanfilippo; +Cc: linux-kernel, linux-fsdevel

On Mon, 2010-11-22 at 18:46 +0100, Lino Sanfilippo wrote:
> 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>

applied.  Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-23 19:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-22 17:46 [PATCH] fanotify: Dont allow a mask of 0 if setting or removing a mark Lino Sanfilippo
2010-11-23 19:54 ` Eric Paris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).