[Devel,4/5] netlink: skip pktinfo scm if a sender group is less than 32

Submitted by Andrei Vagin on Feb. 19, 2017, 6:58 a.m.

Details

Message ID 1487487496-12063-5-git-send-email-avagin@openvz.org
State New
Series "A few fixes for netlink sockets"
Headers show

Commit Message

Andrei Vagin Feb. 19, 2017, 6:58 a.m.
From: Andrei Vagin <avagin@virtuozzo.com>

nl_pktinfo control messages is used to  get the extended
destination group number.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
---
 criu/sk-queue.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/sk-queue.c b/criu/sk-queue.c
index 88e47b8..8124f75 100644
--- a/criu/sk-queue.c
+++ b/criu/sk-queue.c
@@ -10,6 +10,7 @@ 
 #include <sys/socket.h>
 #include <sys/sendfile.h>
 #include <linux/socket.h>
+#include <linux/netlink.h>
 
 #include "common/list.h"
 #include "imgset.h"
@@ -127,6 +128,18 @@  static int dump_packet_cmsg(struct msghdr *mh, SkPacketEntry *pe, int flags)
 				return -1;
 			continue;
 		}
+		if (ch->cmsg_level == SOL_NETLINK &&
+		    ch->cmsg_type == NETLINK_PKTINFO &&
+		    ch->cmsg_len == CMSG_LEN(sizeof(struct nl_pktinfo))) {
+			struct nl_pktinfo *info = CMSG_DATA(ch);
+
+			/* Groups less than 32 are returned in msg_address */
+			if (info->group < 32)
+				continue;
+
+			pr_err("A sender group %d isn't supported\n", info->group);
+			return -1;
+		}
 		pr_err("cmsg: len %ld type %d level %d\n",
 			ch->cmsg_len, ch->cmsg_type, ch->cmsg_level);
 		pr_err("Control messages in queue, not supported\n");