From jon@spock.org  Sun Sep 17 10:17:32 2000
Return-Path: <jon@spock.org>
Received: from spock.org (cm-24-92-52-10.nycap.rr.com [24.92.52.10])
	by hub.freebsd.org (Postfix) with ESMTP id 0358737B422
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 17 Sep 2000 10:17:32 -0700 (PDT)
Received: (from jon@localhost)
	by spock.org  serial EF600Q3T-B7F;
	Sun, 17 Sep 2000 13:17:31 -0400 (EDT)
	(envelope-from jon)
Message-Id: <200009171717.e8HHHVa70853@spock.org>
Date: Sun, 17 Sep 2000 13:17:31 -0400 (EDT)
From: Jonathan Chen <jon@spock.org>
Reply-To: jon@spock.org
To: FreeBSD-gnats-submit@freebsd.org
Subject: change to allow vm86 interrupt calls from userland
X-Send-Pr-Version: 3.2

>Number:         21329
>Category:       i386
>Synopsis:       change to allow vm86 interrupt calls from userland
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jlemon
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Sep 17 10:20:00 PDT 2000
>Closed-Date:    Mon Oct 2 06:37:52 PDT 2000
>Last-Modified:  Mon Oct 02 06:39:23 PDT 2000
>Originator:     Jonathan Chen
>Release:        FreeBSD 4.1-STABLE i386
>Organization:
>Environment:

	

>Description:
VM86 intcalls was disabled at the initial commit -- this would be nice to
have since the only way I know how to get my video card (Savage/IX) to do
X properly is through VM86 VESA int 10 calls.

>How-To-Repeat:

	

>Fix:
Index: vm86.c
===================================================================
RCS file: /export/ncvs/src/sys/i386/i386/vm86.c,v
retrieving revision 1.31
diff -u -r1.31 vm86.c
--- vm86.c	1999/10/29 18:08:35	1.31
+++ vm86.c	2000/09/17 06:58:08
@@ -701,18 +701,18 @@
 		}
 		break;
 
-#if 0
 	case VM86_INTCALL: {
 		struct vm86_intcall_args sa;
 
-		if (error = copyin(ua.sub_args, &sa, sizeof(sa)))
+		if (p->p_cred->pc_ucred->cr_uid != 0) return EPERM;
+
+		if ((error = copyin(ua.sub_args, &sa, sizeof(sa))))
 			return (error);
-		if (error = vm86_intcall(sa.intnum, &sa.vmf))
+		if ((error = vm86_intcall(sa.intnum, &sa.vmf)))
 			return (error);
 		error = copyout(&sa, ua.sub_args, sizeof(sa));
 		}
 		break;
-#endif
 
 	default:
 		error = EINVAL;

>Release-Note:
>Audit-Trail:

From: Bill Fumerola <billf@chimesnet.com>
To: Jonathan Chen <jon@spock.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: i386/21329: change to allow vm86 interrupt calls from userland
Date: Sun, 17 Sep 2000 13:31:14 -0400

 just a little style police..
 
 On Sun, Sep 17, 2000 at 01:17:31PM -0400, Jonathan Chen wrote:
 
 >  	case VM86_INTCALL: {
 >  		struct vm86_intcall_args sa;
 >  
 > -		if (error = copyin(ua.sub_args, &sa, sizeof(sa)))
 > +		if (p->p_cred->pc_ucred->cr_uid != 0) return EPERM;
 > +
 
 		if (p->p_cred->pc_ucred->cr_uid != 0)
 			return EPERM;
 
 > +		if ((error = copyin(ua.sub_args, &sa, sizeof(sa))))
 
 Gratuitous parens. Optionally, add an explicit check here (ie, != 0 or something)
 in which case the parens actually make sense.
 
 >  			return (error);
 > -		if (error = vm86_intcall(sa.intnum, &sa.vmf))
 > +		if ((error = vm86_intcall(sa.intnum, &sa.vmf)))
 
 See previous.
 
 >  			return (error);
 >  		error = copyout(&sa, ua.sub_args, sizeof(sa));
 >  		}
 >  		break;
 > -#endif
 
 Naturally, I can't give you technical feedback, just style(9) fascism. :->
 
 -- 
 Bill Fumerola - Network Architect, BOFH / Chimes, Inc.
                 billf@chimesnet.com / billf@FreeBSD.org
 
 
 
 

From: Jonathan Chen <jon@spock.org>
To: Bill Fumerola <billf@chimesnet.com>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: i386/21329: change to allow vm86 interrupt calls from userland
Date: Sun, 17 Sep 2000 13:41:10 -0400

 On Sun, Sep 17, 2000 at 01:31:14PM -0400, Bill Fumerola wrote:
 > just a little style police..
 > 
 > > +		if ((error = copyin(ua.sub_args, &sa, sizeof(sa))))
 > 
 > Gratuitous parens. Optionally, add an explicit check here (ie, != 0 or something)
 > in which case the parens actually make sense.
 
 Yes, I'm aware of what style() says, but gcc -Wall, in its brokenness,
 "suggests parentheses around assignment used as truth value".  I have no
 clue why gcc would think extra parentheses would be cool there, but I
 decided to silence gcc instead of following style() (and didn't think of
 the != 0 bit).  Anyway, this should be better:
 
 Index: sys/i386/i386/vm86.c
 ===================================================================
 RCS file: /export/ncvs/src/sys/i386/i386/vm86.c,v
 retrieving revision 1.31
 diff -u -r1.31 vm86.c
 --- sys/i386/i386/vm86.c	1999/10/29 18:08:35	1.31
 +++ sys/i386/i386/vm86.c	2000/09/17 17:37:08
 @@ -701,18 +701,18 @@
  		}
  		break;
  
 -#if 0
  	case VM86_INTCALL: {
  		struct vm86_intcall_args sa;
  
 -		if (error = copyin(ua.sub_args, &sa, sizeof(sa)))
 +		if (p->p_cred->pc_ucred->cr_uid != 0) return EPERM;
 +
 +		if (0 != (error = copyin(ua.sub_args, &sa, sizeof(sa))))
  			return (error);
 -		if (error = vm86_intcall(sa.intnum, &sa.vmf))
 +		if (0 != (error = vm86_intcall(sa.intnum, &sa.vmf)))
  			return (error);
  		error = copyout(&sa, ua.sub_args, sizeof(sa));
  		}
  		break;
 -#endif
  
  	default:
  		error = EINVAL;
 
 -- 
     (o_ 1-2-1-2-1-2-1-2-1-2-1-2-1-2-1-2-1-2-1-2-1-2-1-2-1-2-1-2-1-2 _o)
  \\\_\            Jonathan Chen              jon@spock.org           /_///
  <____)  No electrons were harmed during production of this message (____>
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

From: Bill Fumerola <billf@chimesnet.com>
To: Jonathan Chen <jon@spock.org>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: i386/21329: change to allow vm86 interrupt calls from userland
Date: Sun, 17 Sep 2000 13:43:43 -0400

 On Sun, Sep 17, 2000 at 01:41:10PM -0400, Jonathan Chen wrote:
 
 > Yes, I'm aware of what style() says, but gcc -Wall, in its brokenness,
 > "suggests parentheses around assignment used as truth value".  I have no
 > clue why gcc would think extra parentheses would be cool there, but I
 > decided to silence gcc instead of following style() (and didn't think of
 > the != 0 bit).  Anyway, this should be better:
 
 I think it's gcc's roundabout way of encouraging the practice of explicit
 checks. This makes even more sense when you get into things returning NULL
 and abusing the if(!something_that_might_be_null) case.
 
 > 
 [...]
 > -		if (error = copyin(ua.sub_args, &sa, sizeof(sa)))
 > +		if (p->p_cred->pc_ucred->cr_uid != 0) return EPERM;
 > +
 > +		if (0 != (error = copyin(ua.sub_args, &sa, sizeof(sa))))
 >  			return (error);
 > -		if (error = vm86_intcall(sa.intnum, &sa.vmf))
 > +		if (0 != (error = vm86_intcall(sa.intnum, &sa.vmf)))
 >  			return (error);
 >  		error = copyout(&sa, ua.sub_args, sizeof(sa));
 >  		}
 >  		break;
 > -#endif
 
 #1. You still need the \nreturn EPERM;
 #2. I'd put the != 0 after the call.
 
 -- 
 Bill Fumerola - Network Architect, BOFH / Chimes, Inc.
                 billf@chimesnet.com / billf@FreeBSD.org
 
 
 
 

From: Jonathan Chen <jon@spock.org>
To: Bill Fumerola <billf@chimesnet.com>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: i386/21329: change to allow vm86 interrupt calls from userland
Date: Sun, 17 Sep 2000 13:45:11 -0400

 bleah, forgot one last bit to satisfy the style(9) police... ;P
 (how many mistake can I make in one three-line patch?)
 
 Index: sys/i386/i386/vm86.c
 ===================================================================
 RCS file: /export/ncvs/src/sys/i386/i386/vm86.c,v
 retrieving revision 1.31
 diff -u -r1.31 vm86.c
 --- sys/i386/i386/vm86.c	1999/10/29 18:08:35	1.31
 +++ sys/i386/i386/vm86.c	2000/09/17 17:42:34
 @@ -701,18 +701,19 @@
  		}
  		break;
  
 -#if 0
  	case VM86_INTCALL: {
  		struct vm86_intcall_args sa;
  
 -		if (error = copyin(ua.sub_args, &sa, sizeof(sa)))
 +		if (p->p_cred->pc_ucred->cr_uid != 0)
 +			return EPERM;
 +
 +		if (0 != (error = copyin(ua.sub_args, &sa, sizeof(sa))))
  			return (error);
 -		if (error = vm86_intcall(sa.intnum, &sa.vmf))
 +		if (0 != (error = vm86_intcall(sa.intnum, &sa.vmf)))
  			return (error);
  		error = copyout(&sa, ua.sub_args, sizeof(sa));
  		}
  		break;
 -#endif
  
  	default:
  		error = EINVAL;
 
 
Responsible-Changed-From-To: freebsd-bugs->jlemon 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Mon Oct 2 06:19:34 PDT 2000 
Responsible-Changed-Why:  
I think jlemon committed a change roughly equivelent to the patch 
in this PR - can it be closed now? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=21329 
State-Changed-From-To: open->closed 
State-Changed-By: jlemon 
State-Changed-When: Mon Oct 2 06:37:52 PDT 2000 
State-Changed-Why:  
Similar change applied, thanks. 

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