Package: user-mode-linux
Version: 3.2-2um-1+deb7u2+b1
Severity: grave
Tags: patch
Justification: causes non-serious data loss

Dear Maintainer,

This bug is perennial. If we go through old bugs with
"cannot reproduce" tag 50% of them are this one, the other
50% are the "you should not use pipe for interprocess IPC" 
which we will submit shortly.

Manifestation of the problem - UML dies on startup for no
reason with a memory corruption message. Occurs only on 
heavily loaded systems and usually when running a lot of 
UMLs.

-- System Information:
Debian Release: 7.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages user-mode-linux depends on:
ii  libc6          2.13-38
ii  uml-utilities  20070815-1.1-ai-1.8

user-mode-linux recommends no packages.

Versions of packages user-mode-linux suggests:
ii  gnome-terminal [x-terminal-emulator]  3.4.1.1-2
ii  konsole [x-terminal-emulator]         4:4.8.4-2
pn  rootstrap                             <none>
pn  slirp                                 <none>
pn  user-mode-linux-doc                   <none>
pn  vde2                                  <none>
ii  xfce4-terminal [x-terminal-emulator]  0.4.8-1+b1
ii  xterm [x-terminal-emulator]           278-4

-- no debconf information
>From 9c3a9af21c0bfeca27eac958fde215594b4ee3fa Mon Sep 17 00:00:00 2001
From: Anton Ivanov <antiv...@cisco.com>
Date: Sat, 8 Mar 2014 06:49:27 +0000
Subject: [PATCH 2/3] BUG: Memory corruption on startup

The reverse case of this race (you must msync before read) is
well known. This is the not so common one.

It can be triggered only on systems which do a lot of task
switching and only at UML startup. If you are starting 200+ UMLs
~ 0.5% will always die without this fix.
---
 arch/um/include/shared/os.h |    1 +
 arch/um/kernel/physmem.c    |    1 +
 arch/um/os-Linux/file.c     |    6 ++++++
 3 files changed, 8 insertions(+)

diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
index 89b686c1..3c9738d 100644
--- a/arch/um/include/shared/os.h
+++ b/arch/um/include/shared/os.h
@@ -136,6 +136,7 @@ extern int os_ioctl_generic(int fd, unsigned int cmd, unsigned long arg);
 extern int os_get_ifname(int fd, char *namebuf);
 extern int os_set_slip(int fd);
 extern int os_mode_fd(int fd, int mode);
+extern int os_fsync_file(int fd);
 
 extern int os_seek_file(int fd, unsigned long long offset);
 extern int os_open_file(const char *file, struct openflags flags, int mode);
diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c
index f116db1..30fdd5d0 100644
--- a/arch/um/kernel/physmem.c
+++ b/arch/um/kernel/physmem.c
@@ -103,6 +103,7 @@ void __init setup_physmem(unsigned long start, unsigned long reserve_end,
 	 */
 	os_seek_file(physmem_fd, __pa(&__syscall_stub_start));
 	os_write_file(physmem_fd, &__syscall_stub_start, PAGE_SIZE);
+	os_fsync_file(physmem_fd);
 
 	bootmap_size = init_bootmem(pfn, pfn + delta);
 	free_bootmem(__pa(reserve_end) + bootmap_size,
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index b049a63..a4f0e65 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -237,6 +237,12 @@ void os_close_file(int fd)
 {
 	close(fd);
 }
+int os_fsync_file(int fd)
+{
+	if (fsync(fd) < 0) 
+	    return -errno;
+	return 0;
+}
 
 int os_seek_file(int fd, unsigned long long offset)
 {
-- 
1.7.10.4

Reply via email to