This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug linuxthreads/810] New: pthread_create() doesn't fail with EPERM
- From: "nikolay dot zhuravlev at auriga dot ru" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 30 Mar 2005 14:11:57 -0000
- Subject: [Bug linuxthreads/810] New: pthread_create() doesn't fail with EPERM
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
pthread_create() doesn't fail with EPERM when
SCHED_FIFO is requested by an unprivileged process.
Tested on the following system:
$ /lib/libc.so.6
GNU C Library stable release version 2.3.2, by Roland McGrath et al.
$ uname -a
Linux 2.4.20-8smp #1 SMP Thu Mar 13 17:45:54 EST 2003 i686 i686 i386
GNU/Linux
The test is built with 'gcc -lpthread -o test test.c'
--------------------------------------------------
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <limits.h>
#define PRIO 17
pthread_t tid;
void *
thread1( void *arg )
{
pthread_exit(0);
return 0;
}
int main(int argc, char *argv[])
{
int err;
int status; /* used in pthread_join() */
struct sched_param params;
pthread_attr_t attr;
if (pthread_attr_init(&attr)) {
printf("pthread_attr_init FAILED\n");
exit(1);
}
if (pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED)) {
printf("\npthread_attr_setinheritsched FAILED\n");
(void) pthread_attr_destroy( &attr );
exit(1);
}
if (pthread_attr_setschedpolicy(&attr, SCHED_FIFO)) {
printf("\npthread_attr_setschedpolicy FAILED\n");
(void) pthread_attr_destroy( &attr );
exit(1);
}
params.sched_priority = PRIO;
if (pthread_attr_setschedparam(&attr, ¶ms)) {
printf("\npthread_attr_setschedparam FAILED\n");
(void) pthread_attr_destroy( &attr );
exit(1);
}
if ((err = pthread_create(&tid, &attr, &thread1, NULL)) != EPERM) {
printf("TEST FAILED\n");
} else {
printf("TEST OK\n");
if (err == 0 && pthread_join(tid, (void **)&status)) {
printf("pthread_join FAILED\n");
(void) pthread_cancel(tid);
exit(1);
}
}
(void) pthread_attr_destroy( &attr );
return(0);
}
-----------
Also, the test runs fine for the following configurations:
# new machine
glibc 2.3.3,
kernel 2.6.9-1.6_FC2smp
# old machine
glibc 2.2.93
kernel 2.4.18-14
--
Summary: pthread_create() doesn't fail with EPERM
Product: glibc
Version: 2.3.2
Status: NEW
Severity: normal
Priority: P2
Component: linuxthreads
AssignedTo: gotom at debian dot or dot jp
ReportedBy: nikolay dot zhuravlev at auriga dot ru
CC: glibc-bugs at sources dot redhat dot com
http://sources.redhat.com/bugzilla/show_bug.cgi?id=810
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.