selinux: properly handle multiple messages in selinux_netlink_send()

commit fb73974172ffaaf57a7c42f35424d9aece1a5af6 upstream.

Fix the SELinux netlink_send hook to properly handle multiple netlink
messages in a single sk_buff; each message is parsed and subject to
SELinux access control.  Prior to this patch, SELinux only inspected
the first message in the sk_buff.

Cc: stable@vger.kernel.org
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Issue: SEC-2533
Change-Id: I47dcc54d87f0c879b406b476aa725807f4dd1d23
(cherry picked from commit 9592b90cdc99f58e0674e64037c422ea7e9aa367)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 8ed60ce..2b0ec17 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -84,6 +84,7 @@
 #include <linux/msg.h>
 #include <linux/shm.h>
 #include <linux/pft.h>
+#include <linux/ratelimit.h>
 
 #include "avc.h"
 #include "objsec.h"