netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: paul.moore@hp.com
To: netdev@vger.kernel.org, selinux@tycho.nsa.gov
Cc: tgraf@suug.ch, jmorris@redhat.com, sds@epoch.ncsc.mil,
	Paul Moore <paul.moore@hp.com>
Subject: [PATCH v2 5/8] Netlink: add nla_validate_nested()
Date: Mon, 25 Sep 2006 14:04:17 -0400	[thread overview]
Message-ID: <20060925180642.032407000@hp.com> (raw)
In-Reply-To: 20060925180412.715069000@hp.com

[-- Attachment #1: netlink-new_nlattr_iface --]
[-- Type: text/plain, Size: 1755 bytes --]

Add a new function, nla_validate_nested(), to validate nested Netlink
attributes.

Signed-off-by: Paul Moore <paul.moore@hp.com>
---
 include/net/netlink.h |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+)

Index: net-2.6.19/include/net/netlink.h
===================================================================
--- net-2.6.19.orig/include/net/netlink.h
+++ net-2.6.19/include/net/netlink.h
@@ -146,6 +146,7 @@
  *   nla_ok(nla, remaining)		does nla fit into remaining bytes?
  *   nla_next(nla, remaining)		get next netlink attribute
  *   nla_validate()			validate a stream of attributes
+ *   nla_validate_nested()		validate a stream of nested attributes
  *   nla_find()				find attribute in stream of attributes
  *   nla_find_nested()			find attribute in nested attributes
  *   nla_parse()			parse and validate stream of attrs
@@ -951,6 +952,24 @@ static inline int nla_nest_cancel(struct
 }
 
 /**
+ * nla_validate_nested - Validate a stream of nested attributes
+ * @start: container attribute
+ * @maxtype: maximum attribute type to be expected
+ * @policy: validation policy
+ *
+ * Validates all attributes in the nested attribute stream against the
+ * specified policy. Attributes with a type exceeding maxtype will be
+ * ignored. See documenation of struct nla_policy for more details.
+ *
+ * Returns 0 on success or a negative error code.
+ */
+static inline int nla_validate_nested(struct nlattr *start, int maxtype,
+				      struct nla_policy *policy)
+{
+	return nla_validate(nla_data(start), nla_len(start), maxtype, policy);
+}
+
+/**
  * nla_for_each_attr - iterate over a stream of attributes
  * @pos: loop counter, set to current attribute
  * @head: head of attribute stream

--
paul moore
linux security @ hp

  parent reply	other threads:[~2006-09-25 18:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-25 18:04 [PATCH v2 0/8] Updated patchset with Thomas' comments paul.moore
2006-09-25 18:04 ` [PATCH v2 1/8] NetLabel: correct improper handling of non-NetLabel peer contexts paul.moore
2006-09-25 18:04 ` [PATCH v2 2/8] NetLabel: make the CIPSOv4 cache spinlocks bottom half safe paul.moore
2006-09-25 18:04 ` [PATCH v2 3/8] NetLabel: change the SELinux permissions paul.moore
2006-09-25 18:04 ` [PATCH v2 4/8] Netlink: add nla_for_each_nested() to the interface list paul.moore
2006-09-25 18:04 ` paul.moore [this message]
2006-09-25 18:04 ` [PATCH v2 6/8] NetLabel: rework the Netlink attribute handling (part 1) paul.moore
2006-09-25 18:04 ` [PATCH v2 7/8] NetLabel: rework the Netlink attribute handling (part 2) paul.moore
2006-09-25 18:04 ` [PATCH v2 8/8] NetLabel: update docs with website information paul.moore
2006-09-25 19:18 ` [PATCH v2 0/8] Updated patchset with Thomas' comments James Morris
2006-09-25 21:06 ` Thomas Graf
2006-09-25 22:57 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060925180642.032407000@hp.com \
    --to=paul.moore@hp.com \
    --cc=jmorris@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=sds@epoch.ncsc.mil \
    --cc=selinux@tycho.nsa.gov \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).