From owner-freebsd-isdn Tue Sep 28 14:33:29 1999 Delivered-To: freebsd-isdn@freebsd.org Received: from peedub.muc.de (peedub.muc.de [193.149.49.109]) by hub.freebsd.org (Postfix) with ESMTP id CAB6914E98 for ; Tue, 28 Sep 1999 14:33:22 -0700 (PDT) (envelope-from garyj@peedub.muc.de) Received: from peedub.muc.de (localhost [127.0.0.1]) by peedub.muc.de (8.9.3/8.6.9) with ESMTP id XAA00525; Tue, 28 Sep 1999 23:32:32 +0200 (CEST) Message-Id: <199909282132.XAA00525@peedub.muc.de> X-Mailer: exmh version 2.0.2 2/24/98 To: mranner@netway.a Cc: freebsd-isdn@freebsd.org Subject: problems with 0.83 and sPPP From: Gary Jennejohn Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 28 Sep 1999 23:32:32 +0200 Sender: owner-freebsd-isdn@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org I looked into the problems with spppcontrol always returning an error. There are 2 fixes. First, the simple one: *** /u7/garyj/src/sys/i4b_83/sppp/if_sppp.h Mon Jul 19 16:00:55 1999 --- ./if_sppp.h Tue Sep 28 23:08:33 1999 *************** *** 166,172 **** #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp))) struct spppreq { ! int cmd; struct sppp defs; }; --- 166,172 ---- #define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp))) struct spppreq { ! u_long cmd; struct sppp defs; }; Next the more complex one: *** /u7/garyj/src/sys/i4b_83/sppp/if_spppsubr.c Mon Jul 19 16:00:55 1999 --- if_spppsubr.c Tue Sep 28 22:56:53 1999 *************** *** 4167,4182 **** static int sppp_params(struct sppp *sp, IOCTL_CMD_T cmd, void *data) { struct ifreq *ifr = (struct ifreq *)data; struct spppreq spr; /* * ifr->ifr_data is supposed to point to a struct spppreq. */ if (copyin((caddr_t)ifr->ifr_data, &spr, sizeof spr) != 0) return EFAULT; ! switch (spr.cmd) { case SPPPIOGDEFS: if (cmd != SIOCGIFGENERIC) return EINVAL; --- 4167,4191 ---- static int sppp_params(struct sppp *sp, IOCTL_CMD_T cmd, void *data) { + u_long subcmd; struct ifreq *ifr = (struct ifreq *)data; struct spppreq spr; /* * ifr->ifr_data is supposed to point to a struct spppreq. + * Check the cmd word first before attempting to fetch all the + * data. + */ + if ((subcmd = fuword(ifr->ifr_data)) == -1) + return EFAULT; + + /* + * ifr->ifr_data is supposed to point to a struct spppreq. */ if (copyin((caddr_t)ifr->ifr_data, &spr, sizeof spr) != 0) return EFAULT; ! switch (subcmd) { case SPPPIOGDEFS: if (cmd != SIOCGIFGENERIC) return EINVAL; The second patch corresponds to the code in -current. I tried both of these and they both make spppcontrol work OK. Having looked at this it is now pretty obvious where the problem was - the kernel expects spr.cmd to be a u_long, but it was an int. Since the ioctl pretends to be a caddr_t the mismatch apparently lead to the error. -------- Gary Jennejohn Home - garyj@muc.de Work - garyj@fkr.dec.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-isdn" in the body of the message