Message ID | 570409DA.1060508@gmx.de (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
On Tue, 5 Apr 2016, Helge Deller wrote: > On 05.04.2016 19:36, Mikulas Patocka wrote: > > On Tue, 5 Apr 2016, Mikulas Patocka wrote: > > > >> Hi > >> > >> The patch "parisc: Use generic extable search and sort routines" makes the > >> kernel unable to load any modules. It fails with: > >> > >> module unix: Unknown relocation: 9 > >> modprobe: FATAL: Error inserting unix (/lib/modules/4.6.0-rc2/kernel/net/unix/unix.ko): Invalid module format > >> > >> When I revert the patch, the kernel 4.6-rc2 boots fine. > >> > >> Apparently, the function apply_relocate_add in arch/parisc/kernel/module.c > >> doesn't handle the new relocation type. > >> > >> Mikulas > > > > BTW. I'm using hppa64 binutils 2.21 to build the kernel. It generates the > > R_PARISC_PCREL32 relocation that the kernel module loader doesn't handle: > > > Can you try attached patch (untested) ? > > Helge I tried a similar patch, the system booted fine ... but then I discovered that the system boots fine no matter what value is written to *loc. Apparently, none of the modules trigger any exceptions in my configuration. I'll have to create a test module that triggers some exception. Mikulas -- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2016-04-05 2:54 PM, Helge Deller wrote: > + case R_PARISC_PCREL32: > + val -= (uint32_t) loc; > + *loc = val; > + break; PCREL32 for a 64-bit application is "symbol - PC - 8 + addend". Dave
On Tue, 5 Apr 2016, Mikulas Patocka wrote: > > > On Tue, 5 Apr 2016, Helge Deller wrote: > > > On 05.04.2016 19:36, Mikulas Patocka wrote: > > > On Tue, 5 Apr 2016, Mikulas Patocka wrote: > > > > > >> Hi > > >> > > >> The patch "parisc: Use generic extable search and sort routines" makes the > > >> kernel unable to load any modules. It fails with: > > >> > > >> module unix: Unknown relocation: 9 > > >> modprobe: FATAL: Error inserting unix (/lib/modules/4.6.0-rc2/kernel/net/unix/unix.ko): Invalid module format > > >> > > >> When I revert the patch, the kernel 4.6-rc2 boots fine. > > >> > > >> Apparently, the function apply_relocate_add in arch/parisc/kernel/module.c > > >> doesn't handle the new relocation type. > > >> > > >> Mikulas > > > > > > BTW. I'm using hppa64 binutils 2.21 to build the kernel. It generates the > > > R_PARISC_PCREL32 relocation that the kernel module loader doesn't handle: > > > > > > Can you try attached patch (untested) ? > > > > Helge > > I tried a similar patch, the system booted fine ... but then I discovered > that the system boots fine no matter what value is written to *loc. > > Apparently, none of the modules trigger any exceptions in my > configuration. > > I'll have to create a test module that triggers some exception. > > Mikulas Hmm - it's even more strange. I created a test kernel module that triggers an exception by using get_user with an invalid address (see the attached file exception.tar) On x86-64 the module loads fine, but on pa-risc it always crashes, even with older kernel version (I tried versions 2.6.39, 4.5 and 4.6-rc2 and I always get a crash). When I write a userspace code that triggers a fault in module unix.ko, by passing an invalid address to the ioctl syscall, the kernel also crashes. So, it seems that handling exceptions from modules never worked on pa-risc, it was just masked by the fact that exceptions from modules don't happen during normal use. Mikulas /* this will crash pa-risc kernel if it is compiled with CONFIG_UNIX=m */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> int main(void) { int s, r; s = socket(PF_UNIX, SOCK_STREAM, 0); if (s == -1) perror("socket"), exit(1); r = ioctl(s, SIOCOUTQ, 0x124); if (r == -1) perror("ioctl"), exit(1); return 0; }
On 06.04.2016 16:30, Mikulas Patocka wrote: >>>>> The patch "parisc: Use generic extable search and sort routines" makes the >>>>> kernel unable to load any modules. It fails with: >>>>> >>>>> module unix: Unknown relocation: 9 >>>>> modprobe: FATAL: Error inserting unix (/lib/modules/4.6.0-rc2/kernel/net/unix/unix.ko): Invalid module format >>>>> >>>>> When I revert the patch, the kernel 4.6-rc2 boots fine. >>>>> >>>>> Apparently, the function apply_relocate_add in arch/parisc/kernel/module.c >>>>> doesn't handle the new relocation type. >>>>> >>>>> Mikulas >>>> >>>> BTW. I'm using hppa64 binutils 2.21 to build the kernel. It generates the >>>> R_PARISC_PCREL32 relocation that the kernel module loader doesn't handle: >>> >>> Can you try attached patch (untested) ? >>> >>> Helge >> >> I tried a similar patch, the system booted fine ... but then I discovered >> that the system boots fine no matter what value is written to *loc. >> >> Apparently, none of the modules trigger any exceptions in my >> configuration. >> >> I'll have to create a test module that triggers some exception. >> >> Mikulas > > Hmm - it's even more strange. > > I created a test kernel module that triggers an exception by using > get_user with an invalid address (see the attached file exception.tar) I see there is a kernel module <sourcetree>/lib/test_user_copy.c as well. It seems to crash too. > On x86-64 the module loads fine, but on pa-risc it always crashes, even > with older kernel version (I tried versions 2.6.39, 4.5 and 4.6-rc2 and I > always get a crash). I don't fully trust the 4.5 kernel yet. I was working the last few days on trying to fix the FTRACE functions, but am seeing strange crashes too. Any chance that you can try 4.4-stable, just to make sure ? > When I write a userspace code that triggers a fault in module unix.ko, by > passing an invalid address to the ioctl syscall, the kernel also crashes. > > So, it seems that handling exceptions from modules never worked on > pa-risc, it was just masked by the fact that exceptions from modules don't > happen during normal use. I'll try to dig deeper as soon as I find time. Helge -- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c index b9d75d9..f3bfd6a 100644 --- a/arch/parisc/kernel/module.c +++ b/arch/parisc/kernel/module.c @@ -660,6 +660,10 @@ int apply_relocate_add(Elf_Shdr *sechdrs, } *loc = (*loc & ~0x3ff1ffd) | reassemble_22(val); break; + case R_PARISC_PCREL32: + val -= (uint32_t) loc; + *loc = val; + break; default: printk(KERN_ERR "module %s: Unknown relocation: %u\n",