netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netlink: introduce NLA_BINARY type
@ 2007-03-23 15:02 Johannes Berg
  2007-03-23 15:13 ` Thomas Graf
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2007-03-23 15:02 UTC (permalink / raw)
  To: David S. Miller; +Cc: Thomas Graf, netdev

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 <johannes@sipsolutions.net>
Cc: Thomas Graf <tgraf@suug.ch>
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.h	2007-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 other            Exact 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.c	2007-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;



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

end of thread, other threads:[~2007-03-23 18:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-23 15:02 [PATCH] netlink: introduce NLA_BINARY type Johannes Berg
2007-03-23 15:13 ` Thomas Graf
2007-03-23 18:38   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).