From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 18 13:39:26 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C4E4106566C for ; Fri, 18 Feb 2011 13:39:26 +0000 (UTC) (envelope-from mats.w.lindberg@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id F1CBA8FC0C for ; Fri, 18 Feb 2011 13:39:25 +0000 (UTC) Received: by iwn39 with SMTP id 39so3697508iwn.13 for ; Fri, 18 Feb 2011 05:39:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=dNwKpz2655WjyYymddzqVTWWGm8D9yci/Ipq+iRyYtY=; b=BjS6bpPxJWoNTofSN7GNN4kStdVeTVB6uSfHSjv+HurHbF1dflNZXXyAcKLw/HW1g+ U+vi5R8i23TzrVK3hDoZVtKIh8edJfjodTu2vnDkmdwvUPLDXADf0pZj0zhGlbSkTD4Y VZs6rQERHC3mLdxMN7a9PKhnt0RlzLfcmNBoU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=TVzUuED78n2UlrtZZFPJQmE4IpomrNZoB+H9RUOcY1vHZLpeiv45ARC49yQ7d0J7u+ MoSbo3OOBWUUmMSyFVAal1r4cCKgs6J7bSYvf4UOtRUIRoaSckXmdBqjAsACtTCtsYU3 s7gejPFTh5tdAZyP7sAeYQ+XCu/VDSXb/PvdY= MIME-Version: 1.0 Received: by 10.231.206.1 with SMTP id fs1mr506903ibb.193.1298036365270; Fri, 18 Feb 2011 05:39:25 -0800 (PST) Received: by 10.231.13.73 with HTTP; Fri, 18 Feb 2011 05:39:17 -0800 (PST) In-Reply-To: References: Date: Fri, 18 Feb 2011 14:39:17 +0100 Message-ID: From: Mats Lindberg To: Sergey Kandaurov Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org Subject: Re: sched_setscheduler() behaviour changed?? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Feb 2011 13:39:26 -0000 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 > On 17 February 2011 12:50, Mats Lindberg > 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 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 >