Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 May 2008 01:09:17 +0400 (MSD)
From:      Chagin Dmitry <chagin.dmitry@gmail.com>
Cc:        freebsd-emulation@freebsd.org
Subject:   Re: Current problem reports assigned to freebsd-emulation@FreeBSD.org
Message-ID:  <alpine.BSF.1.10.0805210101470.4552@ora.chd.net>
In-Reply-To: <200805191106.m4JB6oBF011533@freefall.freebsd.org>
References:  <200805191106.m4JB6oBF011533@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 19 May 2008, FreeBSD bugmaster wrote:

> Current FreeBSD problem reports
> Critical problems
> Serious problems
>
> S Tracker      Resp.      Description
> --------------------------------------------------------------------------------
> o kern/21463   emulation  [linux] Linux compatability mode should not allow setu
> o kern/97326   emulation  [linux] file descriptor leakage in linux emulation
> o kern/117010  emulation  [linux] linux_getdents() get something like buffer ove
>

about 117010...
Can somebody test this patch on amd64 and i386?
It is necessary linux_base-f8, 2.6.16, -current.
thnx!


diff --git a/src/sys/compat/linux/linux_file.c b/src/sys/compat/linux/linux_file.c
index a843659..0acd07f 100644
--- a/src/sys/compat/linux/linux_file.c
+++ b/src/sys/compat/linux/linux_file.c
@@ -240,6 +240,7 @@ linux_lseek(struct thread *td, struct linux_lseek_args *args)
      return error;
  }

+#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
  int
  linux_llseek(struct thread *td, struct linux_llseek_args *args)
  {
@@ -278,6 +279,7 @@ linux_readdir(struct thread *td, struct linux_readdir_args *args)
  	lda.count = 1;
  	return linux_getdents(td, &lda);
  }
+#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */

  /*
   * Note that linux_getdents(2) and linux_getdents64(2) have the same
@@ -289,7 +291,7 @@ linux_readdir(struct thread *td, struct linux_readdir_args *args)
   */

  struct l_dirent {
-	l_long		d_ino;
+	l_ino_t		d_ino;
  	l_off_t		d_off;
  	l_ushort	d_reclen;
  	char		d_name[LINUX_NAME_MAX + 1];
@@ -536,6 +538,7 @@ linux_getdents64(struct thread *td, struct linux_getdents64_args *args)
  	return (getdents_common(td, args, 1));
  }

+
  /*
   * These exist mainly for hooks for doing /compat/linux translation.
   */
@@ -905,6 +908,7 @@ linux_truncate(struct thread *td, struct linux_truncate_args *args)
  	return (error);
  }

+#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
  int
  linux_truncate64(struct thread *td, struct linux_truncate64_args *args)
  {
@@ -922,6 +926,8 @@ linux_truncate64(struct thread *td, struct linux_truncate64_args *args)
  	LFREEPATH(path);
  	return (error);
  }
+#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */
+
  int
  linux_ftruncate(struct thread *td, struct linux_ftruncate_args *args)
  {
@@ -1119,6 +1125,7 @@ linux_mount(struct thread *td, struct linux_mount_args *args)
  	return (error);
  }

+#if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
  int
  linux_oldumount(struct thread *td, struct linux_oldumount_args *args)
  {
@@ -1128,6 +1135,7 @@ linux_oldumount(struct thread *td, struct linux_oldumount_args *args)
  	args2.flags = 0;
  	return (linux_umount(td, &args2));
  }
+#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */

  int
  linux_umount(struct thread *td, struct linux_umount_args *args)
@@ -1258,7 +1266,7 @@ bsd_to_linux_flock64(struct flock *bsd_flock, struct l_flock64 *linux_flock)
  #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */

  static int
-fcntl_common(struct thread *td, struct linux_fcntl64_args *args)
+fcntl_common(struct thread *td, struct linux_fcntl_args *args)
  {
  	struct l_flock linux_flock;
  	struct flock bsd_flock;
@@ -1382,17 +1390,13 @@ fcntl_common(struct thread *td, struct linux_fcntl64_args *args)
  int
  linux_fcntl(struct thread *td, struct linux_fcntl_args *args)
  {
-	struct linux_fcntl64_args args64;

  #ifdef DEBUG
  	if (ldebug(fcntl))
  		printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd);
  #endif

-	args64.fd = args->fd;
-	args64.cmd = args->cmd;
-	args64.arg = args->arg;
-	return (fcntl_common(td, &args64));
+	return (fcntl_common(td, args));
  }

  #if defined(__i386__) || (defined(__amd64__) && defined(COMPAT_LINUX32))
@@ -1401,6 +1405,7 @@ linux_fcntl64(struct thread *td, struct linux_fcntl64_args *args)
  {
  	struct l_flock64 linux_flock;
  	struct flock bsd_flock;
+	struct linux_fcntl_args fcntl_args;
  	int error;

  #ifdef DEBUG
@@ -1441,7 +1446,10 @@ linux_fcntl64(struct thread *td, struct linux_fcntl64_args *args)
  		    (intptr_t)&bsd_flock));
  	}

-	return (fcntl_common(td, args));
+	fcntl_args.fd = args->fd;
+	fcntl_args.cmd = args->cmd;
+	fcntl_args.arg = args->arg;
+	return (fcntl_common(td, &fcntl_args));
  }
  #endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */



-- 
Have fun!
chd



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.1.10.0805210101470.4552>