Skip to contentSkip to conversation

Sparc

GIT David Miller 2 participants 9 messages Mar 29, 2010 – Oct 26, 2018

lore
Share & tools
lore
#0 lore raw

Please pull to get these Sparc fixes, thanks!

The following changes since commit b72c40949b0f04728f2993a1434598d3bad094ea:
Linus Torvalds (1):

        Merge branch 'for-linus' of git://git.kernel.org/.../jbarnes/pci-2.6

are available in the git repository at:

master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6.git master

David S. Miller (1):
sparc64: Properly truncate pt_regs framepointer in perf callback.

Julia Lawall (1):
arch/sparc/kernel: Use set_cpus_allowed_ptr

Rob Landley (1):
sparc: Fix use of uid16_t and gid16_t in asm/stat.h

 arch/sparc/include/asm/stat.h    |    4 ++--
 arch/sparc/kernel/perf_event.c   |    2 +-
 arch/sparc/kernel/sysfs.c        |    4 ++--
 arch/sparc/kernel/us2e_cpufreq.c |    8 ++++----
 arch/sparc/kernel/us3_cpufreq.c  |    8 ++++----
 5 files changed, 13 insertions(+), 13 deletions(-)
#1 lore raw

1) Build fix for LEON, from Sam Ravnborg.

2) Make the sparc side changes that go along with the infrastructure to retry faults when blocking on a disk transfer. From Kautuk Consul.

Please pull, thanks a lot!

The following changes since commit 64ebe987311853ea857a244439de5b947a4b1b07:

Merge tag 'pm-for-3.4-part-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm (2012-04-04 14:26:40 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git master

for you to fetch changes up to d657784b70ef653350d7aa49da90a8484c29da7d:

sparc32,leon: fix leon build (2012-04-04 15:44:39 -0700)

----------------------------------------------------------------
Kautuk Consul (2):
sparc/mm/fault_64.c: Port OOM changes to do_sparc64_fault sparc/mm/fault_32.c: Port OOM changes to do_sparc_fault

Sam Ravnborg (1):
sparc32,leon: fix leon build

 arch/sparc/kernel/leon_pci.c |   13 -------------
 arch/sparc/mm/fault_32.c     |   37 ++++++++++++++++++++++++++++++-------
 arch/sparc/mm/fault_64.c     |   37 ++++++++++++++++++++++++++++++-------
 3 files changed, 60 insertions(+), 27 deletions(-)
#2 lore raw
In reply to David Miller

1) Add finit_module syscall entry.

2) Remove stray __dev{init,exit} references, from Sam Ravnborg.

Please pull, thanks a lot!

The following changes since commit c4271c6e37c32105492cbbed35f45330cb327b94:

NFS: Kill fscache warnings when mounting without -ofsc (2012-12-21 08:32:09 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc master

for you to fetch changes up to b7c13f76fda994284521f6ef996119c25282bdeb:

sparc: remove __devinit, __devexit annotations (2013-01-12 15:28:45 -0800)

----------------------------------------------------------------
David S. Miller (1):
sparc: Hook up finit_module syscall.

Sam Ravnborg (1):
sparc: remove __devinit, __devexit annotations

 arch/sparc/include/asm/parport.h     |  6 +++---
 arch/sparc/include/asm/timer_64.h    |  2 +-
 arch/sparc/include/uapi/asm/unistd.h |  3 ++-
 arch/sparc/kernel/apc.c              |  4 ++--
 arch/sparc/kernel/auxio_64.c         |  2 +-
 arch/sparc/kernel/central.c          |  6 +++---
 arch/sparc/kernel/chmc.c             | 34 +++++++++++++++++-----------------
 arch/sparc/kernel/ds.c               |  5 ++---
 arch/sparc/kernel/ldc.c              |  2 +-
 arch/sparc/kernel/leon_pci.c         |  2 +-
 arch/sparc/kernel/leon_pci_grpci2.c  |  2 +-
 arch/sparc/kernel/pci.c              | 37 ++++++++++++++++++-------------------
 arch/sparc/kernel/pci_fire.c         |  6 +++---
 arch/sparc/kernel/pci_psycho.c       | 12 ++++++------
 arch/sparc/kernel/pci_sabre.c        |  9 ++++-----
 arch/sparc/kernel/pci_schizo.c       | 16 +++++++---------
 arch/sparc/kernel/pci_sun4v.c        | 15 +++++++--------
 arch/sparc/kernel/pcic.c             |  5 ++---
 arch/sparc/kernel/pmc.c              |  2 +-
 arch/sparc/kernel/power.c            |  4 ++--
 arch/sparc/kernel/smp_64.c           |  4 ++--
 arch/sparc/kernel/systbls_32.S       |  2 +-
 arch/sparc/kernel/systbls_64.S       |  4 ++--
 arch/sparc/kernel/time_32.c          |  2 +-
 arch/sparc/kernel/time_64.c          | 10 +++++-----
 arch/sparc/mm/init_64.c              |  6 +++---
 26 files changed, 98 insertions(+), 104 deletions(-)
#3 lore raw
In reply to David Miller

Sorry, accidently CC:'d linux-ide on this one initially :-)

Several bug fixes (from Kirill Tkhai, Geery Uytterhoeven, and Alexey Dobriyan) and some support for Fujitsu sparc64x chips (from Allen Pais).

Please pull, thanks a lot!

The following changes since commit 64ccccf8525fee499625b517c0faadf784c79e93:

Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux (2013-07-31 17:55:12 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git master

for you to fetch changes up to dc76f9ca71ea597dbb0e9c77d1072ddca651f4f3:

sparc64: Export flush_ptrace_access() (needed by lustre) (2013-09-05 12:12:51 -0700)

----------------------------------------------------------------
Alexey Dobriyan (1):
sparc: fix PCI device proc file mmap(2)

Allen Pais (2):
cpu hw caps support for sparc64x
support sparc64x chip type in cpumap.c

David S. Miller (2):
esp_scsi: Fix tag state corruption when autosensing.
sparc64: Fix off by one in trampoline TLB mapping installation loop.

Geert Uytterhoeven (1):
sparc64: Export flush_ptrace_access() (needed by lustre)

Kirill Tkhai (6):
sparc64: Fix wrong syscall return value passed to trace_sys_exit()
sparc32: Fix exit flag passed from traced sys_sigreturn
sparc64: cleanup: Rename ret_from_syscall to ret_from_fork
sparc64: Fix not SRA'ed %o5 in 32-bit traced syscall
sparc64: Fix ITLB handler of null page
sparc64: Remove RWSEM export leftovers

 arch/sparc/include/asm/switch_to_64.h |  4 ++--
 arch/sparc/kernel/cpumap.c            |  1 +
 arch/sparc/kernel/entry.S             |  2 +-
 arch/sparc/kernel/kgdb_64.c           |  4 ++--
 arch/sparc/kernel/ktlb.S              |  3 +--
 arch/sparc/kernel/ptrace_64.c         |  4 +++-
 arch/sparc/kernel/setup_64.c          | 12 ++++++++----
 arch/sparc/kernel/syscalls.S          | 12 ++++++------
 arch/sparc/kernel/trampoline_64.S     |  2 --
 arch/sparc/lib/ksyms.c                |  9 ---------
 drivers/scsi/esp_scsi.c               | 14 ++++++++------
 drivers/scsi/esp_scsi.h               |  1 +
 fs/proc/inode.c                       | 16 ++++++++++++++++
 13 files changed, 49 insertions(+), 35 deletions(-)
#4 lore raw
In reply to David Miller

Hi Dave!

Quoted 3 lines · David Miller

I've been moving so haven't had access to my Sparc boxes during this time. That's been resolved, and now I can get the patches flowing again.

Great to hear you're back!

Can I bring this bug [1] back to your attention which allowed a regular userland application to crash the kernel? Would be interesting to see whether you're able to reproduce the issue.

The offending binary is attached to the bug report. It's a test program from the testsuite of the Free Pascal Compiler which was recently ported to sparc64.

Thanks,
Adrian

Quoted 1 line

[1] https://bugzilla.kernel.org/show_bug.cgi?id 0625

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#5 lore raw
In reply to David Miller

From: John Paul Adrian Glaubitz <[email protected]>
Date: Mon, 8 Oct 2018 20:42:14 +0200

Quoted 12 lines

Hi Dave!

Quoted 3 lines · David Miller

I've been moving so haven't had access to my Sparc boxes during this time. That's been resolved, and now I can get the patches flowing again.

Great to hear you're back!

Can I bring this bug [1] back to your attention which allowed a regular userland application to crash the kernel? Would be interesting to see whether you're able to reproduce the issue.

Quoted 8 lines

The offending binary is attached to the bug report. It's a test program from the testsuite of the Free Pascal Compiler which was recently ported to sparc64.

Thanks,
Adrian

Quoted 1 line

[1] https://bugzilla.kernel.org/show_bug.cgi?id 0625

I'm looking at this now.

I cannot reproduce the system crash, but I definitely get the illegal instruction both with and without using strace. And those system log message don't show, it must be from some specific config option? Actually I don't see that "Kernel memory exposure" string anywhere in the standard upstream kernel.

Running under gdb the process is gone when the SIGILL arrives which means that a signal wasn't sent but rather the process was forefully exited by the kernel with SIGILL.

Only two things do that:

1) Failing register window faults (arch/sparc/kernel/process_64.c)
2) Invalid signal frames during signal delivery (arch/sparc/kernel/signal32, arch/sparc/kernel/signal_64.c)

This is a 64-bit ELF binary so my guess is setup_rt_frame().

I put some debugging in and I guessed wrong:

[   40.366945] [tweaklib2:428]: fault_in_user_windows() copy failed

Something definitely corrupted the stack and/or frame pointer in this code.

#6 lore raw
In reply to David Miller

From: David Miller <[email protected]>
Date: Thu, 25 Oct 2018 16:39:22 -0700 (PDT)

Quoted 8 lines

This is a 64-bit ELF binary so my guess is setup_rt_frame().

I put some debugging in and I guessed wrong:

[   40.366945] [tweaklib2:428]: fault_in_user_windows() copy failed

Something definitely corrupted the stack and/or frame pointer in this code.

What this amounts to is actually a very simple program:

davem@salty:/opt/davem/src/GIT/CRASH/kernel-crash-test$ readelf -h tweaklib2
 ...
  Entry point address:               0x1003d0

Entry point 0x1003d0, what's that:

davem@salty:/opt/davem/src/GIT/CRASH/kernel-crash-test$ objdump -d tweaklib2 | grep -A 1 1003d0
00000000001003d0 <SI_PRC_$$__FPC_DYNAMIC_PROC_START>:
  1003d0:       81 c3 e0 08     retl
  1003d4:       01 00 00 00     nop

An entry point which simply returns. So this program does nothing, main never gets called, we just return to the dynamic linker code that jumps to the program's entry point which isn't expected.

So the test case is simply:

davem@salty:/opt/davem/src/GIT/CRASH/kernel-crash-test$ cat test.s
        .text
        .align 4
        .globl _start
_start: retl
        nop
davem@salty:/opt/davem/src/GIT/CRASH/kernel-crash-test$ gcc -nostdlib -o test test.s
davem@salty:/opt/davem/src/GIT/CRASH/kernel-crash-test$ ./test
Segmentation fault
davem@salty:/opt/davem/src/GIT/CRASH/kernel-crash-test$ 

and nothing more.

So what happens when you return from _start like this? It ends up looping, adjusting the stack pointer up by 48 bytes every iteration. Eventually we push the stack pointer past the end of the stack mmap area and crash.

The loop is:

davem@salty:/opt/davem/src/GIT/CRASH/kernel-crash-test$ gdb ./test
 ...
(gdb) b *0x0000010000000290
Breakpoint 1 at 0x10000000290
(gdb) display/i $pc
1: x/i $pc
<error: No registers.>
(gdb) run
Starting program: /opt/davem/src/GIT/CRASH/kernel-crash-test/test

Breakpoint 1, 0x0000010000000290 in _start ()
1: x/i $pc
=> 0x10000000290 <_start+4>: nop
(gdb) stepi
0xfff0000100001550 in ?? ()
1: x/i $pc
=> 0xfff0000100001550: sethi %hi(0x113000), %g1
(gdb)
0xfff0000100001554 in ?? ()
1: x/i $pc
=> 0xfff0000100001554: xor %g1, -572, %g1
(gdb)
0xfff0000100001558 in ?? ()
1: x/i $pc
=> 0xfff0000100001558: add %l7, %g1, %g1
(gdb)
0xfff000010000155c in ?? ()
1: x/i $pc

=> 0xfff000010000155c:  jmp  %l0
   0xfff0000100001560:  add  %sp, 0x30, %sp

(gdb)
0xfff0000100001560 in ?? ()
1: x/i $pc
=> 0xfff0000100001560: add %sp, 0x30, %sp
(gdb)
0x000001000000028c in _start ()
1: x/i $pc
=> 0x1000000028c <_start>: retl
0x10000000290 <_start+4>: nop
(gdb)

And that's how we loop forever.

It should not crash the machine and here with an upstream kernel it does not for me.

#7 lore raw
In reply to David Miller

Hi Dave!

Thanks for the explanation!

Quoted 4 lines · David Miller

(...)
And that's how we loop forever.

It should not crash the machine and here with an upstream kernel it does not for me.

Interestingly, we couldn't reproduce the issue on the SPARC-T5 anymore either. It definitely crashes the Sun Fire 2000 used for development of the Free Pascal compiler though, just re-tested:

root@stadler:~/kernel-crash-test# strace ./tweaklib2 
execve("./tweaklib2", ["./tweaklib2"], 0x7feffaafb90 /* 22 vars */) = 0
brk(NULL)                               = 0x264000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xffff800100024000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "./tls/v9v/libtweaklib1.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "./tls/libtweaklib1.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "./v9v/libtweaklib1.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "./libtweaklib1.so", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\2\1\0\0\0\0\0\0\0\0\0\0\3\0+\0\0\0\1\0\0\0\0\0\0\310\360"..., 832) = 832
fstat64(3, {st_mode=S_IFREG|0755, st_size65312, ...}) = 0
getcwd("/root/kernel-crash-test", 128)  = 24
mmap(NULL, 1503776, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xffff800100128000
mprotect(0xffff800100188000, 1040384, PROT_NONE) = 0
mmap(0xffff800100286000, 57344, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5e000) = 0xffff800100286000
mmap(0xffff800100294000, 12832, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffff800100294000
close(3)                                = 0
mprotect(0xffff800100286000, 8192, PROT_READ) = 0
mprotect(0x252000, 8192, PROT_READ)     = 0
mprotect(0xffff800100122000, 8192, PROT_READ) = 0
getrlimit(RLIMIT_STACK, {rlim_cur�92*1024, rlim_max=RLIM64_INFINITY}) = 0
rt_sigaction(SIGFPE, {sa_handler=0xffff800100180e10, sa_mask=[], sa_flags=SA_SIGINFO}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 0xffff800100134ca8, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0xffff800100180e10, sa_mask=[], sa_flags=SA_SIGINFO}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 0xffff800100134ca8, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0xffff800100180e10, sa_mask=[], sa_flags=SA_SIGINFO}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 0xffff800100134ca8, 8) = 0
rt_sigaction(SIGILL, {sa_handler=0xffff800100180e10, sa_mask=[], sa_flags=SA_SIGINFO}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 0xffff800100134ca8, 8) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0
readlink("/proc/self/exe", "/root/kernel-crash-test/tweaklib"..., 255) = 33
rt_sigaction(SIGFPE, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, NULL, 0xffff800100134ca8, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, NULL, 0xffff800100134ca8, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, NULL, 0xffff800100134ca8, 8) = 0
rt_sigaction(SIGILL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, NULL, 0xffff800100134ca8, 8) = 0

And on the console:

sc> console -f
Warning: User < > currently has write permission to this console and forcibly removing them will terminate any current write actions and all work will be lost. Would you like to continue? [y/n]y Enter #. to return to ALOM.

[942798.597985] Unable to handle kernel paging request at virtual address 000000000153a000
[942798.598156] tsk->{mm,active_mm}->context = 0000000000000228
[942798.598253] tsk->{mm,active_mm}->pgd = ffff8007f5da8000
[942806.209845] rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
[942806.210036] rcu:    6-...0: (1 GPs behind) idle„a/1/0x4000000000000002 softirqƒ77262/8377263 fqs$66 
[942806.210137] rcu:    (detected by 3, tS37 jiffies, gW015461, q'50)

I will let you know whether your patch helps to address the problem.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#8 lore raw
In reply to David Miller

From: John Paul Adrian Glaubitz <[email protected]>
Date: Fri, 26 Oct 2018 14:41:53 +0200

Quoted 5 lines
Quoted 1 line

It should not crash the machine and here with an upstream kernel it does not for me.

Interestingly, we couldn't reproduce the issue on the SPARC-T5 anymore either. It definitely crashes the Sun Fire 2000 used for development of the Free Pascal compiler though, just re-tested:

I tested it on my Ultra45

Please reproduce with a vanilla upstream kernel. I think some of the local debian kernel patches might be causing this.

Also, wrt. freepascal, as I described in my email, the link of that binary is causing the NOP _start function to be set as the entry point.

That can't be right, whatever ends up as the entry point should end up calling 'main' so that the program actually runs.