Skip to contentSkip to conversation

block layer request length increases break 2.6.22.* COW ubd

uml-devel Nix 3 participants 5 messages Jul 12, 2007 – Jul 13, 2007

Subsystems (5)
lore
Share & tools
lore

Nix

author
#0 lore raw

My firewall has long been a UML instance sitting atop a COW-backed UBD, with the UBD being marked immutable and sha1-checked against a copy on a CD-R every boot.

Now 2.6.22.1 (and probably 2.6.22 as well) gives me a panic on boot which 2.6.21.* did not. Here's the complete boot log, ending with the panic:

loki:/home/firewall/run/esperi# /usr/bin/nice -n -10 su firewall -c "uml-esperi con=port:16380 con0=fd:0,fd:1 fakeide mem=96M ubd0=/mirror/uml/esperi-root-cow.image,/mirror/uml/esperi-root.image tty_log_dir=/home/firewall/log/esperi umid=esperi eth0=tuntap,tap0,00:60:97:79:E2:C1 eth1=tuntap,tap1"
Core dump limits :
        soft - 0
        hard - NONE
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking for tmpfs mount on /dev/shm...OK
Checking PROT_EXEC mmap in /dev/shm/...OK
Checking for the skas3 patch in the host:
  - /proc/mm...found
  - PTRACE_FAULTINFO...found
  - PTRACE_LDT...found
UML running in SKAS3 mode
Linux version 2.6.22.1 (compiler@loki) (gcc version 4.1.2) #1 Thu Jul 12 12:19:15 BST 2007
Built 1 zonelists.  Total pages: 24384
Kernel command line: con=port:16380 con0=fd:0,fd:1 fakeide mem=96M ubd0=/mirror/uml/esperi-root-cow.image,/mirror/uml/esperi-root.image tty_log_dir=/home/firewall/log/esperi eth0=tuntap,tap0,00:60:97:79:E2:C1 eth1=tuntap,tap1 root=98:0
PID hash table entries: 512 (order: 9, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 94456k available
Security Framework v1.0.0 initialized
Mount-cache hash table entries: 512
Checking for host processor cmov support...Yes
Checking for host processor xmm support...No
Checking that host ptys support output SIGIO...Yes
Checking that host ptys support SIGIO on close...No, enabling workaround
Using 2.6 host AIO
NET: Registered protocol family 16
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
Checking host MADV_REMOVE support...OK
mconsole (version 2) initialized on /home/firewall/.uml/esperi/mconsole
Host TLS support detected
Detected host type: i386
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
io scheduler noop registered
io scheduler deadline registered (default)
tun: Universal TUN/TAP device driver, 1.6
tun: (C) 1999-2004 Max Krasnyansky <[email protected]>
GACT probability NOT on
u32 classifier
    Performance counters on
    Actions configured
nf_conntrack version 0.5.0 (738 buckets, 5904 max)
ip_tables: (C) 2000-2006 Netfilter Core Team
TCP cubic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
Initialized stdio console driver
Console initialized on /dev/tty0
Initializing software serial port version 1
 ubda: unknown partition table
Warning: attempt to assign a globally valid ethernet address to a device
You should better enable the 2nd rightmost bit in the first byte of the MAC,
i.e. 02:60:97:79:e2:c1
Choosing a random ethernet address for device eth0
Netdevice 0 (02:1c:86:28:c2:df) : TUN/TAP backend -
Warning: attempt to assign a globally valid ethernet address to a device
You should better enable the 2nd rightmost bit in the first byte of the MAC,
i.e. 02:60:97:79:e2:c1
Choosing a random ethernet address for device eth1
Netdevice 1 (8e:00:d0:1e:a4:0d) : TUN/TAP backend -
VFS: Mounted root (ext2 filesystem) readonly.
Kernel panic - not syncing: Operation too long

EIP: 0073:[<b7f6c410>] CPU: 0 Not tainted ESP: 007b:b7f67fb8 EFLAGS: 00000292
Not tainted
EAX: 00000000 EBX: 00006582 ECX: 00000013 EDX: 00006582
ESI: 0000657e EDI: 00000011 EBP: 00000000 DS: 007b ES: 007b

08267b94:  [<080780f3>] notifier_call_chain+0x25/0x4e
08267bb4:  [<08078191>] atomic_notifier_call_chain+0x15/0x19
08267bcc:  [<0806d0d6>] panic+0x52/0xd3
08267be8:  [<0805f27a>] cowify_req+0x38/0xcd
08267c08:  [<0805f4a5>] do_ubd_request+0xaa/0x137
08267c3c:  [<08105325>] generic_unplug_device+0x10/0x17
08267c48:  [<08105382>] blk_backing_dev_unplug+0x56/0x5e
08267c64:  [<0808a9d0>] sync_page+0x0/0x29
08267c68:  [<080be5a0>] block_sync_page+0x21/0x24
08267c74:  [<0808a9f0>] sync_page+0x20/0x29
08267c7c:  [<0819dfb0>] __wait_on_bit_lock+0x29/0x51
08267c94:  [<0808b014>] __lock_page+0x56/0x5c
08267cb0:  [<0807dc7a>] wake_bit_function+0x0/0x34
08267cc8:  [<0808bdc6>] filemap_nopage+0x1da/0x268
08267cdc:  [<0808e9bd>] __alloc_pages+0x4f/0x279
08267cf0:  [<08095570>] do_no_page+0x9a/0x2b0
08267d24:  [<08095952>] __handle_mm_fault+0xaa/0x181
08267d54:  [<080584c1>] handle_page_fault+0xe1/0x1e2
08267d84:  [<080595d2>] maybe_map+0x52/0x83
08267db4:  [<08059614>] do_op_one_page+0x11/0x6d
08267dc8:  [<08059703>] do_buffer_op+0x93/0x13c
08267dd8:  [<08059a35>] clear_chunk+0x0/0x21
08267de4:  [<08059a35>] clear_chunk+0x0/0x21
08267e04:  [<08064c80>] setjmp_wrapper+0x3f/0x48
08267e24:  [<08064c56>] setjmp_wrapper+0x15/0x48
08267e34:  [<080597d6>] buffer_op+0x2a/0x53
08267e38:  [<08059670>] do_buffer_op+0x0/0x13c
08267e48:  [<08059a35>] clear_chunk+0x0/0x21
08267e58:  [<080c66fe>] elf_map+0x78/0xb1
08267e64:  [<08059ad5>] clear_user_skas+0x65/0x70
08267e74:  [<08059a35>] clear_chunk+0x0/0x21
08267e88:  [<080c61aa>] padzero+0x1c/0x2c
08267e94:  [<080c7371>] load_elf_binary+0x816/0xbff
08267ee8:  [<080a3ef1>] copy_strings+0x1bd/0x207
08267f04:  [<080a4bee>] search_binary_handler+0x60/0xf5
08267f24:  [<080a4ddf>] do_execve+0x15c/0x1f4
08267f44:  [<08055952>] execve1+0x29/0x50
08267f64:  [<0805598e>] um_execve+0x15/0x3e
08267f7c:  [<08057928>] kernel_execve+0x2b/0x37
08267f98:  [<0805532d>] run_init_process+0x19/0x1d
08267fa8:  [<080553be>] init_post+0x8d/0xb7
08267fb0:  [<080497eb>] kernel_init+0x7b/0x80
08267fbc:  [<08063487>] run_kernel_thread+0x38/0x41
08267fd8:  [<0806346a>] run_kernel_thread+0x1b/0x41
08267fe4:  [<08058f1b>] new_thread_handler+0x53/0x79
08267fe8:  [<08049770>] kernel_init+0x0/0x80

A little instrumentation of the failing conditional shows:

Kernel panic - not syncing: Operation too long: length 23552, max 16384

So it seems that requests from the block layer are too long for cowify_req() nowadays: there can be more sectors in them than there are bits in an `unsigned long'. I'm not sure what the maximum bounds are
now: boosting the sector_mask' to an unsigned long long' doesn't help because we just get a bigger request:

Kernel panic - not syncing: Operation too long: length 65536, max 32768

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

author
#1 lore raw

On 12 Jul 2007, [email protected] stated:

Quoted 3 lines

My firewall has long been a UML instance sitting atop a COW-backed UBD, with the UBD being marked immutable and sha1-checked against a copy on a CD-R every boot.

... aaand Jeff solved it two days ago and I didn't notice. Er, oops?

Here, have a skas-v9-pre9 patch forward-ported to 2.6.22 in restitution of my idiocy.

(The 2.6.20 patch, the most recent I could find, collided with paravirt and the header-inclusion reduction work. My fix to the latter is especially ugly, since it means that <linux/mm.h> is including <asm/current.h> and <linux/sched.h> again. Probably the right fix is for do_mmap_pgoff() to no longer be inlined, but I'm not sure what performance implications that might have.)

(Compile-tested only so far.)

arch/i386/Kconfig +20 -0
Index: i686-loki/arch/i386/Kconfig
===================================================================
@@ -601,6 +601,26 @@
 	default y
 	select RESOURCES_64BIT
 
+config PROC_MM
+	bool "/proc/mm support"
+	default y
+
+config PROC_MM_DUMPABLE
+	bool "Make UML childs /proc/<pid> completely browsable"
+	default n
+	help
+	  If in doubt, say N.
+
+	  This fiddles with some settings to make sure /proc/<pid> is completely
+	  browsable by who started UML, at the expense of some additional
+	  locking (maybe this could slow down the runned UMLs of a few percents,
+	  I've not tested this).
+
+	  Also, if there is a bug in this feature, there is some little
+	  possibility to do privilege escalation if you have UML installed
+	  setuid (which you shouldn't have done) or if UML changes uid on
+	  startup (which will be a good thing, when enabled) ...
+
 # Common NUMA Features
 config NUMA
 	bool "Numa Memory Allocation and Scheduler Support"
arch/i386/kernel/ldt.c +36 -22

144 lines not on this page · raw message

arch/i386/kernel/ptrace.c +61 -0

73 lines not on this page · raw message

arch/i386/kernel/sys_i386.c +21 -6
Index: i686-loki/arch/i386/kernel/sys_i386.c
===================================================================
@@ -22,6 +22,7 @@
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
 #include <asm/ipc.h>
+#include <asm/proc_mm.h>
 
 /*
  * sys_pipe() is the normal C calling standard for creating
@@ -40,13 +41,12 @@
 	return error;
 }
 
-asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
-			  unsigned long prot, unsigned long flags,
-			  unsigned long fd, unsigned long pgoff)
+long do_mmap2(struct mm_struct *mm, unsigned long addr, unsigned long len,
+		unsigned long prot, unsigned long flags, unsigned long fd,
+		unsigned long pgoff)
 {
 	int error = -EBADF;
 	struct file *file = NULL;
-	struct mm_struct *mm = current->mm;
 
 	flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
 	if (!(flags & MAP_ANONYMOUS)) {
@@ -56,7 +56,7 @@
 	}
 
 	down_write(&mm->mmap_sem);
-	error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+	error = __do_mmap_pgoff(mm, file, addr, len, prot, flags, pgoff);
 	up_write(&mm->mmap_sem);
 
 	if (file)
@@ -65,6 +65,18 @@
 	return error;
 }
 
+asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
+       unsigned long prot, unsigned long flags,
+       unsigned long fd, unsigned long pgoff)
+{
+	long ret = do_mmap2(current->mm, addr, len, prot, flags, fd, pgoff);
+
+	/* A tail call would reorder parameters on the stack and they would then
+	 * be restored at the wrong places. */
+	prevent_tail_call(ret);
+	return ret;
+}
+
 /*
  * Perform the select(nd, in, out, ex, tv) and mmap() system
  * calls. Linux/i386 didn't use to be able to handle more than
@@ -93,8 +105,11 @@
 	if (a.offset & ~PAGE_MASK)
 		goto out;
 
-	err = sys_mmap2(a.addr, a.len, a.prot, a.flags,
+	err = do_mmap2(current->mm, a.addr, a.len, a.prot, a.flags,
 			a.fd, a.offset >> PAGE_SHIFT);
+	/* A tail call would reorder parameters on the stack and they would then
+	 * be restored at the wrong places. */
+	prevent_tail_call(err);
 out:
 	return err;
 }
arch/um/include/skas_ptrace.h +4 -0
Index: i686-loki/arch/um/include/skas_ptrace.h
===================================================================
@@ -6,6 +6,8 @@
 #ifndef __SKAS_PTRACE_H
 #define __SKAS_PTRACE_H
 
+#ifndef PTRACE_FAULTINFO
+
 #define PTRACE_FAULTINFO 52
 #define PTRACE_SWITCH_MM 55
 
@@ -13,6 +15,8 @@
 
 #endif
 
+#endif
+
 /*
  * Overrides for Emacs so that we follow Linus's tabbing style.
  * Emacs will notice this stuff at the end of the file and automatically
arch/x86_64/Kconfig +20 -0
Index: i686-loki/arch/x86_64/Kconfig
===================================================================
@@ -514,6 +514,26 @@
 	  access 32-bits of memory can be used on systems with more than
 	  3 GB of memory. If unsure, say Y.
 
+config PROC_MM
+	bool "/proc/mm support"
+	default y
+
+config PROC_MM_DUMPABLE
+	bool "Make UML childs /proc/<pid> completely browsable"
+	default n
+	help
+	  If in doubt, say N.
+
+	  This fiddles with some settings to make sure /proc/<pid> is completely
+	  browsable by who started UML, at the expense of some additional
+	  locking (maybe this could slow down the runned UMLs of a few percents,
+	  I've not tested this).
+
+	  Also, if there is a bug in this feature, there is some little
+	  possibility to do privilege escalation if you have UML installed
+	  setuid (which you shouldn't have done) or if UML changes uid on
+	  startup (which will be a good thing, when enabled) ...
+
 config X86_MCE
 	bool "Machine check support" if EMBEDDED
 	default y
arch/x86_64/ia32/ptrace32.c +68 -0

92 lines not on this page · raw message

arch/x86_64/ia32/sys_ia32.c +12 -4
Index: i686-loki/arch/x86_64/ia32/sys_ia32.c
===================================================================
@@ -693,11 +693,10 @@
 	return ret;
 }
 
-asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
-	unsigned long prot, unsigned long flags,
+long do32_mmap2(struct mm_struct *mm, unsigned long addr,
+	unsigned long len, unsigned long prot, unsigned long flags,
 	unsigned long fd, unsigned long pgoff)
 {
-	struct mm_struct *mm = current->mm;
 	unsigned long error;
 	struct file * file = NULL;
 
@@ -709,7 +708,7 @@
 	}
 
 	down_write(&mm->mmap_sem);
-	error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);
+	error = __do_mmap_pgoff(mm, file, addr, len, prot, flags, pgoff);
 	up_write(&mm->mmap_sem);
 
 	if (file)
@@ -717,6 +716,15 @@
 	return error;
 }
 
+/* XXX: this wrapper can be probably removed, we can simply use the 64-bit
+ * version.*/
+asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
+	unsigned long prot, unsigned long flags,
+	unsigned long fd, unsigned long pgoff)
+{
+	return do32_mmap2(current->mm, addr, len, prot, flags, fd, pgoff);
+}
+
 asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
 {
 	int err;
arch/x86_64/kernel/ldt.c +32 -23

146 lines not on this page · raw message

arch/x86_64/kernel/ptrace.c +70 -0

82 lines not on this page · raw message

arch/x86_64/kernel/sys_x86_64.c +11 -4
Index: i686-loki/arch/x86_64/kernel/sys_x86_64.c
===================================================================
@@ -18,6 +18,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/ia32.h>
+#include <asm/proc_mm.h>
 
 /*
  * sys_pipe() is the normal C calling standard for creating
@@ -36,7 +37,7 @@
 	return error;
 }
 
-asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
+long do64_mmap(struct mm_struct *mm, unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
 	unsigned long fd, unsigned long off)
 {
 	long error;
@@ -54,9 +55,9 @@
 		if (!file)
 			goto out;
 	}
-	down_write(&current->mm->mmap_sem);
-	error = do_mmap_pgoff(file, addr, len, prot, flags, off >> PAGE_SHIFT);
-	up_write(&current->mm->mmap_sem);
+	down_write(&mm->mmap_sem);
+	error = __do_mmap_pgoff(mm, file, addr, len, prot, flags, off >> PAGE_SHIFT);
+	up_write(&mm->mmap_sem);
 
 	if (file)
 		fput(file);
@@ -64,6 +65,12 @@
 	return error;
 }
 
+asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags,
+	unsigned long fd, unsigned long off)
+{
+	return do64_mmap(current->mm, addr, len, prot, flags, fd, off);
+}
+
 static void find_start_end(unsigned long flags, unsigned long *begin,
 			   unsigned long *end)
 {
arch/x86_64/mm/Makefile +1 -0
Index: i686-loki/arch/x86_64/mm/Makefile
===================================================================
@@ -7,5 +7,6 @@
 obj-$(CONFIG_NUMA) += numa.o
 obj-$(CONFIG_K8_NUMA) += k8topology.o
 obj-$(CONFIG_ACPI_NUMA) += srat.o
+obj-$(CONFIG_PROC_MM) += proc_mm.o
 
 hugetlbpage-y = ../../i386/mm/hugetlbpage.o
arch/x86_64/mm/proc_mm.c new file +85 -0

85 lines not on this page · raw message

include/asm-i386/desc.h +3 -0
Index: i686-loki/include/asm-i386/desc.h
===================================================================
@@ -216,6 +216,9 @@
 	return base;
 }
 
+extern int __modify_ldt(struct mm_struct * mm, int func, void __user *ptr,
+		      unsigned long bytecount);
+
 #else /* __ASSEMBLY__ */
 
 /*
include/asm-i386/mmu_context.h +17 -2
Index: i686-loki/include/asm-i386/mmu_context.h
===================================================================
@@ -8,6 +8,7 @@
 #include <asm/paravirt.h>
 #ifndef CONFIG_PARAVIRT
 #include <asm-generic/mm_hooks.h>
+#include <asm/semaphore.h>
 
 static inline void paravirt_activate_mm(struct mm_struct *prev,
 					struct mm_struct *next)
@@ -17,11 +18,22 @@
 
 
 /*
- * Used for LDT copy/destruction.
+ * Used for LDT initialization/destruction. You cannot copy an LDT with
+ * init_new_context, since it thinks you are passing it a new LDT and won't
+ * deallocate its old content.
  */
 int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
 void destroy_context(struct mm_struct *mm);
 
+/* LDT initialization for a clean environment - needed for SKAS. */
+static inline void init_new_empty_context(struct mm_struct *mm)
+{
+	init_MUTEX(&mm->context.sem);
+	mm->context.size = 0;
+}
+
+/* LDT copy for SKAS - for the above problem.*/
+int copy_context(struct mm_struct *mm, struct mm_struct *old_mm);
 
 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 {
@@ -38,6 +50,10 @@
 {
 	int cpu = smp_processor_id();
 
+#ifdef CONFIG_SMP
+	prev = per_cpu(cpu_tlbstate, cpu).active_mm;
+#endif
+
 	if (likely(prev != next)) {
 		/* stop flush ipis for the previous mm */
 		cpu_clear(cpu, prev->cpu_vm_mask);
@@ -59,7 +75,6 @@
 #ifdef CONFIG_SMP
 	else {
 		per_cpu(cpu_tlbstate, cpu).state = TLBSTATE_OK;
-		BUG_ON(per_cpu(cpu_tlbstate, cpu).active_mm != next);
 
 		if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) {
 			/* We were in lazy tlb mode and leave_mm disabled 
include/asm-i386/proc_mm.h new file +18 -0
Index: i686-loki/include/asm-i386/proc_mm.h
===================================================================
@@ -0,0 +1,18 @@
+#ifndef __ASM_PROC_MM
+#define __ASM_PROC_MM
+
+#include <asm/page.h>
+
+extern long do_mmap2(struct mm_struct *mm, unsigned long addr,
+		unsigned long len, unsigned long prot, unsigned long flags,
+		unsigned long fd, unsigned long pgoff);
+
+static inline long __do_mmap(struct mm_struct *mm, unsigned long addr,
+		     unsigned long len, unsigned long prot,
+		     unsigned long flags, unsigned long fd,
+		     unsigned long off)
+{
+	return do_mmap2(mm, addr, len, prot, flags, fd, off >> PAGE_SHIFT);
+}
+
+#endif /* __ASM_PROC_MM */
include/asm-i386/ptrace.h +29 -0
Index: i686-loki/include/asm-i386/ptrace.h
===================================================================
@@ -60,4 +60,33 @@
 extern unsigned long profile_pc(struct pt_regs *regs);
 #endif /* __KERNEL__ */
 
+/*For SKAS3 support.*/
+#ifndef _LINUX_PTRACE_STRUCT_DEF
+#define _LINUX_PTRACE_STRUCT_DEF
+
+#define PTRACE_FAULTINFO	  52
+/* 53 was used for PTRACE_SIGPENDING, don't reuse it. */
+#define PTRACE_LDT		  54
+#define PTRACE_SWITCH_MM 	  55
+#define PTRACE_EX_FAULTINFO	  56
+
+struct ptrace_faultinfo {
+	int is_write;
+	unsigned long addr;
+};
+
+struct ptrace_ex_faultinfo {
+	int is_write;
+	unsigned long addr;
+	int trap_no;
+};
+
+struct ptrace_ldt {
+	int func;
+  	void *ptr;
+	unsigned long bytecount;
+};
+
+#endif /*ifndef _LINUX_PTRACE_STRUCT_DEF*/
+
 #endif
include/asm-x86_64/desc.h +3 -0
Index: i686-loki/include/asm-x86_64/desc.h
===================================================================
@@ -169,6 +169,9 @@
 
 extern struct desc_ptr idt_descr;
 
+extern int __modify_ldt(struct mm_struct * mm, int func, void __user *ptr,
+		unsigned long bytecount);
+
 #endif /* !__ASSEMBLY__ */
 
 #endif
include/asm-x86_64/mmu_context.h +18 -2
Index: i686-loki/include/asm-x86_64/mmu_context.h
===================================================================
@@ -8,13 +8,28 @@
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
 #include <asm-generic/mm_hooks.h>
+#include <asm/semaphore.h>
 
 /*
  * possibly do the LDT unload here?
+ * Used for LDT initialization/destruction. You cannot copy an LDT with
+ * init_new_context, since it thinks you are passing it a new LDT and won't
+ * deallocate its old content.
  */
+
 int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
 void destroy_context(struct mm_struct *mm);
 
+/* LDT initialization for a clean environment - needed for SKAS.*/
+static inline void init_new_empty_context(struct mm_struct *mm)
+{
+	init_MUTEX(&mm->context.sem);
+	mm->context.size = 0;
+}
+
+/* LDT copy for SKAS - for the above problem.*/
+int copy_context(struct mm_struct *mm, struct mm_struct *old_mm);
+
 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 {
 #ifdef CONFIG_SMP
@@ -32,6 +47,9 @@
 			     struct task_struct *tsk)
 {
 	unsigned cpu = smp_processor_id();
+#ifdef CONFIG_SMP
+	prev = read_pda(active_mm);
+#endif
 	if (likely(prev != next)) {
 		/* stop flush ipis for the previous mm */
 		cpu_clear(cpu, prev->cpu_vm_mask);
@@ -48,8 +66,6 @@
 #ifdef CONFIG_SMP
 	else {
 		write_pda(mmu_state, TLBSTATE_OK);
-		if (read_pda(active_mm) != next)
-			out_of_line_bug();
 		if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) {
 			/* We were in lazy tlb mode and leave_mm disabled 
 			 * tlb flush IPI delivery. We must reload CR3
include/asm-x86_64/proc_mm.h new file +58 -0

58 lines not on this page · raw message

include/asm-x86_64/ptrace-abi.h +6 -0
Index: i686-loki/include/asm-x86_64/ptrace-abi.h
===================================================================
@@ -42,6 +42,12 @@
 #define PTRACE_GETFPXREGS         18
 #define PTRACE_SETFPXREGS         19
 
+#define PTRACE_FAULTINFO 52
+/* 53 was used for PTRACE_SIGPENDING, don't reuse it. */
+#define PTRACE_LDT 54
+#define PTRACE_SWITCH_MM 55
+#define PTRACE_EX_FAULTINFO	  56
+
 /* only useful for access 32bit programs */
 #define PTRACE_GET_THREAD_AREA    25
 #define PTRACE_SET_THREAD_AREA    26
include/asm-x86_64/ptrace.h +53 -0

59 lines not on this page · raw message

include/linux/mm.h +13 -2
Index: i686-loki/include/linux/mm.h
===================================================================
@@ -16,6 +16,8 @@
 #include <linux/debug_locks.h>
 #include <linux/backing-dev.h>
 #include <linux/mm_types.h>
+#include <linux/sched.h>
+#include <asm/current.h>
 
 struct mempolicy;
 struct anon_vma;
@@ -1069,9 +1071,15 @@
 
 extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
 
-extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
+extern unsigned long __do_mmap_pgoff(struct mm_struct *mm, struct file *file,
+				   unsigned long addr, unsigned long len,
+				   unsigned long prot, unsigned long flag,
+				   unsigned long pgoff);
+static inline unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
 	unsigned long len, unsigned long prot,
-	unsigned long flag, unsigned long pgoff);
+	unsigned long flag, unsigned long pgoff) {
+	return __do_mmap_pgoff(current->mm, file, addr, len, prot, flag, pgoff);
+}
 
 static inline unsigned long do_mmap(struct file *file, unsigned long addr,
 	unsigned long len, unsigned long prot,
@@ -1088,6 +1096,9 @@
 
 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
 
+extern long do_mprotect(struct mm_struct *mm, unsigned long start,
+			size_t len, unsigned long prot);
+
 extern unsigned long do_brk(unsigned long, unsigned long);
 
 /* filemap.c */
include/linux/proc_mm.h new file +113 -0

113 lines not on this page · raw message

localversion-skas new file +1 -0
Index: i686-loki/localversion-skas
===================================================================
@@ -0,0 +1 @@
+-skas3-v9-pre9
mm/Makefile +4 -0
Index: i686-loki/mm/Makefile
===================================================================
@@ -31,4 +31,8 @@
 obj-$(CONFIG_MIGRATION) += migrate.o
 obj-$(CONFIG_SMP) += allocpercpu.o
 obj-$(CONFIG_QUICKLIST) += quicklist.o
+obj-$(CONFIG_PROC_MM)	+= proc_mm.o
 
+ifeq ($(CONFIG_PROC_MM),y)
+obj-m			+= proc_mm-mod.o
+endif
mm/mmap.c +5 -5
Index: i686-loki/mm/mmap.c
===================================================================
@@ -889,11 +889,11 @@
  * The caller must hold down_write(current->mm->mmap_sem).
  */
 
-unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
-			unsigned long len, unsigned long prot,
-			unsigned long flags, unsigned long pgoff)
+unsigned long __do_mmap_pgoff(struct mm_struct *mm, struct file * file,
+			    unsigned long addr, unsigned long len,
+			    unsigned long prot, unsigned long flags,
+			    unsigned long pgoff)
 {
-	struct mm_struct * mm = current->mm;
 	struct vm_area_struct * vma, * prev;
 	struct inode *inode;
 	unsigned int vm_flags;
@@ -1175,7 +1175,7 @@
 	return error;
 }
 
-EXPORT_SYMBOL(do_mmap_pgoff);
+EXPORT_SYMBOL(__do_mmap_pgoff);
 
 /* Get an address range which is currently unmapped.
  * For shmat() with addr=0.
mm/mprotect.c +15 -5
Index: i686-loki/mm/mprotect.c
===================================================================
@@ -214,8 +214,9 @@
 	return error;
 }
 
-asmlinkage long
-sys_mprotect(unsigned long start, size_t len, unsigned long prot)
+long
+do_mprotect(struct mm_struct *mm, unsigned long start, size_t len,
+	     unsigned long prot)
 {
 	unsigned long vm_flags, nstart, end, tmp, reqprot;
 	struct vm_area_struct *vma, *prev;
@@ -245,9 +246,9 @@
 
 	vm_flags = calc_vm_prot_bits(prot);
 
-	down_write(&current->mm->mmap_sem);
+	down_write(&mm->mmap_sem);
 
-	vma = find_vma_prev(current->mm, start, &prev);
+	vma = find_vma_prev(mm, start, &prev);
 	error = -ENOMEM;
 	if (!vma)
 		goto out;
@@ -309,6 +310,15 @@
 		}
 	}
 out:
-	up_write(&current->mm->mmap_sem);
+	up_write(&mm->mmap_sem);
 	return error;
 }
+
+asmlinkage long sys_mprotect(unsigned long start, size_t len, unsigned long prot)
+{
+	long ret = do_mprotect(current->mm, start, len, prot);
+	/* A tail call would reorder parameters on the stack and they would then
+	 * be restored at the wrong places. */
+	prevent_tail_call(ret);
+	return ret;
+}
mm/proc_mm-mod.c new file +50 -0

50 lines not on this page · raw message

mm/proc_mm.c new file +299 -0

299 lines not on this page · raw message

Signature · 13 lines
`... in the sense that dragons logically follow evolution so they would
 be able to wield metal.' --- Kenneth Eng's colourless green ideas sleep
 furiously

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#2 lore raw
Quoted 1 line · Nix

... aaand Jeff solved it two days ago and I didn't notice. Er, oops?

Heh - it's good to have this in the list archives anyway. The only other place you'll find a mention of this is in the #uml logs, which I think most people won't find.

... and thanks for the skas update

Jeff

Signature · 11 lines
Work email - jdike at linux dot intel dot com

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
author
#3 lore raw

On 12 Jul 2007, Jeff Dike uttered the following:

Quoted 6 lines · Nix
Quoted 1 line

... aaand Jeff solved it two days ago and I didn't notice. Er, oops?

Heh - it's good to have this in the list archives anyway. The only other place you'll find a mention of this is in the #uml logs, which I think most people won't find.

Well, it was also implied by your patch which solved it, but I suppose now we have strings in the archives which people can google for in order to find the fix :)

Quoted 1 line

... and thanks for the skas update

(now runtime-tested, it works)

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#4 lore raw
In reply to Nix
Quoted 4 lines

Here, have a skas-v9-pre9 patch forward-ported to 2.6.22 in restitution of my idiocy.

Quoted 8 lines

(The 2.6.20 patch, the most recent I could find, collided with paravirt and the header-inclusion reduction work. My fix to the latter is especially ugly, since it means that <linux/mm.h> is including <asm/current.h> and <linux/sched.h> again. Probably the right fix is for do_mmap_pgoff() to no longer be inlined, but I'm not sure what performance implications that might have.)

Thanks for that.
For those who find it difficult to extract patches from emails (like me on a laptop), I've copied it here:
http://uml.nagafix.co.uk/skas-2.6.22-v9-pre9.patch.bz2
(also compile tested)

Anyone fancy doing the same work to v8? I remember having severe problems with v9...

Antoine

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel