From owner-freebsd-bugs@FreeBSD.ORG Sat Oct 18 09:20:20 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 24DA816A4B3 for ; Sat, 18 Oct 2003 09:20:20 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 58E2243F3F for ; Sat, 18 Oct 2003 09:20:18 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h9IGKIFY092421 for ; Sat, 18 Oct 2003 09:20:18 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h9IGKIfl092420; Sat, 18 Oct 2003 09:20:18 -0700 (PDT) (envelope-from gnats) Resent-Date: Sat, 18 Oct 2003 09:20:18 -0700 (PDT) Resent-Message-Id: <200310181620.h9IGKIfl092420@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Stefan Farfeleder Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E611216A4B3 for ; Sat, 18 Oct 2003 09:17:44 -0700 (PDT) Received: from fafoe.narf.at (chello212186121237.14.vie.surfer.at [212.186.121.237]) by mx1.FreeBSD.org (Postfix) with ESMTP id DC36843F85 for ; Sat, 18 Oct 2003 09:17:43 -0700 (PDT) (envelope-from stefan@fafoe.dyndns.org) Received: from frog.fafoe.narf.at (frog.fafoe.narf.at [192.168.2.101]) by fafoe.narf.at (Postfix) with ESMTP id 4DD6340ED; Sat, 18 Oct 2003 18:17:40 +0200 (CEST) Received: by frog.fafoe.narf.at (Postfix, from userid 1001) id 9D78C1FC; Sat, 18 Oct 2003 18:17:39 +0200 (CEST) Message-Id: <20031018161739.9D78C1FC@frog.fafoe.narf.at> Date: Sat, 18 Oct 2003 18:17:39 +0200 (CEST) From: Stefan Farfeleder To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: stefan@fafoe.narf.at Subject: kern/58214: [patch] Align smallbits properly in poll() X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Stefan Farfeleder List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Oct 2003 16:20:20 -0000 >Number: 58214 >Category: kern >Synopsis: [patch] Align smallbits properly in poll() >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Oct 18 09:20:17 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Stefan Farfeleder >Release: FreeBSD 5.1-CURRENT i386 >Organization: >Environment: System: FreeBSD frog.fafoe.narf.at 5.1-CURRENT FreeBSD 5.1-CURRENT #1: Sat Oct 18 17:37:40 CEST 2003 freebsd@frog.fafoe.narf.at:/freebsd/testing/obj/freebsd/testing/src/sys/TESTING i386 >Description: Poll() uses the array smallbits that is big enough to hold 32 struct pollfd's to avoid calling malloc() on small numbers of fds. Because smalltype's members have type char, its address might be misaligned for a struct pollfd. >How-To-Repeat: >Fix: Additionally, bits' type is changed to void * to avoid a cast and allows to get rid of another one. --- poll.diff begins here --- Index: src/sys/kern/sys_generic.c =================================================================== RCS file: /usr/home/ncvs/src/sys/kern/sys_generic.c,v retrieving revision 1.125 diff -u -p -r1.125 sys_generic.c --- src/sys/kern/sys_generic.c 27 Sep 2003 12:53:33 -0000 1.125 +++ src/sys/kern/sys_generic.c 18 Oct 2003 15:10:19 -0000 @@ -938,8 +938,8 @@ poll(td, uap) struct thread *td; struct poll_args *uap; { - caddr_t bits; - char smallbits[32 * sizeof(struct pollfd)]; + void *bits; + struct pollfd smallbits[32]; struct timeval atv, rtv, ttv; int error = 0, timo; u_int ncoll, nfds; @@ -991,7 +991,7 @@ retry: mtx_unlock_spin(&sched_lock); mtx_unlock(&sellock); - error = pollscan(td, (struct pollfd *)bits, nfds); + error = pollscan(td, bits, nfds); mtx_lock(&sellock); if (error || td->td_retval[0]) goto done; --- poll.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: