From owner-freebsd-arch@FreeBSD.ORG Sat Jan 17 01:57:45 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DBA5116A4CE; Sat, 17 Jan 2004 01:57:45 -0800 (PST) Received: from gw.catspoiler.org (217-ip-163.nccn.net [209.79.217.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id A405643D4C; Sat, 17 Jan 2004 01:57:44 -0800 (PST) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.12.9p2/8.12.9) with ESMTP id i0H9va7E047876; Sat, 17 Jan 2004 01:57:40 -0800 (PST) (envelope-from truckman@FreeBSD.org) Message-Id: <200401170957.i0H9va7E047876@gw.catspoiler.org> Date: Sat, 17 Jan 2004 01:57:36 -0800 (PST) From: Don Lewis To: rwatson@FreeBSD.org In-Reply-To: MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii cc: arch@FreeBSD.org Subject: Re: Signal delivery to kernel threads/processes? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jan 2004 09:57:46 -0000 On 16 Jan, Robert Watson wrote: > > Bill Paul raised an interesting question with me recently -- he observed > that a userspace process running with root privileges could deliver a > signal to a kthread, and that this might produce undesired behavior. I > was sure that, at some point, we had a check disallowing this, but I don't > see it in either RELENG_4 or HEAD. Do we rely on the ability to > send/receive signals to interrupt kthreads, that we know of? While the > signal delivery itself doesn't make sense, waking up a tsleep() with > PCATCH could well be useful behavior. Should a kthread have to declare if > it wants to receive interruptions? Given plans, at some point, to make > kthreads be real threads, and be part of a kernel process, that would > raise some challenges for code relying on the ability to be interrupted > with a signal in kernel space, as signals generated by kill() are > targetted at processes, not threads. > > Any thoughts? It's tempting simply to add the following to cr_cansignal() > to at least disallow sourcing the signals in userspace: > > if (p->p_flag & P_SYSTEM) > return (EPERM); > > But I don't have a broad enough view of what goes on in the kernel to > reason about what disasters this might cause if signalling is relied on. The only thing I worried about is what happens to kthreads on shutdown. It looks like this is handled by kthread_suspend() which tells the thread that it has received a SIGSTOP, but this isn't done with the normal signal delivery mechanism.