From owner-freebsd-current Tue Jul 7 10:02:20 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA28581 for freebsd-current-outgoing; Tue, 7 Jul 1998 10:02:20 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from dingo.cdrom.com (dingo.cdrom.com [204.216.28.145]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA28568 for ; Tue, 7 Jul 1998 10:02:16 -0700 (PDT) (envelope-from mike@dingo.cdrom.com) Received: from dingo.cdrom.com (localhost [127.0.0.1]) by dingo.cdrom.com (8.8.8/8.8.5) with ESMTP id KAA00644; Tue, 7 Jul 1998 10:00:04 -0700 (PDT) Message-Id: <199807071700.KAA00644@dingo.cdrom.com> X-Mailer: exmh version 2.0zeta 7/24/97 To: Terry Lambert cc: jkh@time.cdrom.com (Jordan K. Hubbard), joelh@gnu.org, smoergrd@oslo.geco-prakla.slb.com, tarkhil@asteroid.svib.ru, current@FreeBSD.ORG Subject: Re: xf86OpenConsole: KDENABIO failed (Operation not permitted) In-reply-to: Your message of "Tue, 07 Jul 1998 07:18:05 -0000." <199807070718.AAA04728@usr06.primenet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 07 Jul 1998 10:00:04 -0700 From: Mike Smith Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > Truly, standing up on a soapbox and calling it a bug is Not Useful and > > has already been done before by a succession of previous soapbox > > orators (check out the OpenBSD mailing lists sometime for a whole > > book's worth of material on the topic). Suggesting some real, > > tangible approach to dealing with it would be a welcome switch from > > the usual. > > I'm pretty sure patches to add Linux-like control to the I/O address > space rather than using the /dev/io hack have gone by several times; They actually exist in -current, although Bruce is not fond of the implementation. He says: ... FreeBSD ioperm is not completely implemented. It is only available if the kernel was configured with `options "VM86"'. It is a subcall of sysarch(undocumented). You have to pass it a pointer to a poorly laid out struct giving the args, something like this: Linux: int ioperm(u_long from, u_long num, int turn_on); FreeBSD: struct i386_ioperm_args { u_short from, num; u_char turn_on; } foo; sysarch(I386_SET_IOPERM, /* XXX 1970's interface */ (char *)&foo); Here are some fixes for the bugs. They are untested. diff -c2 sys_machdep.c~ sys_machdep.c *** sys_machdep.c~ Fri Nov 28 14:37:35 1997 --- sys_machdep.c Fri Nov 28 17:28:16 1997 *************** *** 181,185 **** char *args; { ! int i, error = 0; struct i386_ioperm_args ua; char *iomap; --- 181,185 ---- char *args; { ! int i, error; struct i386_ioperm_args ua; char *iomap; *************** *** 188,194 **** return (error); - /* Only root can do this */ if (error = suser(p->p_ucred, &p->p_acflag)) return (error); /* * XXX --- 188,195 ---- return (error); if (error = suser(p->p_ucred, &p->p_acflag)) return (error); + if (securelevel > 0) + return (EPERM); /* * XXX *************** *** 203,207 **** iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; ! if ((int)(ua.start + ua.length) > 0xffff) return (EINVAL); --- 204,208 ---- iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; ! if (ua.start + ua.length > IOPAGES * PAGE_SIZE * NBBY) return (EINVAL); *************** *** 220,224 **** char *args; { ! int i, state, error = 0; struct i386_ioperm_args ua; char *iomap; --- 221,225 ---- char *args; { ! int i, state, error; struct i386_ioperm_args ua; char *iomap; *************** *** 226,229 **** --- 227,232 ---- if (error = copyin(args, &ua, sizeof(struct i386_ioperm_args))) return (error); + if (ua.start >= IOPAGES * PAGE_SIZE * NBBY) + return (EINVAL); if (p->p_addr->u_pcb.pcb_ext == 0) { *************** *** 234,237 **** --- 237,242 ---- iomap = (char *)p->p_addr->u_pcb.pcb_ext->ext_iomap; + i = ua.start; + state = (iomap[i >> 3] >> (i & 7)) & 1; ua.enable = !state; ua.length = 1; Bruce -- \\ Sometimes you're ahead, \\ Mike Smith \\ sometimes you're behind. \\ mike@smith.net.au \\ The race is long, and in the \\ msmith@freebsd.org \\ end it's only with yourself. \\ msmith@cdrom.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message