Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3132926pxy; Mon, 3 May 2021 16:15:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/Zps7vpIsm12Hg/AM+mTC8u2ep2TIuMjn86y3T4fi+VHqAYsIWIQPEQTG/J+tmX93rvlU X-Received: by 2002:a17:90a:5d14:: with SMTP id s20mr23197770pji.185.1620083754832; Mon, 03 May 2021 16:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620083754; cv=none; d=google.com; s=arc-20160816; b=w/aoyROv1lPrEG4Sh/iXPdoJvxF2i8x12ewHTPE8ALEqdP8Yn3cfD6+KcA5+v4z5Lo CcXTb0yyRXEa+GgK0sOH+6F4g8Ff8AO1g3ZPq+nSkvUqyFU6pmRxH7h6kpM9DcfL6gXm NvgOlDdu0vK1GMxAsDwKvbM18K7pClA5fqPQ73N3h34gSragjkT8bvdk6UdelPG8EIPH nXRtBCugU/VD63+6+9phn211lTrkpVwI6UQD3uSHLeTOhmcVPHR/wNDvFlimCENG+aM4 Zpl7mQbxRSKz3q7ejGWGPyebwX++TxtW7nn6V5H/vlZZuXDv/qHP5rvlFWNwlPy4/pPS jN9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=xhf/1dJduLOJCNe2AU9V1VQzCeL9nYRZSP5wzFlpp5w=; b=iNNp+FWz7KAgJmHmC+sNM/8Mz9Sj0DIEOVcMHEYEPp81oihdAR211mwRxd+gpC4w5X X91eH/ZHf2NkoLusBMIq2x50uEprHfzAgQLTnNeN/R5Aa1Tf5T++OXgCdCu/kAw9EX4k T02JKPktD2bwhrK0ZyIEaAofW/7fBJVVOZn7JbRkr1yiAaQL/RzU3pp8SJoLSWFamLNa uUoFln4NyEkYWliEBNzsOxDV4vWYDLNCn4kvorZG4HG9IAxR/gA/bNk1CZyvxO6t6lAJ 7rEZSESLB3m+zt/xMZZKx9zO+bsaJ6dmPqjdZwpodL/87dw8USQUuAe0oi+fWli3H/mv h3Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=gkXsOsEw; 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 r5si1186504plo.339.2021.05.03.16.15.40; Mon, 03 May 2021 16:15:54 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=gkXsOsEw; 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 S229876AbhECXQD (ORCPT + 99 others); Mon, 3 May 2021 19:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbhECXQC (ORCPT ); Mon, 3 May 2021 19:16:02 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05839C061574 for ; Mon, 3 May 2021 16:15:08 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id i190so5507898pfc.12 for ; Mon, 03 May 2021 16:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=xhf/1dJduLOJCNe2AU9V1VQzCeL9nYRZSP5wzFlpp5w=; b=gkXsOsEw7q9iyrOGQiFwqXE8RR5WxPF+OSd8fvDbxNDWbodCc3YZWiaoa98oBbEH8I Wk6Wje2UNgZhK5Yxw7mbLZb8tdi3Rp91YcOFAwutr2iujEWg7Q/xfcO2xmKTA0yUqKrz XQdQUANWPUtzmzqmaQvA232aY1/mIETJiJrMGzm8b+67TG2IxBAnOp1vKjBw5I0/mNOd 5yUqocsuGzcQxfsT3wPvD8dRKpAjEGTv9bqPZuelLs3WitqsbEgqcQ+eC7IzyMYRlN4j i/aVb0oF2BnRWK8Ib0xbCdtRRfM0q25ptJMMJLy3zuL7l1tJqV2ti+QRJzW/P+06YorG 4zjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=xhf/1dJduLOJCNe2AU9V1VQzCeL9nYRZSP5wzFlpp5w=; b=M0Cm4nNxWbg0DLJp2vLfZQciBfzgnLN8SLlCNtJA/dnEsHjxnMTbaN2YxhX7JOAPQ3 ZPobM82GxJGgJrM8heJGpoWW/s9JVoM4arz9O4dQO0tCVjFa6R+uqYFk0YdX4e+LmRxe TsGmFJkvBaV9HVicdE9958EMQdY7A7MEKt7HjVfaAIBY9w5ddYfS3xvvyXXgatmT7oP3 bHGKzwPC+Z40UTHU22ZwfmMCrGpnfrW/r+FbTmNQWazo9T2ym2nGfstBBUtbtp+AMTpq HuEXags+/8bZJQiJo5tmoCEE1P5Ua05pudW+ERSaZZ54tGvqDWkBne3KVFlwNRpiCtcb NC3A== X-Gm-Message-State: AOAM53101jRC1Hf8QyYNyBMgAY4ieL/KYLs3lAs1bH5hwRNDCpCiwRj/ XpN53wLj/jrh7FBoIRc07f2XYw== X-Received: by 2002:a17:90a:e003:: with SMTP id u3mr1204009pjy.77.1620083708528; Mon, 03 May 2021 16:15:08 -0700 (PDT) Received: from smtpclient.apple ([2601:646:c200:1ef2:e4d2:be75:9322:ee7]) by smtp.gmail.com with ESMTPSA id w2sm10301356pfb.174.2021.05.03.16.15.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 May 2021 16:15:08 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] io_thread/x86: don't reset 'cs', 'ss', 'ds' and 'es' registers for io_threads Date: Mon, 3 May 2021 16:15:06 -0700 Message-Id: <2D8933AD-A3A8-4965-9061-3929D84AAAA2@amacapital.net> References: <8735v3jujv.ffs@nanos.tec.linutronix.de> Cc: Linus Torvalds , Andy Lutomirski , Jens Axboe , Stefan Metzmacher , Linux Kernel Mailing List , io-uring , the arch/x86 maintainers In-Reply-To: <8735v3jujv.ffs@nanos.tec.linutronix.de> To: Thomas Gleixner X-Mailer: iPhone Mail (18E199) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 3, 2021, at 3:56 PM, Thomas Gleixner wrote: >=20 > =EF=BB=BFOn Mon, May 03 2021 at 15:08, Linus Torvalds wrote: >>> On Mon, May 3, 2021 at 2:49 PM Andy Lutomirski wrote: >>>=20 >>> To be clear, I'm suggesting that we -EINVAL the PTRACE_GETREGS calls >>> and such, not the ATTACH. I have no idea what gdb will do if this >>> happens, though. >>=20 >> I feel like the likelihood that it will make gdb work any better is >> basically zero. >>=20 >> I think we should just do Stefan's patch - I assume it generates >> something like four instructions (two loads, two stores) on x86-64, >> and it "just works". >>=20 >> Yeah, yeah, it presumably generates 8 instructions on 32-bit x86, and >> we could fix that by just using the constant __USER_CS/DS instead (no >> loads necessary) since 32-bit doesn't have any compat issues. >>=20 >> But is it worth complicating the patch for a couple of instructions in >> a non-critical path? >>=20 >> And I don't see anybody stepping up to say "yes, I will do the patch >> for gdb", so I really think the least pain is to just take the very >> straightforward and tested kernel patch. >>=20 >> Yes, yes, that also means admitting to ourselves that the gdb >> situation isn't likely going to improve, but hey, if nobody in this >> thread is willing to work on the gdb side to fix the known issues >> there, isn't that the honest thing to do anyway? >=20 > GDB is one thing. But is this setup actually correct under all > circumstances? >=20 > It's all fine that we have lots of blurb about GDB, but there is no > reasoning why this does not affect regular kernel threads which take the > same code path. >=20 > Neither is there an answer what happens in case of a signal delivered to > this thread and what any other GDB/ptraced induced poking might cause. >=20 > This is a half setup user space thread which is assumed to behave like a > regular kernel thread, but is this assumption actually true? >=20 >=20 I=E2=80=99m personally concerned about FPU state. No one ever imagined when w= riting and reviewing the FPU state code that we were going to let ptrace pok= e the state on a kernel thread. Now admittedly kernel_execve() magically turns kernel threads into user thre= ads, but, again, I see no evidence that anyone has thought through all the i= mplications of letting ptrace go to town before doing so. (Is the io_uring thread a kthread style kernel thread? kthread does horribl= e, horrible things with the thread stack.)=