From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 28 23:50:01 2009 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 D1993106566C for ; Wed, 28 Jan 2009 23:50:01 +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 AD9D78FC21 for ; Wed, 28 Jan 2009 23:50:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n0SNo1LN050166 for ; Wed, 28 Jan 2009 23:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n0SNo1IN050165; Wed, 28 Jan 2009 23:50:01 GMT (envelope-from gnats) Resent-Date: Wed, 28 Jan 2009 23:50:01 GMT Resent-Message-Id: <200901282350.n0SNo1IN050165@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, Andreas Kies Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92E0E106566C for ; Wed, 28 Jan 2009 23:40:37 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 64B658FC1B for ; Wed, 28 Jan 2009 23:40:37 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n0SNeaOA088522 for ; Wed, 28 Jan 2009 23:40:36 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n0SNeaqi088521; Wed, 28 Jan 2009 23:40:36 GMT (envelope-from nobody) Message-Id: <200901282340.n0SNeaqi088521@www.freebsd.org> Date: Wed, 28 Jan 2009 23:40:36 GMT From: Andreas Kies To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/131099: [patch] readdir broken on Linux emulation. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jan 2009 23:50:02 -0000 >Number: 131099 >Category: misc >Synopsis: [patch] readdir broken on Linux emulation. >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jan 28 23:50:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Andreas Kies >Release: 7.1 >Organization: >Environment: FreeBSD andiunx.local 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan 1 14:37:25 UTC 2009 root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386 >Description: The system call readdir does not return any data if a Linux binary is run. The internally calculated space for returning an entry is sizeof(struct dirent *), but it should be sizeof(struct dirent). Please consider applying the attached patch. >How-To-Repeat: /*Compile the following program */ /* Compile with -fno-stack-protector if you want to run it as a Linux binary * on FreeBSD 7.1 * Assembly part might be broken if optimization is used. */ #include #include #include #include #include int myreaddir( int fd, unsigned char *buf, int c) { int res; __asm__ __volatile__ ("\ mov $0x59,%%eax \n\ int $0x80 \n" : "=a" (res) : "b" (fd), "c" (buf), "d" (c) ); return res; } int main() { int fd; int i, j; unsigned char inparr[512]; DIR *dipo; int respar; dipo=opendir("."); for (j=0; j < 10; j++) { memset( inparr, 0x55, sizeof(inparr)); respar=myreaddir(dirfd(dipo),inparr, 1); if ( respar == 0 ) break; if ( respar != 1 ) printf("respar %d\n", respar); for (i=0; i < 25; i++) printf( "%02x ", inparr[i]); printf( "\n"); } } >Fix: Apply attached patch. Patch attached with submission follows: --- linux_file.c.orig 2009-01-29 00:24:33.000000000 +0100 +++ linux_file.c 2009-01-29 00:24:55.000000000 +0100 @@ -438,7 +438,7 @@ /* readdir(2) case. Always struct dirent. */ if (is64bit) return (EINVAL); - nbytes = sizeof(linux_dirent); + nbytes = sizeof(*linux_dirent); justone = 1; } else justone = 0; >Release-Note: >Audit-Trail: >Unformatted: