lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Thu, 19 Jul 2007 00:05:19 +0200
From:	Johannes Berg <johannes@...solutions.net>
To:	David Miller <davem@...emloft.net>
Cc:	Patrick McHardy <kaber@...sh.net>, netdev <netdev@...r.kernel.org>,
	jamal <hadi@...erus.ca>
Subject: [PATCH] enforce generic netlink multicast group API

This patch changes genlmsg_multicast() to take a struct
genl_multicast_group * instead of the ID, that way users are forced to
register a group before being able to use genlmsg_multicast().

Signed-off-by: Johannes Berg <johannes@...solutions.net>

---
Just seemed like a good idea to enforce using this API so we won't get
into any trouble with somebody using the family number as the group,
nobody noticing and then being stuck with that userspace ABI. Not sure
if it's worth it, but it doesn't really make a difference code-wise, I
guess it shouldn't even generate different code.

---
 include/net/genetlink.h |    9 +++++----
 net/netlink/genetlink.c |   10 ++++++++--
 2 files changed, 13 insertions(+), 6 deletions(-)

--- wireless-dev.orig/include/net/genetlink.h	2007-07-18 23:54:48.680937160 +0200
+++ wireless-dev/include/net/genetlink.h	2007-07-18 23:55:44.330937160 +0200
@@ -7,7 +7,7 @@
 /**
  * struct genl_multicast_group - generic netlink multicast group
  * @name: name of the multicast group, names are per-family
- * @id: multicast group ID, assigned by the core, to use with
+ * @id: multicast group ID, assigned by the core, used by
  *      genlmsg_multicast().
  * @list: list entry for linking
  * @family: pointer to family, need not be set before registering
@@ -171,13 +171,14 @@ static inline int genlmsg_cancel(struct 
  * genlmsg_multicast - multicast a netlink message
  * @skb: netlink message as socket buffer
  * @pid: own netlink pid to avoid sending to yourself
- * @group: multicast group id
+ * @group: multicast group
  * @flags: allocation flags
  */
 static inline int genlmsg_multicast(struct sk_buff *skb, u32 pid,
-				    unsigned int group, gfp_t flags)
+				    struct genl_multicast_group *group,
+				    gfp_t flags)
 {
-	return nlmsg_multicast(genl_sock, skb, pid, group, flags);
+	return nlmsg_multicast(genl_sock, skb, pid, group->id, flags);
 }
 
 /**
--- wireless-dev.orig/net/netlink/genetlink.c	2007-07-18 23:54:08.210937160 +0200
+++ wireless-dev/net/netlink/genetlink.c	2007-07-18 23:59:29.470937160 +0200
@@ -730,7 +730,7 @@ static int genl_ctrl_event(int event, vo
 		if (IS_ERR(msg))
 			return PTR_ERR(msg);
 
-		genlmsg_multicast(msg, 0, GENL_ID_CTRL, GFP_KERNEL);
+		genlmsg_multicast(msg, 0, &notify_grp, GFP_KERNEL);
 		break;
 	case CTRL_CMD_NEWMCAST_GRP:
 	case CTRL_CMD_DELMCAST_GRP:
@@ -738,7 +738,7 @@ static int genl_ctrl_event(int event, vo
 		if (IS_ERR(msg))
 			return PTR_ERR(msg);
 
-		genlmsg_multicast(msg, 0, GENL_ID_CTRL, GFP_KERNEL);
+		genlmsg_multicast(msg, 0, &notify_grp, GFP_KERNEL);
 		break;
 	}
 
@@ -754,6 +754,12 @@ static struct genl_ops genl_ctrl_ops = {
 
 static struct genl_multicast_group notify_grp = {
 	.name		= "notify",
+	/*
+	 * The ID is fixed because it is userspace ABI,
+	 * pre-assign so we already have a valid one
+	 * during registration of the controller family.
+	 */
+	.id		= GENL_ID_CTRL,
 };
 
 static int __init genl_init(void)


-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists