From owner-freebsd-emulation@FreeBSD.ORG Fri Jul 25 07:00:16 2008 Return-Path: Delivered-To: freebsd-emulation@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7A15E106568B for ; Fri, 25 Jul 2008 07:00:16 +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 211EF8FC1E for ; Fri, 25 Jul 2008 07:00:16 +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 m6P70Faw036133 for ; Fri, 25 Jul 2008 07:00:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m6P70FSF036132; Fri, 25 Jul 2008 07:00:15 GMT (envelope-from gnats) Date: Fri, 25 Jul 2008 07:00:15 GMT Message-Id: <200807250700.m6P70FSF036132@freefall.freebsd.org> To: freebsd-emulation@FreeBSD.org From: Chagin Dmitry Cc: Subject: Re: kern/117010: [linux] linux_getdents() get somethinng like buffer overflow X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Chagin Dmitry List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jul 2008 07:00:16 -0000 The following reply was made to PR kern/117010; it has been noted by GNATS. From: Chagin Dmitry To: bug-followup@freebsd.org, samflanker@gmail.com Cc: Subject: Re: kern/117010: [linux] linux_getdents() get somethinng like buffer overflow Date: Fri, 25 Jul 2008 10:22:46 +0400 (MSD) Please, try a patch below: diff --git a/src/sys/compat/linux/linux_file.c b/src/sys/compat/linux/linux_file index 303bc3f..d88f95f 100644 --- a/src/sys/compat/linux/linux_file.c +++ b/src/sys/compat/linux/linux_file.c @@ -303,8 +303,8 @@ struct l_dirent64 { char d_name[LINUX_NAME_MAX + 1]; }; -#define LINUX_RECLEN(de,namlen) \ - ALIGN((((char *)&(de)->d_name - (char *)de) + (namlen) + 1)) +#define LINUX_RECLEN(de,namlen,trail) \ + ALIGN((((char *)&(de)->d_name - (char *)de) + (namlen) + trail)) #define LINUX_DIRBLKSIZ 512 @@ -436,8 +436,8 @@ again: } linuxreclen = (is64bit) - ? LINUX_RECLEN(&linux_dirent64, bdp->d_namlen) - : LINUX_RECLEN(&linux_dirent, bdp->d_namlen); + ? LINUX_RECLEN(&linux_dirent64, bdp->d_namlen, 1) + : LINUX_RECLEN(&linux_dirent, bdp->d_namlen, 2); if (reclen > len || resid < linuxreclen) { outp++; it solves getdents() problem (at least at x86_64 emulation with linux_base-f8) ps, be not bared, linux really has such features... thnx! -- Have fun! chd