All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fanotify: prove that structure size is correct
@ 2014-09-28 23:35 Kees Cook
  2014-10-02 18:56 ` Heinrich Schuchardt
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2014-09-28 23:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: Eric Paris

When building with CONFIG_DEBUG_STRICT_USER_COPY_CHECKS, this copy_to_user
wasn't provably correct (the length was in a variable but the structure
wasn't). The compiler wasn't able to check that the length was being
statically assigned, so include a BUG_ON to notice if this ever changes.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 fs/notify/fanotify/fanotify_user.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index b13992a41bd9..7bdb43222875 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -216,6 +216,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
 
 	fd = fanotify_event_metadata.fd;
 	ret = -EFAULT;
+	BUG_ON(fanotify_event_metadata.event_len != FAN_EVENT_METADATA_LEN);
 	if (copy_to_user(buf, &fanotify_event_metadata,
 			 fanotify_event_metadata.event_len))
 		goto out_close_fd;
-- 
1.9.1


-- 
Kees Cook
Chrome OS Security

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

end of thread, other threads:[~2014-10-02 18:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-28 23:35 [PATCH] fanotify: prove that structure size is correct Kees Cook
2014-10-02 18:56 ` Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.