From owner-freebsd-bugs@FreeBSD.ORG Sun Dec 30 11:30:03 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 05E4E16A479 for ; Sun, 30 Dec 2007 11:30:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E645B13C467 for ; Sun, 30 Dec 2007 11:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id lBUBU2FR058607 for ; Sun, 30 Dec 2007 11:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id lBUBU2Fn058599; Sun, 30 Dec 2007 11:30:02 GMT (envelope-from gnats) Date: Sun, 30 Dec 2007 11:30:02 GMT Message-Id: <200712301130.lBUBU2Fn058599@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Antoine Brodin Cc: Subject: Re: kern/119129: [libc] __stack_chk_guard setup is bogus in src/lib/libc/sys/stack_protector.c X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Antoine Brodin List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Dec 2007 11:30:03 -0000 The following reply was made to PR kern/119129; it has been noted by GNATS. From: Antoine Brodin To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/119129: [libc] __stack_chk_guard setup is bogus in src/lib/libc/sys/stack_protector.c Date: Sun, 30 Dec 2007 12:21:47 +0100 This is a multi-part message in MIME format. --Multipart=_Sun__30_Dec_2007_12_21_47_+0100_99Kj1udS0jrX1iLD Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Here is a patch, tested on i386 only. I tried to mimic what OpenBSD does. --Multipart=_Sun__30_Dec_2007_12_21_47_+0100_99Kj1udS0jrX1iLD Content-Type: text/x-diff; name="kern_mib.c.diff" Content-Disposition: attachment; filename="kern_mib.c.diff" Content-Transfer-Encoding: 7bit Index: kern_mib.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_mib.c,v retrieving revision 1.85 diff -u -p -r1.85 kern_mib.c --- kern_mib.c 4 Dec 2007 12:28:07 -0000 1.85 +++ kern_mib.c 30 Dec 2007 10:48:44 -0000 @@ -153,14 +153,18 @@ SYSCTL_INT(_hw, HW_PAGESIZE, pagesize, C static int sysctl_kern_arnd(SYSCTL_HANDLER_ARGS) { - u_long val; + char buf[256]; + size_t len; - arc4rand(&val, sizeof(val), 0); - return (sysctl_handle_long(oidp, &val, 0, req)); + len = req->oldlen; + if (len > sizeof(buf)) + len = sizeof(buf); + arc4rand(buf, len, 0); + return (SYSCTL_OUT(req, buf, len)); } -SYSCTL_PROC(_kern, KERN_ARND, arandom, CTLFLAG_RD, - 0, 0, sysctl_kern_arnd, "L", "arc4rand"); +SYSCTL_PROC(_kern, KERN_ARND, arandom, CTLTYPE_OPAQUE | CTLFLAG_RD, + NULL, 0, sysctl_kern_arnd, "", "arc4rand"); static int sysctl_hw_physmem(SYSCTL_HANDLER_ARGS) --Multipart=_Sun__30_Dec_2007_12_21_47_+0100_99Kj1udS0jrX1iLD--