NetBSD-Bugs archive

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

kern/59502: *hci_init registers the pci intr before initialising the intr mutex



>Number:         59502
>Category:       kern
>Synopsis:       *hci_init registers the pci intr before initialising the intr mutex
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 02 08:15:00 +0000 2025
>Originator:     Damien Zammit
>Release:        10.99.12 RUMP ROAST
>Organization:
>Environment:
GNU zamhurd 0.9 GNU-Mach 1.8/Hurd-0.9 i686-AT386 GNU
(running rump)
>Description:
When the usb stack is initialised during runtime in userspace on a GNU/Hurd box, during the invocation of rump_init(), the program seg faults because another device sharing the same pci irq interrupts in between the pci registration of the *HCI interrupt handler and the call to mutex_init(), thus the *hci_intr() function is called and tries to enter an uninitialised mutex, causing a fault.

Please fix these race conditions, so we can continue using the great NetBSD kernel drivers in userspace.

Thanks,
>How-To-Repeat:
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <dlfcn.h>
#include <stdint.h>
#include <sys/io.h>
#include <mach.h>

#define _STANDALONE
#include <rump/rump_syscalls.h>
#include <rump/rump.h>
#include <rump/rumperrno2host.h>
#include <stddef.h>

int main()
{
  int fd;

  rump_init();
  rump_sys_reboot(0, NULL);
  return 0;
}

$ gcc -static -Wall -g -D_FILE_OFFSET_BITS=64 test-rumpusb.c -o test-rumpusb -Wl,--whole-archive -lrump -lrumpuser -lrumpdev -lrumpdev_usb -lrumpdev_pci -lrumpvfs -lrumpdev_pci_usbhc -lrumpvfs_nofifofs_pic -Wl,--no-whole-archive -lpthread -ldl -lpciaccess -lirqhelp -lz

(On a i386 GNU/Hurd system).
>Fix:
The mutex_init() call needs to be done before the call to pci_intr_alloc(), I think.



Home | Main Index | Thread Index | Old Index