Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp2425622pxf; Sat, 20 Mar 2021 15:54:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyJnpMIAq8ZqRxEdppkkxNCOrYAfJIi1jWr2t+aYaW/embO0vou3drlMJ6JBtJOmLcaSIj X-Received: by 2002:aa7:df86:: with SMTP id b6mr17737711edy.294.1616280844895; Sat, 20 Mar 2021 15:54:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616280844; cv=none; d=google.com; s=arc-20160816; b=Z2DCLILdJl6LKrHXlhCP3xnY7Rz+thn5jA2cv56hDIZFr6ArXNnvkmnLuWBV6YWQ1Y DKMfNx7kPghXnNSVpLSc51cMU1q1JMAiLYNaSY7E6ULqb4Mi+n2JK2zLOxF9sJTKigPv qvq6QU3RsKSSXZBcVeCZgPJOOf7HLI6iPSl20Kng5EqbY8UofxqJjcxsjdqakBPVVcTs w9dxEPqEanFbf5G6aE/Romp6JfK12myKz9xOheCznvA9trDCNjLfihgQECXPC8tDuBnr 1oc/Nzk+HnxkXBUegRKS8icmpTUWdHbjzFj/ys6AOzZ2XPDCt4pc2PCvm3mrVqMBRPeM R5sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=CP6XWAgVpuegbTUMFWEzWCVzLKWLQ4kM5wh2fwuAa3k=; b=bUbKPi3e18SEPe1dvXlnQvcpjzxxxeoR1mgR6EvTJGZHP7D+sMRTsrQRkLAT9FIg5S AruTqxbdyl5XMG4nTt1xMJJgOYZe6BRU5/zmQc0wN1Kb0clbni5o4tfe/FUDFFSlbuYx r5GFYLs9cR0Lg2eeSzRUeUsCvEEcRqGJucFU51Rgco8Of9gTssRfpdeF1lMg0nPsAYG5 REfiegasPPZZ5PO7MmXJU/1fRXqjBdAi6XuR1E7GjOuibpRqmFrhZlpqpRFUssuobPqf RmB0Hn0fHpta0Nz/5jPt8v5qNgKPCBkcFYHunbfFLPW+5WUd5HBVlfSHjzzREtB8+CJR OKWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=QCoTt0q8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lf1si7474533ejc.433.2021.03.20.15.53.43; Sat, 20 Mar 2021 15:54:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=QCoTt0q8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbhCTWm1 (ORCPT + 99 others); Sat, 20 Mar 2021 18:42:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbhCTWmM (ORCPT ); Sat, 20 Mar 2021 18:42:12 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 108E7C061574 for ; Sat, 20 Mar 2021 15:42:12 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id s21so6442214pjq.1 for ; Sat, 20 Mar 2021 15:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=CP6XWAgVpuegbTUMFWEzWCVzLKWLQ4kM5wh2fwuAa3k=; b=QCoTt0q8o50hCJ8UjJQemjoANIbbaJDpuwoPqbATB6EIz/Pc1vN3X3dOSSwWRYMSrc 7cmtlIO7o/9ZmKite6RZZc4mmsKvit/GK4IFTFH4gZ623/ccyPh389sYimYUUWVpHsHG AwgQu2we0zKfZXoNLiqsJlAZqIzTTIc2c5QdNsk7SiD8ugQjuiFpUWKr3s7VegBr5X1A ktzseNUXTTtGnCN21Ai41CmbWirMAGVSK45KLItke2XKfLxCNi+w9kQwM01NmsRv4Vgx z5oJ3HJteK0zPWM6lQrgkWy8g2TOMDagQQ5YtNa1Q0uJuFt13UQkkaIhCU7PsfHrm1cG pPzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CP6XWAgVpuegbTUMFWEzWCVzLKWLQ4kM5wh2fwuAa3k=; b=irPcJ3s0HE27xeqrfonVm/QnYb9IClRgcZynhQ+c59fA0cFA4ImyMp1+yQMMdmKOYY tVipYNa13GY8BMHte5VV5n1q8xhXd3f520AI/HHnmxXzC+gAkeNcggbHob12FkTOBFvY pcpedjohn/LP6yJnNtC8fe3ZR+F0hXVp6qoP52wJEJDbGTID8SIDNiaCYqTukb1v+8SW WWo1ZF/jXJRb0HsZtm1zHvzkm+p8ybQm2jDkTtZa+BmOMzUaQyGQmmjn3iX25juY7Lri gyXrkUmm/QpF2S/F2wZVe9QpO7LobamJ1YU1RI+NxPjkn1hfGNlTuuNc+ketIkPW8XFa ZS3A== X-Gm-Message-State: AOAM531kDibYA6AnKcBygwSULT9brJK6VvAkpl35yEvwok5ks5RETiPC CRchGMVxunY+9WJXo4WFbzkYOA== X-Received: by 2002:a17:90a:5898:: with SMTP id j24mr5336476pji.110.1616280131349; Sat, 20 Mar 2021 15:42:11 -0700 (PDT) Received: from [192.168.1.134] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id b9sm8679749pgn.42.2021.03.20.15.42.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 20 Mar 2021 15:42:10 -0700 (PDT) Subject: Re: [PATCH 1/2] signal: don't allow sending any signals to PF_IO_WORKER threads To: "Eric W. Biederman" , Linus Torvalds Cc: io-uring , Linux Kernel Mailing List , Oleg Nesterov , Stefan Metzmacher References: <20210320153832.1033687-1-axboe@kernel.dk> <20210320153832.1033687-2-axboe@kernel.dk> From: Jens Axboe Message-ID: <43f05d70-11a9-d59a-1eac-29adc8c53894@kernel.dk> Date: Sat, 20 Mar 2021 16:42:09 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/20/21 3:38 PM, Eric W. Biederman wrote: > Linus Torvalds writes: > >> On Sat, Mar 20, 2021 at 9:19 AM Eric W. Biederman wrote: >>> >>> The creds should be reasonably in-sync with the rest of the threads. >> >> It's not about credentials (despite the -EPERM). >> >> It's about the fact that kernel threads cannot handle signals, and >> then get caught in endless loops of "if (sigpending()) return >> -EAGAIN". >> >> For a normal user thread, that "return -EAGAIN" (or whatever) will end >> up returning an error to user space - and before it does that, it will >> go through the "oh, returning to user space, so handle signal" path. >> Which will clear sigpending etc. >> >> A thread that never returns to user space fundamentally cannot handle >> this. The sigpending() stays on forever, the signal never gets >> handled, the thread can't do anything. >> >> So delivering a signal to a kernel thread fundamentally cannot work >> (although we do have some threads that explicitly see "oh, if I was >> killed, I will exit" - think things like in-kernel nfsd etc). > > I agree that getting a kernel thread to receive a signal is quite > tricky. But that is not what the patch affects. > > The patch covers the case when instead of specifying the pid of the > process to kill(2) someone specifies the tid of a thread. Which implies > that type is PIDTYPE_TGID, and in turn the signal is being placed on the > t->signal->shared_pending queue. Not the thread specific t->pending > queue. > > So my question is since the signal is delivered to the process as a > whole why do we care if someone specifies the tid of a kernel thread, > rather than the tid of a userspace thread? Right, that's what this first patch does, and in all honesty, it's not required like the 2/2 patch is. I do think it makes it more consistent, though - the threads don't take signals, period. Allowing delivery from eg kill(2) and then pass it to the owning task of the io_uring is somewhat counterintuitive, and differs from earlier kernels where there was no relationsship between that owning task and the async worker thread. That's why I think the patch DOES make sense. These threads may share a personality with the owning task, but I don't think we should be able to manipulate them from userspace at all. That includes SIGSTOP, of course, but also regular signals. Hence I do think we should do something like this. -- Jens Axboe