Date: Fri, 18 Feb 2011 14:39:17 +0100 From: Mats Lindberg <mats.w.lindberg@gmail.com> To: Sergey Kandaurov <pluknet@gmail.com> Cc: freebsd-hackers@freebsd.org Subject: Re: sched_setscheduler() behaviour changed?? Message-ID: <AANLkTikLR=OwQtxW6R_d09r%2BYRaCj2xpO9ZmFtCoW1eS@mail.gmail.com> In-Reply-To: <AANLkTime_5XhQb4kHuJwpVHL0Kqvs7dwzdSfbzJjNQQy@mail.gmail.com> References: <AANLkTin8wCp2RUw3F=6UMx5S%2B7Ux_cDvkziLx3U4nmcf@mail.gmail.com> <AANLkTime_5XhQb4kHuJwpVHL0Kqvs7dwzdSfbzJjNQQy@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Sergey, thanks for your comment - however it was my own mistake in rt.c ... static void setSchedPolicy( int policy ) { struct sched_param schedParam = { 0 }; TRY(sched_getparam(0, &schedParam),-1); switch ( policy ) { case SCHED_RR: case SCHED_FIFO: schedParam.sched_priority = MAX(1,schedParam.sched_priority); break; default:; } TRY(sched_setscheduler(0,policy,&schedParam),-1); } ... the sched_getparam() is called in SCHED_OTHER policy, where I would get a negative or at least acceptable prio value in FBSD 5.x and 6.x in FBSD 8.1 I got 63 which of course gives me EPERM cause I'm out of range. Again thanks 2011/2/18 Sergey Kandaurov <pluknet@gmail.com> > On 17 February 2011 12:50, Mats Lindberg <mats.w.lindberg@gmail.com> > wrote: > > All, > > I have been using a small program /rt) that utilize the > sched_setscheduler() > > syscall to set the scheduling policy of a process to SCHED_RR. Been > running > > it FBSD 5.x and 6.x. Now when migrating to FBSD 8.1 I get EPERM back at > me. > > used to be able to run it like e.g. > >> ./rt -sr -p2 -- prog > > > > which started <prog> in SCHED_RR policy with priority 2. > > > > now in FBSD 8.1 I get EPERM > > > > But If I do > >> rtprio 10 ./rt -sr -p2 -- prog > > > > it I dont get EPERM. > > > > I'm always root when doing this. > > > > My problem is that I have customers that need to run their old 5.x 6.x > > applications 'as is' in 8.1 whithout changing anything. > > > > [just thinking aloud] > > Perhaps, you might have stumbled upon the change in > sched_setscheduler() restricting permission to superuser: > > src/sys/posix4/p1003_1b.c#rev1.24.2.1 > MFC revision 1.27. > Don't allow non-root user to set a scheduler policy. > > @@ -195,6 +195,10 @@ int sched_setscheduler(struct thread *td > struct thread *targettd; > struct proc *targetp; > > + /* Don't allow non root user to set a scheduler policy */ > + if (suser(td) != 0) > + return (EPERM); > + > e = copyin(uap->param, &sched_param, sizeof(sched_param)); > if (e) > return (e); > > > -- > wbr, > pluknet >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikLR=OwQtxW6R_d09r%2BYRaCj2xpO9ZmFtCoW1eS>