Re: Oopses and invalid addresses under Hatari

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 10/04/19 10:07 AM, Michael Schmitz wrote:


A potentially good question is why kthread_probe_data() would return
NULL on 030:
----------------------------
/**
 * kthread_probe_data - speculative version of kthread_data()
 * @task: possible kthread task in question
 *
 * @task could be a kthread task.  Return the data value specified when it  * was created if accessible.  If @task isn't a kthread task or its data is  * inaccessible for any reason, %NULL is returned.  This function requires
 * that @task itself is safe to dereference.
 */
void *kthread_probe_data(struct task_struct *task)
{
        struct kthread *kthread = to_kthread(task);
        void *data = NULL;

        probe_kernel_read(&data, &kthread->data, sizeof(data));
        return data;
}
----------------------------

My guess would be that it's inaccessible, and warnings Hatari was
giving on every syscall are somehow related to it.


Had kthread->data been inaccessible, probe_kernel_read() would have taken a fault right there, wouldn't it?

The situation we encounter here (kthread->data == NULL) seems to have been anticipated by the designers of this 'speculative' read of kthread data. We still take a bus error, even though __probe_kernel_read() attempts to suppress that. Unfortunately, our bus_error030() is agnostic to that (at least in the corner case of either invalid MMU descriptor or write protect faults).

OK, I decided to bite the bullet and modify bus_error030() to allow falling through to do_page_fault if an invalid page read happens while page faults are disabled.

Patch:

commit 4260aafb69eacb846e871e63318eaefc225ab700
Author: Michael Schmitz <schmitzmic@xxxxxxxxx>
Date:   Wed Apr 10 17:54:47 2019 +1200

    m68k: kernel/traps.c - fix 030 bus error on __probe_kernel_read()

    __probe_kernel_read() attempts to bypass page fault handling on addresses     it probes. This is honoured by do_page_fault(), but bus_error030 does bypass     do_page_fault() in case of data faults on invalid pages (such as the unmapped
    zero page), and forces a bus error signal directly.

    Log cases where pagefault_disabled() is true when fault is taken on invalid
    pages.

    Fall through to do_page_fault() instead of forcing bus error in these cases.

    Signed-off-By: Michael Schmitz <schmitzmic@xxxxxxxxx>

diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c
index b2fd000..52f78b3 100644
--- a/arch/m68k/kernel/traps.c
+++ b/arch/m68k/kernel/traps.c
@@ -30,6 +30,7 @@
 #include <linux/init.h>
 #include <linux/ptrace.h>
 #include <linux/kallsyms.h>
+#include <linux/uaccess.h>

 #include <asm/setup.h>
 #include <asm/fpu.h>
@@ -555,7 +556,10 @@ static inline void bus_error030 (struct frame *fp)
                                       ssw & RW ? "read" : "write",
                                       fp->un.fmtb.daddr,
                                       space_names[ssw & DFC], fp->ptregs.pc);
-                               goto buserr;
+                               if (pagefault_disabled())
+                                       pr_err("Pagefault handler disabled!\n");
+                               else
+                                       goto buserr;
                        }
                        /* Don't try to do anything further if an exception was
                           handled. */

Resulting syslog:

[31197.530000] sysrq: SysRq : Show State
[31197.540000]   task                PC stack   pid father
[31197.550000] init            S    0     1      0 0x00000000
[31197.570000] Stack from 00821fcc:
[31197.570000]         0000000b efd81a7c 00000000 00000000 efd81a74 00000000 0000000a 800017ec
[31197.570000]         0000008e 0000008e 00000000 0200c00b e0be0080
[31197.600000] Call Trace:
[31197.620000] kthreadd        S    0     2      0 0x00000000
[31197.630000] Stack from 00829fcc:
[31197.630000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31197.630000]         00000000 00000000 00000000 20000000 00000000
[31197.660000] Call Trace:
[31197.680000] kworker/0:0     I    0     3      2 0x00000000
[31197.700000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31197.710000] Pagefault handler disabled!
[31197.720000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31197.740000] Pagefault handler disabled!
[31197.750000] Workqueue:    (null) (events)
[31197.770000] Stack from 0082bfcc:
[31197.770000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31197.770000]         00000000 00000000 00000000 20000000 00000000
[31197.790000] Call Trace:
[31197.800000] kworker/0:0H    I    0     4      2 0x00000000
[31197.820000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31197.830000] Pagefault handler disabled!
[31197.840000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31197.860000] Pagefault handler disabled!
[31197.870000] Stack from 0082dfcc:
[31197.870000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31197.870000]         00000000 00000000 00000000 20000000 00000000
[31197.910000] Call Trace:
[31197.930000] mm_percpu_wq    I    0     6      2 0x00000000
[31197.940000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31197.950000] Pagefault handler disabled!
[31197.960000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31197.980000] Pagefault handler disabled!
[31197.990000] Stack from 00833fcc:
[31197.990000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31197.990000]         00000000 00000000 00000000 20000000 00000000
[31198.010000] Call Trace:
[31198.020000] ksoftirqd/0     R  running task        0 7      2 0x00000000
[31198.040000] Stack from 00835fcc:
[31198.040000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.040000]         00000000 00000000 00000000 20000000 00000000
[31198.070000] Call Trace:
[31198.080000] kdevtmpfs       S    0     8      2 0x00000000
[31198.110000] Stack from 0083bfcc:
[31198.110000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.110000]         00000000 00000000 00000000 20000000 00000000
[31198.130000] Call Trace:
[31198.160000] kworker/u2:1    I    0     9      2 0x00000000
[31198.170000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31198.180000] Pagefault handler disabled!
[31198.190000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31198.210000] Pagefault handler disabled!
[31198.230000] Workqueue:    (null) (events_unbound)
[31198.240000] Stack from 00851fcc:
[31198.240000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.240000]         00000000 00000000 00000000 20000000 00000000
[31198.270000] Call Trace:
[31198.280000] oom_reaper      S    0    12      2 0x00000000
[31198.300000] Stack from 008affcc:
[31198.300000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.300000]         00000000 00000000 00000000 20000000 00000000
[31198.320000] Call Trace:
[31198.330000] kworker/0:1     I    0    13      2 0x00000000
[31198.350000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31198.360000] Pagefault handler disabled!
[31198.390000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31198.400000] Pagefault handler disabled!
[31198.410000] Stack from 008b9fcc:
[31198.410000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.410000]         00000000 00000000 00000000 20000000 00000000
[31198.430000] Call Trace:
[31198.450000] writeback       I    0    95      2 0x00000000
[31198.460000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31198.470000] Pagefault handler disabled!
[31198.490000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31198.500000] Pagefault handler disabled!
[31198.510000] Workqueue:    (null) (flush-3:0)
[31198.530000] Stack from 00865fcc:
[31198.530000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.530000]         00000000 00000000 00000000 20000000 00000000
[31198.550000] Call Trace:
[31198.570000] crypto          I    0    97      2 0x00000000
[31198.580000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31198.590000] Pagefault handler disabled!
[31198.600000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31198.610000] Pagefault handler disabled!
[31198.620000] Stack from 00873fcc:
[31198.620000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.620000]         00000000 00000000 00000000 20000000 00000000
[31198.650000] Call Trace:
[31198.660000] kblockd         I    0    99      2 0x00000000
[31198.680000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31198.690000] Pagefault handler disabled!
[31198.700000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31198.710000] Pagefault handler disabled!
[31198.720000] Workqueue:    (null) (kblockd)
[31198.730000] Stack from 0090dfcc:
[31198.730000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.730000]         00000000 00000000 00000000 20000000 00000000
[31198.750000] Call Trace:
[31198.760000] kswapd0         S    0   200      2 0x00000000
[31198.770000] Stack from 00931fcc:
[31198.770000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.770000]         00000000 00000000 00000000 20000000 00000000
[31198.810000] Call Trace:
[31198.820000] kworker/0:1H    I    0   761      2 0x00000000
[31198.840000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31198.850000] Pagefault handler disabled!
[31198.860000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31198.880000] Pagefault handler disabled!
[31198.890000] Workqueue:    (null) (kblockd)
[31198.900000] Stack from 00b3bfcc:
[31198.900000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.900000]         00000000 00000000 00000000 20000000 00000000
[31198.920000] Call Trace:
[31198.950000] jbd2/hda3-8     S    0   794      2 0x00000000
[31198.960000] Stack from 00b7ffcc:
[31198.960000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31198.960000]         00000000 00000000 00000000 20000000 00000000
[31198.990000] Call Trace:
[31199.010000] ext4-rsv-conver I    0   795      2 0x00000000
[31199.020000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31199.030000] Pagefault handler disabled!
[31199.060000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31199.070000] Pagefault handler disabled!
[31199.080000] Stack from 00b81fcc:
[31199.080000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31199.080000]         00000000 00000000 00000000 20000000 00000000
[31199.100000] Call Trace:
[31199.120000] portmap         S    0   982      1 0x00000000
[31199.140000] Stack from 00619fcc:
[31199.140000]         80008768 00000002 ffffffff 80008768 80092b08 c0126524 80008760 80008778
[31199.140000]         000000a8 000000a8 00000000 0208c00d a4580080
[31199.170000] Call Trace:
[31199.180000] syslogd         S    0  1070      1 0x00000000
[31199.190000] Stack from 0064ffcc:
[31199.190000]         00000014 efc2cd44 00000000 00000000 00000000 00000000 00000013 00000001
[31199.190000]         0000008e 0000008e 00000000 0200c00b e0be0080
[31199.210000] Call Trace:
[31199.220000] klogd           R  running task        0 1076      1 0x00000000
[31199.240000] Stack from 00749fcc:
[31199.240000]         00000000 800068fc 00000fff 00000000 80094888 00000041 00000000 800011f8
[31199.240000]         00000003 00000003 00000000 0204c00b 8a160080
[31199.270000] Call Trace:
[31199.280000] gpm             S    0  1086      1 0x00000000
[31199.310000] Stack from 00d37fcc:
[31199.310000]         00000002 800114c0 00000000 00000000 efc97cf2 00000002 00000001 efc97d26
[31199.310000]         0000008e 0000008e 00000000 0200c00f c0be0080
[31199.330000] Call Trace:
[31199.350000] inetd           S    0  1091      1 0x00000000
[31199.360000] Stack from 007f1fcc:
[31199.360000]         00000009 efc5cc22 00000000 00000000 00000000 efc5cca2 00000001 800015dc
[31199.360000]         0000008e 0000008e 00000000 0200c00b e0be0080
[31199.400000] Call Trace:
[31199.410000] lpd             S    0  1095      1 0x00000000
[31199.430000] Stack from 00c97fcc:
[31199.430000]         00000006 efbaaa66 00000000 00000000 00000000 00000006 efbaacd6 efbaaaea
[31199.430000]         0000008e 0000008e 00000000 0200c00b e0be0080
[31199.450000] Call Trace:
[31199.470000] sshd            S    0  1101      1 0x00000000
[31199.480000] Stack from 00d3ffcc:
[31199.480000]         00000006 8004f1d8 00000000 00000000 00000000 ffffffff 0000000a 8004f1d8
[31199.480000]         0000008e 0000008e 00000000 0200c023 70be0080
[31199.500000] Call Trace:
[31199.520000] rpc.statd       S    0  1106      1 0x00000000
[31199.530000] Stack from 00b95fcc:
[31199.530000]         00000400 efbb5cf4 00000000 00000000 00000000 80003f98 00000400 00000000
[31199.530000]         0000008e 0000008e 00000000 0200c00d c0be0080
[31199.550000] Call Trace:
[31199.560000] atd             S    0  1111      1 0x00000000
[31199.580000] Stack from 00c67fcc:
[31199.580000]         efa66b90 efa66b90 00000000 80093a88 80093a88 efa66d38 efa66c1c efa66ca4
[31199.580000]         000000a2 000000a2 00000000 0208c009 f30c0080
[31199.600000] Call Trace:
[31199.610000] cron            S    0  1114      1 0x00000000
[31199.620000] Stack from 00661fcc:
[31199.620000]         ef92dbe0 ef92dbe0 00000000 80001bc0 80094488 00000039 ef92dc6c ef92dcf4
[31199.620000]         000000a2 000000a2 00000000 0208c00a 830c0080
[31199.650000] Call Trace:
[31199.670000] getty           S    0  1120      1 0x00000000
[31199.690000] Stack from 0058dfcc:
[31199.690000]         00000000 ef8cad87 00000001 8000188c 80001310 00000000 00000003 ef8cadf0
[31199.690000]         00000003 00000003 00000000 0204c00b 8a160080
[31199.710000] Call Trace:
[31199.720000] getty           S    0  1121      1 0x00000000
[31199.740000] Stack from 006b9fcc:
[31199.740000]         00000000 ef940d87 00000001 8000188c 80001310 00000000 00000003 ef940df0
[31199.740000]         00000003 00000003 00000000 0204c00b 8a160080
[31199.770000] Call Trace:
[31199.790000] getty           S    0  1122      1 0x00000000
[31199.810000] Stack from 005a9fcc:
[31199.810000]         00000000 efa36d87 00000001 8000188c 80001310 00000000 00000003 efa36df0
[31199.810000]         00000003 00000003 00000000 0204c00b 8a160080
[31199.830000] Call Trace:
[31199.850000] getty           S    0  1123      1 0x00000000
[31199.870000] Stack from 00b6dfcc:
[31199.870000]         00000000 efa70d87 00000001 8000188c 80001310 00000000 00000003 efa70df0
[31199.870000]         00000003 00000003 00000000 0204c00b 8a160080
[31199.900000] Call Trace:
[31199.920000] getty           S    0  1124      1 0x00000000
[31199.940000] Stack from 006f1fcc:
[31199.940000]         00000000 efbe7d87 00000001 8000188c 80001310 00000000 00000003 efbe7df0
[31199.940000]         00000003 00000003 00000000 0204c00b 8a160080
[31199.960000] Call Trace:
[31199.980000] getty           S    0  1125      1 0x00000000
[31200.000000] Stack from 00559fcc:
[31200.000000]         00000000 efa3bd87 00000001 8000188c 80001310 00000000 00000003 efa3bdf0
[31200.000000]         00000003 00000003 00000000 0204c00b 8a160080
[31200.030000] Call Trace:
[31200.050000] kworker/u2:0    I    0  1272      2 0x00000000
[31200.060000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31200.070000] Pagefault handler disabled!
[31200.090000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31200.100000] Pagefault handler disabled!
[31200.110000] Stack from 005adfcc:
[31200.110000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31200.110000]         00000000 00000000 00000000 20000000 00000000
[31200.130000] Call Trace:
[31200.160000] sshd            S    0  1304   1101 0x00000000
[31200.180000] Stack from 0055bfcc:
[31200.180000]         00000005 ef821468 00000004 00000004 00000005 ef821498 00000000 80026594
[31200.180000]         00000003 00000003 00000000 0200c003 922e0080
[31200.210000] Call Trace:
[31200.220000] sshd            S    0  1306   1304 0x00000000
[31200.230000] Stack from 004abfcc:
[31200.230000]         0000000a 80056718 80056708 00000000 00000000 00000000 00000000 8000b3ea
[31200.230000]         0000008e 0000008e 00000000 0200c023 70be0080
[31200.250000] Call Trace:
[31200.270000] bash            S    0  1307   1306 0x00000000
[31200.280000] Stack from 00651fcc:
[31200.280000]         ffffffff eff45b00 00000002 ffffffff 00000000 c014b524 800934a8 80012518
[31200.280000]         00000007 00000007 00000000 0200c00e 1eda0080
[31200.310000] Call Trace:
[31200.330000] bash            R  running task        0  1308 1307 0x00000080
[31200.350000] Stack from 00c91fcc:
[31200.350000]         00000001 8008b408 00000002 00000002 8008b408 8008b408 0000000a c0146410
[31200.350000]         00000004 00000004 00000000 0200c00f ba8a0080
[31200.380000] Call Trace:
[31200.390000] kworker/u2:2    I    0  1310      2 0x00000000
[31200.400000] Data read fault at 0x00000004 in Super Data (pc=0x28a85e)
[31200.410000] Pagefault handler disabled!
[31200.430000] Data read fault at 0x0000005c in Super Data (pc=0x28a85e)
[31200.440000] Pagefault handler disabled!
[31200.460000] Workqueue:    (null) (events_unbound)
[31200.470000] Stack from 00c99fcc:
[31200.470000]         00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[31200.470000]         00000000 00000000 00000000 20000000 00000000
[31200.490000] Call Trace:
[31200.510000] Showing busy workqueues and worker pools:

I'm not really sure this is the output you'd expect to see, but it no longer crashes the parent shell at least.

You may want to give this a spin, to see whether it fixes your syscall errors.

Cheers,

    Michael





[Index of Archives]     [Video for Linux]     [Yosemite News]     [Linux S/390]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux