Richard Weinberger | 10 Dec 14:02 2014
Picon

[PATCH] um: Skip futex_atomic_cmpxchg_inatomic() test

futex_atomic_cmpxchg_inatomic() does not work on UML because
it triggers a copy_from_user() in kernel context.
On UML copy_from_user() can only be used if the kernel was called
by a real user space process such that UML can use ptrace()
to fetch the value.

Reported-by: Miklos Szeredi <miklos <at> szeredi.hu>
Suggested-by: Geert Uytterhoeven <geert <at> linux-m68k.org>
Signed-off-by: Richard Weinberger <richard <at> nod.at>
---
 arch/um/Kconfig.common | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index 87bc868..d195a87 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
 <at>  <at>  -3,6 +3,7  <at>  <at>  config UML
 	default y
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_UID16
+	select HAVE_FUTEX_CMPXCHG if FUTEX
 	select GENERIC_IRQ_SHOW
 	select GENERIC_CPU_DEVICES
 	select GENERIC_IO
--

-- 
2.1.0

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
(Continue reading)

Toralf Förster | 19 Nov 18:06 2014
Picon
Picon

starting an UML image sometimes failed, next (identical) attempt works

/me wonders, why the same call few seconds later works (current git kernel), but not for the first time :

$ nice start_uml.sh -r trinity 
+ /usr/local/bin/linux-v3.18-rc4 earlyprintk ubda=/home/tfoerste/virtual/uml/trinity
ubdb=/mnt/ramdisk/trinity_swap eth0=tuntap,tap0,72:ef:3d:9f:c3:5a mem=2000M con0=fd:0,fd:1
con=pts umid=uml_trinity rootfstype=ext4 softlockup_all_cpu_backtrace=1

Locating the bottom of the address space ... 0x1000
Locating the top of the address space ... 0xc0000000
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 environment variables for a tempdir...none found
Checking if /dev/shm is on tmpfs...OK
Checking PROT_EXEC mmap in /dev/shm...OK
Checking for the skas3 patch in the host:
  - /proc/mm...not found: No such file or directory
  - PTRACE_FAULTINFO...not found
  - PTRACE_LDT...not found
UML running in SKAS0 mode
Adding 28835840 bytes to physical memory to account for exec-shield gap
Kernel virtual memory size shrunk to 953155584 bytes
bootconsole [earlycon0] enabled
PID hash table entries: 4096 (order: 2, 16384 bytes)
Dentry cache hash table entries: 262144 (order: 8, 1048576 bytes)
Inode-cache hash table entries: 131072 (order: 7, 524288 bytes)
Memory: 2022804K/2076160K available (4848K kernel code, 310K rwdata, 1784K rodata, 118K init, 240K bss,
(Continue reading)

Thomas Meyer | 19 Oct 17:09 2014
Picon

[PATCH v3 2/3] um: add a kmsg_dumper


Add a kmsg_dumper, that dumps the kmsg buffer to stdout, when no
console is available.
This an enables the printing of early panic() calls triggered in
uml_postsetup().

Signed-off-by: Thomas Meyer <thomas <at> m3y3r.de>
---

diff -r ee0ba83fd81e arch/um/kernel/Makefile
--- a/arch/um/kernel/Makefile	Sat Oct 11 18:55:17 2014 +0200
+++ b/arch/um/kernel/Makefile	Sun Oct 12 14:42:48 2014 +0200
 <at>  <at>  -13,7 +13,7  <at>  <at> 
 obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \
 	physmem.o process.o ptrace.o reboot.o sigio.o \
 	signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o \
-	um_arch.o umid.o maccess.o skas/
+	um_arch.o umid.o maccess.o kmsg_dump.o skas/

 obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
 obj-$(CONFIG_GPROF)	+= gprof_syms.o
diff -r ee0ba83fd81e arch/um/kernel/kmsg_dump.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/arch/um/kernel/kmsg_dump.c	Sun Oct 12 14:42:48 2014 +0200
 <at>  <at>  -0,0 +1,43  <at>  <at> 
+#include <linux/kmsg_dump.h>
+#include <linux/console.h>
+#include <shared/init.h>
+#include <shared/kern.h>
+#include <os.h>
(Continue reading)

Thomas Meyer | 19 Oct 17:14 2014
Picon

[PATCH v3 3/3] um: enable trace irqflags support

Add TRACE_IRQFLAGS_SUPPORT to UML.
This enables LOCKDEP_SUPPORT and TRACING_SUPPORT.

Signed-off-by: Thomas Meyer <thomas <at> m3y3r.de>
---
diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index 87bc868..6a33c3a 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
 <at>  <at>  -28,10 +28,9  <at>  <at>  config PCI
 config PCMCIA
 	bool

-# Yet to do!
 config TRACE_IRQFLAGS_SUPPORT
 	bool
-	default n
+	default y

 config LOCKDEP_SUPPORT
 	bool
diff --git a/arch/um/include/asm/irqflags.h b/arch/um/include/asm/irqflags.h
index c780d8a..c5b636e 100644
--- a/arch/um/include/asm/irqflags.h
+++ b/arch/um/include/asm/irqflags.h
 <at>  <at>  -34,9 +34,9  <at>  <at>  static inline unsigned long arch_local_irq_save(void)
 	return flags;
 }

-static inline bool arch_irqs_disabled(void)
(Continue reading)

Thomas Meyer | 19 Oct 17:08 2014
Picon

[PATCH v3 1/3] um: Move uml_postsetup in the init_thread stack


atomic_notifier_chain_register() and uml_postsetup() do call kernel code
that rely on the current macro and a valid task_struct resp. thread_info struct.

Signed-off-by: Thomas Meyer <thomas <at> m3y3r.de>
---

diff --git a/arch/um/include/shared/as-layout.h b/arch/um/include/shared/as-layout.h
index 41c8c77..ca1843e 100644
--- a/arch/um/include/shared/as-layout.h
+++ b/arch/um/include/shared/as-layout.h
 <at>  <at>  -56,6 +56,7  <at>  <at>  extern unsigned long brk_start;
 extern unsigned long host_task_size;

 extern int linux_main(int argc, char **argv);
+extern void uml_finishsetup(void);

 struct siginfo;
 extern void (*sig_info[])(int, struct siginfo *si, struct uml_pt_regs *);
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 016adf0..ab72560 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
 <at>  <at>  -247,6 +247,16  <at>  <at>  static struct notifier_block panic_exit_notifier = {
 	.priority 		= 0
 };

+void uml_finishsetup(void)
+{
+	atomic_notifier_chain_register(&panic_notifier_list,
(Continue reading)

Thomas Meyer | 13 Oct 23:48 2014
Picon

kernel stalls in balance_dirty_pages_ratelimited()

#0  balance_dirty_pages_ratelimited (mapping=0x792cc618) at mm/page-writeback.c:1587
#1  0x00000000600ba54f in do_wp_page (mm=<optimized out>, vma=<optimized out>, address=<optimized
out>, page_table=<optimized out>, pmd
=<optimized out>, orig_pte=..., ptl=<optimized out>) at mm/memory.c:2178
#2  0x00000000600bc986 in handle_pte_fault (flags=<optimized out>, pmd=<optimized out>,
pte=<optimized out>, address=<optimized out>, v
ma=<optimized out>, mm=<optimized out>) at mm/memory.c:3230
#3  __handle_mm_fault (flags=<optimized out>, address=<optimized out>, vma=<optimized out>,
mm=<optimized out>) at mm/memory.c:3335
#4  handle_mm_fault (mm=<optimized out>, vma=0x78008e88, address=1462695424, flags=<optimized
out>) at mm/memory.c:3364
#5  0x0000000060028cec in handle_page_fault (address=1462695424, ip=<optimized out>,
is_write=<optimized out>, is_user=0, code_out=<opt
imized out>) at arch/um/kernel/trap.c:75
#6  0x00000000600290d7 in segv (fi=..., ip=1228924391, is_user=<optimized out>, regs=0x624f5728) at arch/um/kernel/trap.c:222
#7  0x0000000060029395 in segv_handler (sig=<optimized out>, unused_si=<optimized out>,
regs=<optimized out>) at arch/um/kernel/trap.c:
191
#8  0x0000000060039c0f in userspace (regs=0x624f5728) at arch/um/os-Linux/skas/process.c:429
#9  0x0000000060026a8c in fork_handler () at arch/um/kernel/process.c:149
#10 0x0000000000000000 in ?? ()

backing_dev_info:
p *mapping->backing_dev_info
$2 = {bdi_list = {next = 0x605901a0 <bdi_list>, prev = 0x80a42890}, ra_pages = 32, state = 8, capabilities =
4, congested_fn = 0x0, con
gested_data = 0x0, name = 0x604fb827 "block", bdi_stat = {{count = 4}, {count = 0}, {count = 318691}, {count
= 314567}}, bw_time_stamp
= 4339445229, dirtied_stamp = 318686, written_stamp = 314564, write_bandwidth = 166,
avg_write_bandwidth = 164, dirty_ratelimit = 1, ba
(Continue reading)

Thomas Meyer | 12 Oct 14:39 2014
Picon

[PATCH v2 2/2] um: add a kmsg_dumper


Add a kmsg_dumper, that dumps the kmsg buffer to stdout, when no
console is available.
This an enables the printing of early panic() calls triggered in
uml_postsetup().

Signed-off-by: Thomas Meyer <thomas <at> m3y3r.de>
---
 arch/um/drivers/ubd_kern.c  |  5 +++--
 arch/um/include/shared/os.h |  1 +
 arch/um/kernel/Makefile     |  2 +-
 arch/um/kernel/kmsg_dump.c  | 44 ++++++++++++++++++++++++++++++++++++++++++++
 arch/um/kernel/um_arch.c    |  2 ++
 arch/um/os-Linux/util.c     | 12 ++++++++++++
 6 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 arch/um/kernel/kmsg_dump.c

diff -r ee0ba83fd81e arch/um/kernel/Makefile
--- a/arch/um/kernel/Makefile	Sat Oct 11 18:55:17 2014 +0200
+++ b/arch/um/kernel/Makefile	Sun Oct 12 14:24:54 2014 +0200
 <at>  <at>  -13,7 +13,7  <at>  <at> 
 obj-y = config.o exec.o exitcode.o irq.o ksyms.o mem.o \
 	physmem.o process.o ptrace.o reboot.o sigio.o \
 	signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o \
-	um_arch.o umid.o maccess.o skas/
+	um_arch.o umid.o maccess.o kmsg_dump.o skas/

 obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
 obj-$(CONFIG_GPROF)	+= gprof_syms.o
diff -r ee0ba83fd81e arch/um/kernel/kmsg_dump.c
(Continue reading)

Thomas Meyer | 12 Oct 14:39 2014
Picon

[PATCH v2 1/2] um: Move uml_postsetup in the init_thread stack


atomic_notifier_chain_register() and uml_postsetup() do call kernel code
that rely on the current macro and a valid task_struct resp. thread_info struct.

Signed-off-by: Thomas Meyer <thomas <at> m3y3r.de>
---
 arch/um/include/shared/as-layout.h |  1 +
 arch/um/kernel/um_arch.c           | 15 ++++++++++-----
 arch/um/os-Linux/skas/process.c    |  2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/as-layout.h b/arch/um/include/shared/as-layout.h
index 41c8c77..ca1843e 100644
--- a/arch/um/include/shared/as-layout.h
+++ b/arch/um/include/shared/as-layout.h
 <at>  <at>  -56,6 +56,7  <at>  <at>  extern unsigned long brk_start;
 extern unsigned long host_task_size;

 extern int linux_main(int argc, char **argv);
+extern void uml_finishsetup(void);

 struct siginfo;
 extern void (*sig_info[])(int, struct siginfo *si, struct uml_pt_regs *);
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 016adf0..ab72560 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
 <at>  <at>  -247,6 +247,16  <at>  <at>  static struct notifier_block panic_exit_notifier = {
 	.priority 		= 0
 };
(Continue reading)

Thomas Meyer | 9 Oct 19:55 2014
Picon

[PATCH 2/2] um: add a kmsg_dumper


Add a kmsg_dumper, that dumps the kmsg buffer to stderr, when no
console is available.
This an enables the printing of early panic() calls triggered in
uml_postsetup().

Signed-off-by: Thomas Meyer <thomas <at> m3y3r.de>
---
 arch/um/drivers/ubd_kern.c  |  5 +++--
 arch/um/include/shared/os.h |  1 +
 arch/um/kernel/Makefile     |  2 +-
 arch/um/kernel/kmsg_dump.c  | 44 ++++++++++++++++++++++++++++++++++++++++++++
 arch/um/kernel/um_arch.c    |  2 ++
 arch/um/os-Linux/util.c     | 12 ++++++++++++
 6 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 arch/um/kernel/kmsg_dump.c

diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h
index 08eec0b..36741f4 100644
--- a/arch/um/include/shared/os.h
+++ b/arch/um/include/shared/os.h
 <at>  <at>  -238,6 +238,7  <at>  <at>  extern void setup_hostinfo(char *buf, int len);
 extern void os_dump_core(void) __attribute__ ((noreturn));
 extern void um_early_printk(const char *s, unsigned int n);
 extern void os_fix_helper_signals(void);
+extern int os_printf_stderr(const char *fmt, ...);

 /* time.c */
 extern void idle_sleep(unsigned long long nsecs);
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
(Continue reading)

Thomas Meyer | 9 Oct 19:54 2014
Picon

[PATCH 1/2] um: Move uml_postsetup in the init_thread stack


atomic_notifier_chain_register() and uml_postsetup() do call kernel code
that rely on the current macro and a valid task_struct resp. thread_info struct.

Signed-off-by: Thomas Meyer <thomas <at> m3y3r.de>
---
 arch/um/include/shared/as-layout.h |  1 +
 arch/um/kernel/um_arch.c           | 15 ++++++++++-----
 arch/um/os-Linux/skas/process.c    |  2 +-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/um/include/shared/as-layout.h b/arch/um/include/shared/as-layout.h
index 41c8c77..ca1843e 100644
--- a/arch/um/include/shared/as-layout.h
+++ b/arch/um/include/shared/as-layout.h
 <at>  <at>  -56,6 +56,7  <at>  <at>  extern unsigned long brk_start;
 extern unsigned long host_task_size;

 extern int linux_main(int argc, char **argv);
+extern void uml_finishsetup(void);

 struct siginfo;
 extern void (*sig_info[])(int, struct siginfo *si, struct uml_pt_regs *);
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 016adf0..ab72560 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
 <at>  <at>  -247,6 +247,16  <at>  <at>  static struct notifier_block panic_exit_notifier = {
 	.priority 		= 0
 };
(Continue reading)

Thomas Meyer | 3 Oct 01:21 2014
Picon

panic() call from non-kernel stack in uml_postsetup

Hi,

When you pass an initrd to UML and the size of the initrd is too big for
the current kernel memory, a panic() call is done with the message("Out
of memory").

But this message never hits the stdout as the following stack trace
dumps because there is no current_thread_info() in the UML stack, which
is still active at this time:

(gdb) bt
#0  dump_stack_print_info (log_lvl=0x6053f583 "\001d") at kernel/printk/printk.c:2979
#1  0x000000006047126b in __dump_stack () at lib/dump_stack.c:14
#2  dump_stack () at lib/dump_stack.c:50
#3  0x000000006046bf87 in panic	(fmt=<optimized out>) at kernel/panic.c:110
#4  0x0000000060010bc7 in ___alloc_bootmem (limit=<optimized out>, goal=<optimized out>,
align=<optimized out>, size=<optimized out>) a
t mm/bootmem.c:674
#5  __alloc_bootmem (size=55792228, align=<optimized out>, goal=<optimized out>) at mm/bootmem.c:696
#6  0x0000000060004eca in read_initrd () at arch/um/kernel/initrd.c:39
#7  0x0000000060004b71 in uml_postsetup	() at arch/um/kernel/um_arch.c:228
#8  linux_main (argc=<optimized out>, argv=0x7fffffffdf98) at arch/um/kernel/um_arch.c:377
#9  0x00000000600059db in main (argc=<optimized out>, argv=0x7fffffffdf98, envp=<optimized out>) at arch/um/os-Linux/main.c:156

So current_thread_info() will return the stack of the UML program
itself, which is an invalid struct thread_info:
thread info= 0x7fffffffc000

so the access to current->pid, will segfault as "current" is a macro for
current_thread_info()->task->pid and task is NULL.
(Continue reading)


Gmane