PERFORCE change 188276 for review
Edward Tomasz Napierala
trasz at FreeBSD.org
Fri Jan 28 19:24:30 UTC 2011
http://p4web.freebsd.org/@@188276?ac=10
Change 188276 by trasz at trasz_victim on 2011/01/28 19:23:53
Instead of supporting only a few arbitrarily chosen signals
for the "action" field, support all of them.
Affected files ...
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_rctl.c#21 edit
.. //depot/projects/soc2009/trasz_limits/sys/sys/rctl.h#10 edit
Differences ...
==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_rctl.c#21 (text+ko) ====
@@ -123,14 +123,39 @@
{ NULL, -1 }};
static struct dict actionnames[] = {
- { "deny", RCTL_ACTION_DENY },
- { "log", RCTL_ACTION_LOG },
{ "sighup", RCTL_ACTION_SIGHUP },
{ "sigint", RCTL_ACTION_SIGINT },
+ { "sigquit", RCTL_ACTION_SIGQUIT },
+ { "sigill", RCTL_ACTION_SIGILL },
+ { "sigtrap", RCTL_ACTION_SIGTRAP },
+ { "sigabrt", RCTL_ACTION_SIGABRT },
+ { "sigemt", RCTL_ACTION_SIGEMT },
+ { "sigfpe", RCTL_ACTION_SIGFPE },
{ "sigkill", RCTL_ACTION_SIGKILL },
+ { "sigbus", RCTL_ACTION_SIGBUS },
{ "sigsegv", RCTL_ACTION_SIGSEGV },
+ { "sigsys", RCTL_ACTION_SIGSYS },
+ { "sigpipe", RCTL_ACTION_SIGPIPE },
+ { "sigalrm", RCTL_ACTION_SIGALRM },
+ { "sigterm", RCTL_ACTION_SIGTERM },
+ { "sigurg", RCTL_ACTION_SIGURG },
+ { "sigstop", RCTL_ACTION_SIGSTOP },
+ { "sigtstp", RCTL_ACTION_SIGTSTP },
+ { "sigchld", RCTL_ACTION_SIGCHLD },
+ { "sigttin", RCTL_ACTION_SIGTTIN },
+ { "sigttou", RCTL_ACTION_SIGTTOU },
+ { "sigio", RCTL_ACTION_SIGIO },
{ "sigxcpu", RCTL_ACTION_SIGXCPU },
{ "sigxfsz", RCTL_ACTION_SIGXFSZ },
+ { "sigvtalrm", RCTL_ACTION_SIGVTALRM },
+ { "sigprof", RCTL_ACTION_SIGPROF },
+ { "sigwinch", RCTL_ACTION_SIGWINCH },
+ { "siginfo", RCTL_ACTION_SIGINFO },
+ { "sigusr1", RCTL_ACTION_SIGUSR1 },
+ { "sigusr2", RCTL_ACTION_SIGUSR2 },
+ { "sigthr", RCTL_ACTION_SIGTHR },
+ { "deny", RCTL_ACTION_DENY },
+ { "log", RCTL_ACTION_LOG },
{ NULL, -1 }};
static void rctl_init(void);
@@ -306,27 +331,18 @@
sbuf_delete(&sb);
free(buf, M_RCTL);
continue;
- case RCTL_ACTION_SIGHUP:
- psignal(p, SIGHUP);
- continue;
- case RCTL_ACTION_SIGINT:
- psignal(p, SIGINT);
+ default:
+ KASSERT(rule->rr_action > 0 &&
+ rule->rr_action <= RCTL_ACTION_SIGNAL_MAX,
+ ("rctl_enforce: unknown action %d",
+ rule->rr_action));
+
+ /*
+ * We're using the fact that RCTL_ACTION_SIG* values
+ * are equal to their counterparts from sys/signal.h.
+ */
+ psignal(p, rule->rr_action);
continue;
- case RCTL_ACTION_SIGKILL:
- psignal(p, SIGKILL);
- continue;
- case RCTL_ACTION_SIGSEGV:
- psignal(p, SIGSEGV);
- continue;
- case RCTL_ACTION_SIGXCPU:
- psignal(p, SIGXCPU);
- continue;
- case RCTL_ACTION_SIGXFSZ:
- psignal(p, SIGXFSZ);
- continue;
- default:
- panic("rctl_enforce: unknown action %d",
- rule->rr_action);
}
}
==== //depot/projects/soc2009/trasz_limits/sys/sys/rctl.h#10 (text+ko) ====
@@ -95,30 +95,56 @@
*/
#define RCTL_ACTION_UNDEFINED -1
-#define RCTL_ACTION_DENY 0x0000
-#define RCTL_ACTION_LOG 0x0002
-#define RCTL_ACTION_SIGHUP 0x0003
-#define RCTL_ACTION_SIGINT 0x0004
-#define RCTL_ACTION_SIGKILL 0x0005
-#define RCTL_ACTION_SIGSEGV 0x0006
-#define RCTL_ACTION_SIGXCPU 0x0007
-#define RCTL_ACTION_SIGXFSZ 0x0008
-#define RCTL_ACTION_MAX RCTL_ACTION_SIGXFSZ
+#define RCTL_ACTION_SIGHUP SIGHUP
+#define RCTL_ACTION_SIGINT SIGINT
+#define RCTL_ACTION_SIGQUIT SIGQUIT
+#define RCTL_ACTION_SIGILL SIGILL
+#define RCTL_ACTION_SIGTRAP SIGTRAP
+#define RCTL_ACTION_SIGABRT SIGABRT
+#define RCTL_ACTION_SIGEMT SIGEMT
+#define RCTL_ACTION_SIGFPE SIGFPE
+#define RCTL_ACTION_SIGKILL SIGKILL
+#define RCTL_ACTION_SIGBUS SIGBUS
+#define RCTL_ACTION_SIGSEGV SIGSEGV
+#define RCTL_ACTION_SIGSYS SIGSYS
+#define RCTL_ACTION_SIGPIPE SIGPIPE
+#define RCTL_ACTION_SIGALRM SIGALRM
+#define RCTL_ACTION_SIGTERM SIGTERM
+#define RCTL_ACTION_SIGURG SIGURG
+#define RCTL_ACTION_SIGSTOP SIGSTOP
+#define RCTL_ACTION_SIGTSTP SIGTSTP
+#define RCTL_ACTION_SIGCHLD SIGCHLD
+#define RCTL_ACTION_SIGTTIN SIGTTIN
+#define RCTL_ACTION_SIGTTOU SIGTTOU
+#define RCTL_ACTION_SIGIO SIGIO
+#define RCTL_ACTION_SIGXCPU SIGXCPU
+#define RCTL_ACTION_SIGXFSZ SIGXFSZ
+#define RCTL_ACTION_SIGVTALRM SIGVTALRM
+#define RCTL_ACTION_SIGPROF SIGPROF
+#define RCTL_ACTION_SIGWINCH SIGWINCH
+#define RCTL_ACTION_SIGINFO SIGINFO
+#define RCTL_ACTION_SIGUSR1 SIGUSR1
+#define RCTL_ACTION_SIGUSR2 SIGUSR2
+#define RCTL_ACTION_SIGTHR SIGTHR
+#define RCTL_ACTION_SIGNAL_MAX RCTL_ACTION_SIGTHR
+#define RCTL_ACTION_DENY (RCTL_ACTION_SIGNAL_MAX + 1)
+#define RCTL_ACTION_LOG (RCTL_ACTION_SIGNAL_MAX + 2)
+#define RCTL_ACTION_MAX RCTL_ACTION_LOG
#define RCTL_AMOUNT_UNDEFINED -1
void rctl_proc_ucred_changed(struct proc *p, struct ucred *newcred);
-struct rctl_rule *rctl_rule_alloc(int flags);
-struct rctl_rule *rctl_rule_duplicate(const struct rctl_rule *rule, int flags);
+struct rctl_rule *rctl_rule_alloc(int flags);
+struct rctl_rule *rctl_rule_duplicate(const struct rctl_rule *rule, int flags);
void rctl_rule_acquire(struct rctl_rule *rule);
void rctl_rule_release(struct rctl_rule *rule);
int rctl_rule_add(struct rctl_rule *rule);
int rctl_rule_remove(struct rctl_rule *filter);
int rctl_enforce(struct proc *p, int resource, uint64_t amount);
-uint64_t rctl_get_limit(struct proc *p, int resource);
-uint64_t rctl_get_available(struct proc *p, int resource);
-const char *rctl_resource_name(int resource);
+uint64_t rctl_get_limit(struct proc *p, int resource);
+uint64_t rctl_get_available(struct proc *p, int resource);
+const char *rctl_resource_name(int resource);
int rctl_proc_fork(struct proc *parent, struct proc *child);
void rctl_proc_exit(struct proc *p);
#else /* !_KERNEL */
More information about the p4-projects
mailing list