From nobody@FreeBSD.org  Mon Jul 15 12:09:15 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 1EC5B37B400
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Jul 2002 12:09:15 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id D1CA443E42
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Jul 2002 12:09:14 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g6FJ9EOT072746
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 15 Jul 2002 12:09:14 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g6FJ9E6Q072745;
	Mon, 15 Jul 2002 12:09:14 -0700 (PDT)
Message-Id: <200207151909.g6FJ9E6Q072745@www.freebsd.org>
Date: Mon, 15 Jul 2002 12:09:14 -0700 (PDT)
From: Shannon -jj Behrens <jj@nttmcl.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [PATCH] linux JRE 1.4 under linux compatibility only runs as root (kernel patch)
X-Send-Pr-Version: www-1.0

>Number:         40611
>Category:       kern
>Synopsis:       [PATCH] linux JRE 1.4 under linux compatibility only runs as root (kernel patch)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 15 12:10:04 PDT 2002
>Closed-Date:    Wed Mar 26 14:10:59 PST 2003
>Last-Modified:  Wed Mar 26 14:10:59 PST 2003
>Originator:     Shannon -jj Behrens
>Release:        FreeBSD STABLE
>Organization:
NTT MCL, INC.
>Environment:
FreeBSD udp.nttmcl.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Tue Apr 23 18:14:15 PDT 2002 root@udp.nttmcl.com:/usr/obj/usr/src/sys/GENERIC i386
>Description:
Due to permissions checking in linux_sched_getscheduler, the linux JRE 1.4 will only run as root.  Some users on the FreeBSD-java mailing list feel that the permissions checking in linux_sched_getscheduler are far too strict. Don Bowman <don@sandvine.com> has submitted the following patch. 
>How-To-Repeat:
Install the port linux-sun-jdk14 on a system that does not have linux_base-6 installed (note, linux_base-6 is not susceptible to this problem).  linux_base will be installed as a dependency.  Now, try to run any of the Java binaries.  All of them will throw a Java exception.
>Fix:
Here is the email from Don Bowman, including his patch.

<http://docs.freebsd.org/cgi/getmsg.cgi?fetch=132728+0+archive/2002/freebsd-java/20020714.freebsd-java>

According to the following email, both sched_getscheduler and sched_getparam need to be patched, but the patch does indeed work.

<http://docs.freebsd.org/cgi/getmsg.cgi?fetch=168075+0+archive/2002/freebsd-java/20020714.freebsd-java>
>Release-Note:
>Audit-Trail:

From: Shannon -jj Behrens <jj@nttmcl.com>
To: freebsd-gnats-submit@FreeBSD.org, jj@nttmcl.com
Cc:  
Subject: Re: kern/40611: [PATCH] linux JRE 1.4 under linux compatibility only runs as root (kernel patch)
Date: Tue, 16 Jul 2002 10:07:14 -0700

 Here is an updated patch from Antony T Curtis <antony.t.curtis@ntlworld.com>.
 It was applied to his 4.6-STABLE system.
 
 --- p1003_1b.c.orig     Thu Aug  3 02:09:59 2000
 +++ p1003_1b.c  Fri Jul 12 21:44:24 2002
 @@ -178,15 +178,22 @@
   int sched_getparam(struct proc *p,
          struct sched_getparam_args *uap)
   {
 -       int e;
 +       int e = 0;
 +       struct proc *targetp;
          struct sched_param sched_param;
 
 -       (void) (0
 -       || (e = p31b_proc(p, uap->pid, &p))
 -       || (e = ksched_getparam(&p->p_retval[0], ksched, p, &sched_param))
 -       );
 +       if (uap->pid == 0) {
 +               targetp = p;
 +       } else {
 +               targetp = pfind(uap->pid);
 +               if (targetp == NULL)
 +                       e = ESRCH;
 +       }
 +
 +       if (e == 0)
 +               e = ksched_getparam(&p->p_retval[0], ksched, targetp, 
 &sched_param);
 
 -       if (!e)
 +       if (e == 0)
                  copyout(&sched_param, uap->param, sizeof(sched_param));
 
          return e;
 @@ -211,13 +218,21 @@
   int sched_getscheduler(struct proc *p,
          struct sched_getscheduler_args *uap)
   {
 -       int e;
 -       (void) (0
 -       || (e = p31b_proc(p, uap->pid, &p))
 -       || (e = ksched_getscheduler(&p->p_retval[0], ksched, p))
 -       );
 +       int e = 0;
 +       struct proc *targetp;
 
 -       return e;
 +       if (uap->pid == 0) {
 +               targetp = p;
 +       } else {
 +               targetp = pfind(uap->pid);
 +               if (targetp == NULL)
 +                       e = ESRCH;
 +       }
 +
 +       if (e == 0)
 +               e = ksched_getscheduler(&p->p_retval[0], ksched, targetp);
 +
 +       return (e);
   }
   int sched_yield(struct proc *p,
          struct sched_yield_args *uap)

From: "Ulrich 'Q' Spoerlein" <q@uni.de>
To: freebsd-gnats-submit@FreeBSD.org, jj@nttmcl.com
Cc:  
Subject: Re: kern/40611: [PATCH] linux JRE 1.4 under linux compatibility only runs as root (kernel patch)
Date: Wed, 13 Nov 2002 23:36:27 +0100

 this patch works fine for me. thanks!
State-Changed-From-To: open->closed 
State-Changed-By: mbr 
State-Changed-When: Wed Mar 26 14:10:16 PST 2003 
State-Changed-Why:  
A similar patch has been committed in Rev. 1.5.2.2 of src/sys/posix4/p1003_1b.c 
and the jdk will not crash anymore in 4.8R. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=40611 
>Unformatted:
