Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp815449pxf; Thu, 25 Mar 2021 14:52:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx84TgGpnC80YzoKlpHG0oRhNsW8EbN3Tkb+8qrIqNeZBFr/gvZZNF/GQmbn6P0GnOyHp/k X-Received: by 2002:a17:906:fcc7:: with SMTP id qx7mr12033111ejb.486.1616709136858; Thu, 25 Mar 2021 14:52:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616709136; cv=none; d=google.com; s=arc-20160816; b=gCPSPGbWgjrw//qLcsNceOYL/r5XmIBMqSKwVRjVfDNPGfk8+XLbPYvTTUHHG+QS6d 3+izd1b/UXLGlVmDW54NKjHBhetP4YQkZ2xE9EIG8ABP0ue/GpRWj7TJiHQ7VknRMbnO +MXAGrFaLlguSPD9M+Tw6MhVroEVSSX3LKBkesKMcbmEdPKwqRbdAEAXyYIv2Rb/8JeR reK/kYBjSIXV5H4ZD6pA3M2oKCXig1QMX+ct4uUWxsiYTqC6UyWOfLiqRQycguQc0Ycz quNPXT975qnPJhXBwz4cS2ljpoeznQ5VSJLoM3xOt7oSqdNMGz77V6GeC3+1CP+BKmD0 pW7Q== 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=WQol3I8KDADeHPFfgCWBy9/yOmLYynHOdYXdfaAWvrI=; b=I6eCOgj04rxRav/43q4SECJMXV5XfoO8lKslQmLNcbpuFramjkcumJvVMqFGE/8q30 HwXPYJBvuxAFIubIlkhxdSk+H05TVLtqj3nv0Bu3ev9wcgMGpML3e7jYiCfFGamXowz1 TnjHYdwjGf91nOvaXC43ZX+UhxL8Vkm8M4eVJ2kQhHv6C0P2OMUF8bLfr0hPmZRsC7hL 7gS7e8VFf4Jh/UlhLfdBTrQ7V1/WEgakcwNYKqL10QKhlxv1aaCDsIYZ3vUrJF9uVY8+ RZFAsM+VFvP4SyAHWHJ3p/UDkp3jAjO3MVNwwEp6ZIIBwYwZtXmR/rGHkiIuSZQ/4tx5 4sHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=eFmiQKcr; 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 jg25si5143546ejc.50.2021.03.25.14.51.54; Thu, 25 Mar 2021 14:52:16 -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=eFmiQKcr; 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 S230509AbhCYVup (ORCPT + 99 others); Thu, 25 Mar 2021 17:50:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbhCYVuN (ORCPT ); Thu, 25 Mar 2021 17:50:13 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A331EC06175F for ; Thu, 25 Mar 2021 14:50:13 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id k23-20020a17090a5917b02901043e35ad4aso3274898pji.3 for ; Thu, 25 Mar 2021 14:50:13 -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=WQol3I8KDADeHPFfgCWBy9/yOmLYynHOdYXdfaAWvrI=; b=eFmiQKcrCQ2pUVCzc1+fSr2A17ZRi0O4dsrJoyFpidImI1SHtbGT/9T9KLUbcgwFcN xWgL6omSsunAmIbhxOfZdPWkpQNtApo3k2oaaKT0KwubLXKrDgFhervwjtH18OsaLDwL 1AajzvU0b6nR0zW9ymqbXJnWc3qtXbJuS8s4CzpkiIjG9jE279WVHjOB6z/TRl+80n1/ iwohZPPvhPLi6jJTxtBiiLL97fAajFhJpNHOTK0/KOXHtngS87+r3LijijqL0dYFPhWs /EYl66jklev7oTR0LA21aIqkSyIxlSz4vzVmX5FaoXdx7XEh3wH6HvQ836D9SrFH2aj/ fgXA== 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=WQol3I8KDADeHPFfgCWBy9/yOmLYynHOdYXdfaAWvrI=; b=FnqSEoqob8M0WCpcECsNjgm6C1I8ISAX+5oXrrHAmGYF/EqyR2PxzaEIAQUJlJgJ6h Iju/bO7ZjOIVHkbjmyVLzoEtx4BBL5IRF7wbUfD1BwpQvfpK8WRWAbXiomKOKj829+0f YycqFL3cj6z3DJ0T0fkd5IegM0G5y0Z8+eB+tL+w7l4/oDlRmDp4Tb3jS8lGoCmwFug8 R1uRDJr1G3wMClkEiKLxJX1WAPVNyphLmpBEcNSBvKeKbiamztp/laFcUMEbaXXbVLL1 B5W3WBaqkrMtE5vjoMMn+2rc7d+bm/S56rHOnXjXAYdYxX7kBrvePZB0X8XjHPFC+lFB FpnQ== X-Gm-Message-State: AOAM530Z/bwvNLeyFPjXLoFrsvRn8ynvPiq3jyfBp0EBlUvRD0zrFGeT J3bNVrThmDAtjIZZ4C5cZBAHcA== X-Received: by 2002:a17:90b:d85:: with SMTP id bg5mr10558372pjb.230.1616709013104; Thu, 25 Mar 2021 14:50:13 -0700 (PDT) Received: from [192.168.1.134] ([66.219.217.173]) by smtp.gmail.com with ESMTPSA id t22sm6514889pjw.54.2021.03.25.14.50.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Mar 2021 14:50:12 -0700 (PDT) Subject: Re: [PATCH 0/2] Don't show PF_IO_WORKER in /proc//task/ To: "Eric W. Biederman" , Linus Torvalds Cc: io-uring , Linux Kernel Mailing List , Oleg Nesterov , Stefan Metzmacher References: <20210325164343.807498-1-axboe@kernel.dk> From: Jens Axboe Message-ID: <0f24896f-eef5-508f-8177-a6b5abf59cc6@kernel.dk> Date: Thu, 25 Mar 2021 15:50:11 -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/25/21 2:43 PM, Eric W. Biederman wrote: > Linus Torvalds writes: > >> On Thu, Mar 25, 2021 at 12:42 PM Linus Torvalds >> wrote: >>> >>> On Thu, Mar 25, 2021 at 12:38 PM Linus Torvalds >>> wrote: >>>> >>>> I don't know what the gdb logic is, but maybe there's some other >>>> option that makes gdb not react to them? >>> >>> .. maybe we could have a different name for them under the task/ >>> subdirectory, for example (not just the pid)? Although that probably >>> messes up 'ps' too.. >> >> Actually, maybe the right model is to simply make all the io threads >> take signals, and get rid of all the special cases. >> >> Sure, the signals will never be delivered to user space, but if we >> >> - just made the thread loop do "get_signal()" when there are pending signals >> >> - allowed ptrace_attach on them >> >> they'd look pretty much like regular threads that just never do the >> user-space part of signal handling. >> >> The whole "signals are very special for IO threads" thing has caused >> so many problems, that maybe the solution is simply to _not_ make them >> special? > > The special case in check_kill_permission is certainly unnecessary. > Having the signal blocked is enough to prevent signal_pending() from > being true. > > > The most straight forward thing I can see is to allow ptrace_attach and > to modify ptrace_check_attach to always return -ESRCH for io workers > unless ignore_state is set causing none of the other ptrace operations > to work. > > That is what a long running in-kernel thread would do today so > user-space aka gdb may actually cope with it. > > > We might be able to support if io workers start supporting SIGSTOP but I > am not at all certain. See patch just send out as a POC, mostly, not fully sanitized yet. But I did try to return -ESRCH from ptrace_check_attach() if it's an IO thread and ignore_state isn't set: if (!ignore_state && child->flags & PF_IO_WORKER) return -ESRCH; and that causes gdb to abort at that thread. For the same test case as in the previous email, you get: Attaching to process 358 [New LWP 359] [New LWP 360] [New LWP 361] Couldn't get CS register: No such process. (gdb) 0x00007ffa58537125 in ?? () (gdb) bt #0 0x00007ffa58537125 in ?? () #1 0x0000000000000000 in ?? () (gdb) info threads Id Target Id Frame * 1 LWP 358 "io_uring" 0x00007ffa58537125 in ?? () 2 LWP 359 "iou-mgr-358" Couldn't get registers: No such process. (gdb) q A debugging session is active. Inferior 1 [process 358] will be detached. Quit anyway? (y or n) y Couldn't write debug register: No such process. where 360 here is a regular pthread created thread, and 361 is another iou-mgr-x task. While gdb behaves better in this case, it does still prevent you from inspecting thread 3 which would be totally valid. -- Jens Axboe