NetBSD Problem Report #59502

From www@netbsd.org  Wed Jul  2 08:11:32 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id EC61E1A923C
	for <gnats-bugs@gnats.NetBSD.org>; Wed,  2 Jul 2025 08:11:31 +0000 (UTC)
Message-Id: <20250702081130.77BDB1A923E@mollari.NetBSD.org>
Date: Wed,  2 Jul 2025 08:11:30 +0000 (UTC)
From: damien@zamaudio.com
Reply-To: damien@zamaudio.com
To: gnats-bugs@NetBSD.org
Subject: *hci_init registers the pci intr before initialising the intr mutex 
X-Send-Pr-Version: www-1.0

>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.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.