PERFORCE change 163589 for review

Edward Tomasz Napierala trasz at FreeBSD.org
Fri Jun 5 17:36:21 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=163589

Change 163589 by trasz at trasz_victim on 2009/06/05 17:36:05

	In setrlimit(2), the 'max' limit doesn't enforce anything other than
	the 'soft' limit.  No point in putting it into hrl.

Affected files ...

.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#3 edit

Differences ...

==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#3 (text+ko) ====

@@ -646,7 +646,7 @@
 static void
 hrl_handle_setrlimit(u_int which, struct rlimit *lim, struct thread *td)
 {
-	int object, subject, soft_action, hard_action;
+	int object, subject, action = -1;
 	id_t id;
 
 	/*
@@ -654,13 +654,11 @@
 	 */
 	subject = HRL_SUBJECT_PROCESS;
 	id = td->td_proc->p_pid;
-	soft_action = HRL_ACTION_LOG;
-	hard_action = HRL_ACTION_DENY;
 
 	switch (which) {
 	case RLIMIT_CPU:
 		object = HRL_OBJECT_CPUTIME;
-		soft_action = HRL_ACTION_SIGXCPU;
+		action = HRL_ACTION_SIGXCPU;
 		break;
 	case RLIMIT_FSIZE:
 		object = HRL_OBJECT_FILESIZE;
@@ -670,7 +668,7 @@
 		break;
 	case RLIMIT_STACK:
 		object = HRL_OBJECT_STACKSIZE;
-		soft_action = HRL_ACTION_SIGSEGV;
+		action = HRL_ACTION_SIGSEGV;
 		break;
 	case RLIMIT_CORE:
 		object = HRL_OBJECT_COREDUMPSIZE;
@@ -688,7 +686,7 @@
 		break;
 	case RLIMIT_NOFILE:
 		object = HRL_OBJECT_OPENFILES;
-		soft_action = HRL_ACTION_SIGXFSZ;
+		action = HRL_ACTION_SIGXFSZ;
 		break;
 	case RLIMIT_SBSIZE:
 		object = HRL_OBJECT_SBSIZE;
@@ -707,16 +705,17 @@
 		panic("hrl_handle_setrlimit: unknown limit");
 	}
 
-	if (lim->rlim_cur != RLIM_INFINITY)
-		hrl_adjust(subject, id, subject, object, soft_action,
+	if (lim->rlim_cur != RLIM_INFINITY) {
+		hrl_adjust(subject, id, subject, object, HRL_ACTION_DENY,
 		    lim->rlim_cur);
-	else
-		hrl_adjust(subject, id, subject, object, soft_action, 0);
-	if (lim->rlim_max != RLIM_INFINITY)
-		hrl_adjust(subject, id, subject, object, hard_action,
-		    lim->rlim_max);
-	else
-		hrl_adjust(subject, id, subject, object, hard_action, 0);
+		if (action != -1)
+			hrl_adjust(subject, id, subject, object, action,
+			    lim->rlim_cur);
+	} else {
+		hrl_adjust(subject, id, subject, object, HRL_ACTION_DENY, 0);
+		if (action != -1)
+			hrl_adjust(subject, id, subject, object, action, 0);
+	}
 }
 
 int


More information about the p4-projects mailing list