summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2009-01-09 21:02:54 +0000
committerAlexander Motin <mav@FreeBSD.org>2009-01-09 21:02:54 +0000
commitdca4357a7ab7181289bbebba9f702c83fe707677 (patch)
tree5d76843b72509ade4da0db7f545d167ebf1ac45b
parentf7e68080a6f8256df5a536b80df5f469d60934d7 (diff)
Notes
-rw-r--r--sys/netgraph/ng_base.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index 2c44a96e6e19..5c6bd2cc96ab 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -2377,19 +2377,27 @@ ng_apply_item(node_p node, item_p item, int rw)
case NGQF_FN:
case NGQF_FN2:
/*
- * We have to implicitly trust the hook,
- * as some of these are used for system purposes
- * where the hook is invalid. In the case of
- * the shutdown message we allow it to hit
+ * In the case of the shutdown message we allow it to hit
* even if the node is invalid.
*/
- if ((NG_NODE_NOT_VALID(node))
- && (NGI_FN(item) != &ng_rmnode)) {
+ if (NG_NODE_NOT_VALID(node) &&
+ NGI_FN(item) != &ng_rmnode) {
TRAP_ERROR();
error = EINVAL;
NG_FREE_ITEM(item);
break;
}
+ /* Same is about some internal functions and invalid hook. */
+ if (hook && NG_HOOK_NOT_VALID(hook) &&
+ NGI_FN2(item) != &ng_con_part2 &&
+ NGI_FN2(item) != &ng_con_part3 &&
+ NGI_FN(item) != &ng_rmhook_part2) {
+ TRAP_ERROR();
+ error = EINVAL;
+ NG_FREE_ITEM(item);
+ break;
+ }
+
if ((item->el_flags & NGQF_TYPE) == NGQF_FN) {
(*NGI_FN(item))(node, hook, NGI_ARG1(item),
NGI_ARG2(item));