[PATCH] netlink: introduce NLA_BINARY type

2007-03-23 Thread Johannes Berg
This patch introduces a new NLA_BINARY attribute policy type with the
verification of simply checking the maximum length of the payload.

It also fixes a small typo in the example.

Signed-off-by: Johannes Berg [EMAIL PROTECTED]
Cc: Thomas Graf [EMAIL PROTECTED]
Cc: netdev@vger.kernel.org

---
 include/net/netlink.h |4 +++-
 net/netlink/attr.c|5 +
 2 files changed, 8 insertions(+), 1 deletion(-)

--- linux-2.6.orig/include/net/netlink.h2007-03-23 15:45:52.932598534 
+0100
+++ linux-2.6/include/net/netlink.h 2007-03-23 15:46:25.962598534 +0100
@@ -171,6 +171,7 @@ enum {
NLA_MSECS,
NLA_NESTED,
NLA_NUL_STRING,
+   NLA_BINARY,
__NLA_TYPE_MAX,
 };
 
@@ -188,12 +189,13 @@ enum {
  *NLA_STRING   Maximum length of string
  *NLA_NUL_STRING   Maximum length of string (excluding NUL)
  *NLA_FLAG Unused
+ *NLA_BINARY   Maximum length of attribute payload
  *All otherExact length of attribute payload
  *
  * Example:
  * static struct nla_policy my_policy[ATTR_MAX+1] __read_mostly = {
  * [ATTR_FOO] = { .type = NLA_U16 },
- * [ATTR_BAR] = { .type = NLA_STRING, len = BARSIZ },
+ * [ATTR_BAR] = { .type = NLA_STRING, .len = BARSIZ },
  * [ATTR_BAZ] = { .len = sizeof(struct mystruct) },
  * };
  */
--- linux-2.6.orig/net/netlink/attr.c   2007-03-23 15:46:53.112598534 +0100
+++ linux-2.6/net/netlink/attr.c2007-03-23 15:48:12.902598534 +0100
@@ -67,6 +67,11 @@ static int validate_nla(struct nlattr *n
}
break;
 
+   case NLA_BINARY:
+   if (pt-len  attrlen  pt-len)
+   return -ERANGE;
+   break;
+
default:
if (pt-len)
minlen = pt-len;


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


Re: [PATCH] netlink: introduce NLA_BINARY type

2007-03-23 Thread Thomas Graf
* Johannes Berg [EMAIL PROTECTED] 2007-03-23 16:02
 This patch introduces a new NLA_BINARY attribute policy type with the
 verification of simply checking the maximum length of the payload.
 
 It also fixes a small typo in the example.
 
 Signed-off-by: Johannes Berg [EMAIL PROTECTED]
 Cc: Thomas Graf [EMAIL PROTECTED]
 Cc: netdev@vger.kernel.org

Signed-off-by: Thomas Graf [EMAIL PROTECTED]
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] netlink: introduce NLA_BINARY type

2007-03-23 Thread David Miller
From: Thomas Graf [EMAIL PROTECTED]
Date: Fri, 23 Mar 2007 16:13:24 +0100

 * Johannes Berg [EMAIL PROTECTED] 2007-03-23 16:02
  This patch introduces a new NLA_BINARY attribute policy type with the
  verification of simply checking the maximum length of the payload.
  
  It also fixes a small typo in the example.
  
  Signed-off-by: Johannes Berg [EMAIL PROTECTED]
  Cc: Thomas Graf [EMAIL PROTECTED]
  Cc: netdev@vger.kernel.org
 
 Signed-off-by: Thomas Graf [EMAIL PROTECTED]

Applied to net-2.6.22, thanks everyone.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html