Re: [Regression] 2.6.24-git9: RT sched mishandles artswrapper (bisected)

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Rafael J. Wysocki
Date: Tuesday, February 5, 2008 - 6:21 pm

On Tuesday, 5 of February 2008, Dmitry Adamushko wrote:

Well, instead please find appended a test program that allows me to trigger
the issue.

To reproduce it do:

$ gcc -o break_scheduler break_scheduler.c
$ su -
[...]
# chown root.root $PATH_TO_BINARY/break_scheduler
# chmod u+s $PATH_TO_BINARY/break_scheduler
^D
$ ./break_scheduler

It behaves normally if run directly by root and it also behaves normally if
the execv() at the end is removed.

Hope that helps to understand what the problem is.

Thanks,
Rafael

---
#include <stdio.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <sched.h>

#define EXECUTE "/bin/ls"

void adjust_priority()
{
	int sched = sched_getscheduler(0);

	if(sched == SCHED_FIFO || sched == SCHED_RR) {
		puts(">> non-standard scheduling policy");
	} else {
		struct sched_param sp;
		long int priority = (sched_get_priority_max(SCHED_FIFO) +
			             sched_get_priority_min(SCHED_FIFO))/2;
		
		sp.sched_priority = priority;

		if (sched_setscheduler(0, SCHED_FIFO, &sp) != -1) {
			printf(">> running as realtime process now "
				"(priority %ld)\n", priority);
		} else {
			/* can't set realtime priority */
			puts(">> could not set realtime priority");
		}
	}
}

int main(int argc, char **argv)
{
	adjust_priority();

	/* drop root privileges if running setuid root
	   (due to realtime priority stuff) */
	if (geteuid() != getuid()) {
		seteuid(getuid());
		if (geteuid() != getuid()) {
			perror("setuid()");
			return 2;
		}
	}

	puts("OK");

	if(argc == 0)
		return 1;

	argv[0] = EXECUTE;
	execv(EXECUTE, argv);
	perror(EXECUTE);

	return 0;
}
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[Regression] 2.6.24-git9: RT sched mishandles artswrapper ..., Rafael J. Wysocki, (Thu Jan 31, 6:37 pm)
Re: [Regression] 2.6.24-git9: RT sched mishandles artswrap ..., Rafael J. Wysocki, (Thu Jan 31, 7:04 pm)
Re: [Regression] 2.6.24-git9: RT sched mishandles artswrap ..., Rafael J. Wysocki, (Tue Feb 5, 6:21 pm)