From owner-freebsd-audit Mon Nov 25 1:36:32 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2BA5E37B401 for ; Mon, 25 Nov 2002 01:36:30 -0800 (PST) Received: from cognet.ci0.org (cognet.ci0.org [80.65.224.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id B6F3B43E4A for ; Mon, 25 Nov 2002 01:36:25 -0800 (PST) (envelope-from doginou@cognet.ci0.org) Received: from cognet.ci0.org (cognet.ci0.org [80.65.224.102] (may be forged)) by cognet.ci0.org (8.12.6/8.12.6) with ESMTP id gAP9WTFn010557 for ; Mon, 25 Nov 2002 10:32:29 +0100 (CET) (envelope-from doginou@cognet.ci0.org) Received: (from doginou@localhost) by cognet.ci0.org (8.12.6/8.12.6/Submit) id gAP9WSHk010556 for freebsd-audit@FreeBSD.org; Mon, 25 Nov 2002 10:32:28 +0100 (CET) Date: Mon, 25 Nov 2002 10:32:28 +0100 From: Olivier Houchard To: freebsd-audit@FreeBSD.org Subject: do_dup patch Message-ID: <20021125093228.GA10213@ci0.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Nq2Wo0NMKNjxTN9z" Content-Disposition: inline User-Agent: Mutt/1.5.1i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, This patch makes the "new" and "old" do_dup arguments unsigned int instead of int. I can't see any reason they would have to be int, and right now a call to dup or dup2 with an invalid negative fd, such as dup(-999999); will panic a -CURRENT box (the problem doesn't exist on -STABLE because the file descriptor validity is checked in dup() and dup2()). Is there anything wrong with committing this ? Any comments are welcome. Olivier --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="kern_descrip.c.diff" Index: kern_descrip.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_descrip.c,v retrieving revision 1.168 diff -u -p -r1.168 kern_descrip.c --- kern_descrip.c 27 Oct 2002 18:07:41 -0000 1.168 +++ kern_descrip.c 24 Nov 2002 19:52:55 -0000 @@ -101,7 +101,7 @@ static struct cdevsw fildesc_cdevsw = { /* How to treat 'new' parameter when allocating a fd for do_dup(). */ enum dup_type { DUP_VARIABLE, DUP_FIXED }; -static int do_dup(struct thread *td, enum dup_type type, int old, int new, +static int do_dup(struct thread *td, enum dup_type type, u_int old, u_int new, register_t *retval); static int badfo_readwrite(struct file *fp, struct uio *uio, struct ucred *active_cred, int flags, struct thread *td); @@ -171,8 +171,7 @@ dup2(td, uap) struct dup2_args *uap; { - return (do_dup(td, DUP_FIXED, (int)uap->from, (int)uap->to, - td->td_retval)); + return (do_dup(td, DUP_FIXED, uap->from, uap->to, td->td_retval)); } /* @@ -193,7 +192,7 @@ dup(td, uap) struct dup_args *uap; { - return (do_dup(td, DUP_VARIABLE, (int)uap->fd, 0, td->td_retval)); + return (do_dup(td, DUP_VARIABLE, uap->fd, 0, td->td_retval)); } /* @@ -452,7 +451,7 @@ done2: static int do_dup(td, type, old, new, retval) enum dup_type type; - int old, new; + u_int old, new; register_t *retval; struct thread *td; { --Nq2Wo0NMKNjxTN9z-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message